Commit 8278eb8837
Changed files (840)
lib
libcxx
include
__algorithm
__bit
__chrono
__compare
__concepts
__debug_utils
__filesystem
__format
__functional
__fwd
__ios
__iterator
__memory
__random
__ranges
__support
android
musl
openbsd
solaris
win32
__type_traits
__utility
__variant
experimental
src
experimental
include
support
src
lib/libcxx/include/__algorithm/adjacent_find.h
@@ -11,34 +11,42 @@
#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Iter, class _Sent, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter
+__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
+ if (__first == __last)
+ return __first;
+ _Iter __i = __first;
+ while (++__i != __last) {
+ if (__pred(*__first, *__i))
+ return __first;
+ __first = __i;
+ }
+ return __i;
+}
+
template <class _ForwardIterator, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
- if (__first != __last) {
- _ForwardIterator __i = __first;
- while (++__i != __last) {
- if (__pred(*__first, *__i))
- return __first;
- __first = __i;
- }
- }
- return __last;
+ return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::adjacent_find(__first, __last, __equal_to<__v>());
+ return std::adjacent_find(std::move(__first), std::move(__last), __equal_to<__v>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/algorithm_family.h
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H
+#define _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/move.h>
+#include <__algorithm/ranges_move.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _AlgPolicy>
+struct _AlgFamily;
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+template <>
+struct _AlgFamily<_RangeAlgPolicy> {
+ static constexpr auto __move = ranges::move;
+};
+
+#endif
+
+template <>
+struct _AlgFamily<_ClassicAlgPolicy> {
+
+ // move
+ template <class _InputIterator, class _OutputIterator>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 static _OutputIterator
+ __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ return std::move(
+ std::move(__first),
+ std::move(__last),
+ std::move(__result));
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H
lib/libcxx/include/__algorithm/all_of.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/any_of.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/binary_search.h
@@ -16,38 +16,30 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp);
- return __first != __last && !__comp(__value_, *__first);
-}
-
template <class _ForwardIterator, class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
-binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp);
+ using _Comp_ref = typename __comp_ref_type<_Compare>::type;
+ __first = std::lower_bound<_ForwardIterator, _Tp, _Comp_ref>(__first, __last, __value, __comp);
+ return __first != __last && !__comp(__value, *__first);
}
template <class _ForwardIterator, class _Tp>
_LIBCPP_NODISCARD_EXT inline
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
-binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
- return _VSTD::binary_search(__first, __last, __value_,
- __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+ return std::binary_search(__first, __last, __value,
+ __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/clamp.h
@@ -10,11 +10,11 @@
#define _LIBCPP___ALGORITHM_CLAMP_H
#include <__algorithm/comp.h>
+#include <__assert>
#include <__config>
-#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/comp.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/comp_ref_type.h
@@ -10,20 +10,15 @@
#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
#include <__config>
-
-#ifdef _LIBCPP_DEBUG
-# include <__debug>
-# include <__utility/declval.h>
-#endif
+#include <__debug>
+#include <__utility/declval.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifdef _LIBCPP_DEBUG
-
template <class _Compare>
struct __debug_less
{
@@ -57,8 +52,10 @@ struct __debug_less
decltype((void)declval<_Compare&>()(
declval<_LHS &>(), declval<_RHS &>()))
__do_compare_assert(int, _LHS & __l, _RHS & __r) {
- _LIBCPP_ASSERT(!__comp_(__l, __r),
+ _LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),
"Comparator does not induce a strict weak ordering");
+ (void)__l;
+ (void)__r;
}
template <class _LHS, class _RHS>
@@ -67,16 +64,14 @@ struct __debug_less
void __do_compare_assert(long, _LHS &, _RHS &) {}
};
-#endif // _LIBCPP_DEBUG
-
template <class _Comp>
struct __comp_ref_type {
// Pass the comparator by lvalue reference. Or in debug mode, using a
// debugging wrapper that stores a reference.
-#ifndef _LIBCPP_DEBUG
- typedef _Comp& type;
-#else
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
typedef __debug_less<_Comp> type;
+#else
+ typedef _Comp& type;
#endif
};
lib/libcxx/include/__algorithm/copy.h
@@ -10,66 +10,97 @@
#define _LIBCPP___ALGORITHM_COPY_H
#include <__algorithm/unwrap_iter.h>
+#include <__algorithm/unwrap_range.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#include <cstring>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
// copy
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-__copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- *__result = *__first;
- return __result;
+template <class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InIter, _OutIter> __copy_impl(_InIter __first, _Sent __last, _OutIter __result) {
+ while (__first != __last) {
+ *__result = *__first;
+ ++__first;
+ ++__result;
+ }
+ return pair<_InIter, _OutIter>(std::move(__first), std::move(__result));
}
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_OutputIterator
-__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return _VSTD::__copy_constexpr(__first, __last, __result);
+template <class _InValueT,
+ class _OutValueT,
+ class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value
+ && is_trivially_copy_assignable<_OutValueT>::value> >
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, _OutValueT* __result) {
+ if (__libcpp_is_constant_evaluated()
+// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
+#ifndef _LIBCPP_COMPILER_GCC
+ && !is_trivially_copyable<_InValueT>::value
+#endif
+ )
+ return std::__copy_impl<_InValueT*, _InValueT*, _OutValueT*>(__first, __last, __result);
+ const size_t __n = static_cast<size_t>(__last - __first);
+ if (__n > 0)
+ ::__builtin_memmove(__result, __first, __n * sizeof(_OutValueT));
+ return std::make_pair(__first + __n, __result + __n);
+}
+
+template <class _InIter, class _OutIter,
+ __enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value
+ && __is_cpp17_contiguous_iterator<typename _InIter::iterator_type>::value
+ && __is_cpp17_contiguous_iterator<typename _OutIter::iterator_type>::value
+ && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value
+ && __is_reverse_iterator<_InIter>::value
+ && __is_reverse_iterator<_OutIter>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InIter, _OutIter>
+__copy_impl(_InIter __first, _InIter __last, _OutIter __result) {
+ auto __first_base = std::__unwrap_iter(__first.base());
+ auto __last_base = std::__unwrap_iter(__last.base());
+ auto __result_base = std::__unwrap_iter(__result.base());
+ auto __result_first = __result_base - (__first_base - __last_base);
+ std::__copy_impl(__last_base, __first_base, __result_first);
+ return std::make_pair(__last, _OutIter(std::__rewrap_iter(__result.base(), __result_first)));
+}
+
+template <class _InIter, class _Sent, class _OutIter,
+ __enable_if_t<!(is_copy_constructible<_InIter>::value
+ && is_copy_constructible<_Sent>::value
+ && is_copy_constructible<_OutIter>::value), int> = 0 >
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
+ return std::__copy_impl(std::move(__first), std::move(__last), std::move(__result));
}
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_copy_assignable<_Up>::value,
- _Up*
->::type
-__copy(_Tp* __first, _Tp* __last, _Up* __result)
-{
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- return __result + __n;
+template <class _InIter, class _Sent, class _OutIter,
+ __enable_if_t<is_copy_constructible<_InIter>::value
+ && is_copy_constructible<_Sent>::value
+ && is_copy_constructible<_OutIter>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
+ auto __range = std::__unwrap_range(__first, __last);
+ auto __ret = std::__copy_impl(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__result));
+ return std::make_pair(
+ std::__rewrap_range<_Sent>(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
}
template <class _InputIterator, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
-copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__copy_constexpr(__first, __last, __result);
- } else {
- return _VSTD::__rewrap_iter(__result,
- _VSTD::__copy(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result)));
- }
+copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ return std::__copy(__first, __last, __result).second;
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_backward.h
@@ -9,69 +9,51 @@
#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H
#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
+#include <__algorithm/copy.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/ranges_copy.h>
#include <__algorithm/unwrap_iter.h>
+#include <__concepts/same_as.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/subrange.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#include <cstring>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-__copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
-{
- while (__first != __last)
- *--__result = *--__last;
- return __result;
+template <class _AlgPolicy, class _InputIterator, class _OutputIterator,
+ __enable_if_t<is_same<_AlgPolicy, _ClassicAlgPolicy>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InputIterator, _OutputIterator>
+__copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ auto __ret = std::__copy(
+ __unconstrained_reverse_iterator<_InputIterator>(__last),
+ __unconstrained_reverse_iterator<_InputIterator>(__first),
+ __unconstrained_reverse_iterator<_OutputIterator>(__result));
+ return pair<_InputIterator, _OutputIterator>(__ret.first.base(), __ret.second.base());
}
-template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_OutputIterator
-__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
-{
- return _VSTD::__copy_backward_constexpr(__first, __last, __result);
-}
-
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_copy_assignable<_Up>::value,
- _Up*
->::type
-__copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
-{
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- {
- __result -= __n;
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- }
- return __result;
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2,
+ __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) {
+ auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), std::move(__last)));
+ auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result));
+ return std::make_pair(__ret.in.base(), __ret.out.base());
}
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_BidirectionalIterator2
-copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
- _BidirectionalIterator2 __result)
-{
- if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__copy_backward_constexpr(__first, __last, __result);
- } else {
- return _VSTD::__rewrap_iter(__result,
- _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result)));
- }
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator2
+copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
+ return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result).second;
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_if.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_n.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/count.h
@@ -14,7 +14,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -22,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Tp>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename iterator_traits<_InputIterator>::difference_type
- count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {
+ count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
typename iterator_traits<_InputIterator>::difference_type __r(0);
for (; __first != __last; ++__first)
- if (*__first == __value_)
+ if (*__first == __value)
++__r;
return __r;
}
lib/libcxx/include/__algorithm/count_if.h
@@ -14,7 +14,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/equal.h
@@ -16,7 +16,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/equal_range.h
@@ -12,69 +12,71 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/half_positive.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/lower_bound.h>
#include <__algorithm/upper_bound.h>
#include <__config>
-#include <iterator>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/advance.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__type_traits/is_callable.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _ForwardIterator, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
-__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- difference_type __len = _VSTD::distance(__first, __last);
- while (__len != 0)
- {
- difference_type __l2 = _VSTD::__half_positive(__len);
- _ForwardIterator __m = __first;
- _VSTD::advance(__m, __l2);
- if (__comp(*__m, __value_))
- {
- __first = ++__m;
- __len -= __l2 + 1;
- }
- else if (__comp(__value_, *__m))
- {
- __last = __m;
- __len = __l2;
- }
- else
- {
- _ForwardIterator __mp1 = __m;
- return pair<_ForwardIterator, _ForwardIterator>
- (
- _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp),
- _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
- );
- }
+template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_Iter, _Iter>
+__equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
+ auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
+ _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
+ while (__len != 0) {
+ auto __half_len = std::__half_positive(__len);
+ _Iter __mid = _IterOps<_AlgPolicy>::next(__first, __half_len);
+ if (std::__invoke(__comp, std::__invoke(__proj, *__mid), __value)) {
+ __first = ++__mid;
+ __len -= __half_len + 1;
+ } else if (std::__invoke(__comp, __value, std::__invoke(__proj, *__mid))) {
+ __end = __mid;
+ __len = __half_len;
+ } else {
+ _Iter __mp1 = __mid;
+ return pair<_Iter, _Iter>(
+ std::__lower_bound_impl<_AlgPolicy>(__first, __mid, __value, __comp, __proj),
+ std::__upper_bound<_AlgPolicy>(++__mp1, __end, __value, __comp, __proj));
}
- return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
+ }
+ return pair<_Iter, _Iter>(__first, __first);
}
template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-pair<_ForwardIterator, _ForwardIterator>
-equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp);
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
+equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
+ static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
+ "The comparator has to be callable");
+ static_assert(is_copy_constructible<_ForwardIterator>::value,
+ "Iterator has to be copy constructible");
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return std::__equal_range<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), __value, static_cast<_Comp_ref>(__comp), std::__identity());
}
template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-pair<_ForwardIterator, _ForwardIterator>
-equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- return _VSTD::equal_range(__first, __last, __value_,
- __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
+equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
+ return std::equal_range(
+ std::move(__first),
+ std::move(__last),
+ __value,
+ __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/fill.h
@@ -15,34 +15,36 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
+
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
-__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)
+__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
{
for (; __first != __last; ++__first)
- *__first = __value_;
+ *__first = __value;
}
template <class _RandomAccessIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
-__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)
+__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)
{
- _VSTD::fill_n(__first, __last - __first, __value_);
+ _VSTD::fill_n(__first, __last - __first, __value);
}
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
-fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
- _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category());
+ _VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/fill_n.h
@@ -14,27 +14,29 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
+
template <class _OutputIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
-__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
+__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
{
for (; __n > 0; ++__first, (void) --__n)
- *__first = __value_;
+ *__first = __value;
return __first;
}
template <class _OutputIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
-fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
+fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
{
- return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
+ return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value);
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find.h
@@ -13,16 +13,16 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Tp>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
-find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {
+find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
for (; __first != __last; ++__first)
- if (*__first == __value_)
+ if (*__first == __value)
break;
return __first;
}
lib/libcxx/include/__algorithm/find_end.h
@@ -11,44 +11,69 @@
#define _LIBCPP___ALGORITHM_FIND_END_OF_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/search.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/advance.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/reverse_iterator.h>
+#include <__utility/pair.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- _BinaryPredicate __pred, forward_iterator_tag,
- forward_iterator_tag) {
+template <
+ class _AlgPolicy,
+ class _Iter1,
+ class _Sent1,
+ class _Iter2,
+ class _Sent2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2>
+_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Iter1, _Iter1> __find_end_impl(
+ _Iter1 __first1,
+ _Sent1 __last1,
+ _Iter2 __first2,
+ _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2,
+ forward_iterator_tag,
+ forward_iterator_tag) {
// modeled after search algorithm
- _ForwardIterator1 __r = __last1; // __last1 is the "default" answer
+ _Iter1 __match_first = _IterOps<_AlgPolicy>::next(__first1, __last1); // __last1 is the "default" answer
+ _Iter1 __match_last = __match_first;
if (__first2 == __last2)
- return __r;
+ return pair<_Iter1, _Iter1>(__match_last, __match_last);
while (true) {
while (true) {
- if (__first1 == __last1) // if source exhausted return last correct answer
- return __r; // (or __last1 if never found)
- if (__pred(*__first1, *__first2))
+ if (__first1 == __last1) // if source exhausted return last correct answer (or __last1 if never found)
+ return pair<_Iter1, _Iter1>(__match_first, __match_last);
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
break;
++__first1;
}
// *__first1 matches *__first2, now match elements after here
- _ForwardIterator1 __m1 = __first1;
- _ForwardIterator2 __m2 = __first2;
+ _Iter1 __m1 = __first1;
+ _Iter2 __m2 = __first2;
while (true) {
if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one
- __r = __first1;
+ __match_first = __first1;
+ __match_last = ++__m1;
++__first1;
break;
}
if (++__m1 == __last1) // Source exhausted, return last answer
- return __r;
- if (!__pred(*__m1, *__m2)) // mismatch, restart with a new __first
+ return pair<_Iter1, _Iter1>(__match_first, __match_last);
+ // mismatch, restart with a new __first
+ if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2)))
{
++__first1;
break;
@@ -57,33 +82,52 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __f
}
}
-template <class _BinaryPredicate, class _BidirectionalIterator1, class _BidirectionalIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end(
- _BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2,
- _BidirectionalIterator2 __last2, _BinaryPredicate __pred, bidirectional_iterator_tag, bidirectional_iterator_tag) {
+template <
+ class _IterOps,
+ class _Pred,
+ class _Iter1,
+ class _Sent1,
+ class _Iter2,
+ class _Sent2,
+ class _Proj1,
+ class _Proj2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1 __find_end(
+ _Iter1 __first1,
+ _Sent1 __sent1,
+ _Iter2 __first2,
+ _Sent2 __sent2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2,
+ bidirectional_iterator_tag,
+ bidirectional_iterator_tag) {
+ auto __last1 = _IterOps::next(__first1, __sent1);
+ auto __last2 = _IterOps::next(__first2, __sent2);
// modeled after search algorithm (in reverse)
if (__first2 == __last2)
return __last1; // Everything matches an empty sequence
- _BidirectionalIterator1 __l1 = __last1;
- _BidirectionalIterator2 __l2 = __last2;
+ _Iter1 __l1 = __last1;
+ _Iter2 __l2 = __last2;
--__l2;
while (true) {
// Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks
while (true) {
if (__first1 == __l1) // return __last1 if no element matches *__first2
return __last1;
- if (__pred(*--__l1, *__l2))
+ if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2)))
break;
}
// *__l1 matches *__l2, now match elements before here
- _BidirectionalIterator1 __m1 = __l1;
- _BidirectionalIterator2 __m2 = __l2;
+ _Iter1 __m1 = __l1;
+ _Iter2 __m2 = __l2;
while (true) {
if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern)
return __m1;
if (__m1 == __first1) // Otherwise if source exhaused, pattern not found
return __last1;
- if (!__pred(*--__m1, *--__m2)) // if there is a mismatch, restart with a new __l1
+
+ // if there is a mismatch, restart with a new __l1
+ if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2)))
{
break;
} // else there is a match, check next elements
@@ -91,37 +135,53 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end(
}
}
-template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(
- _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
- _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) {
- typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
- typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
+template <
+ class _AlgPolicy,
+ class _Pred,
+ class _Iter1,
+ class _Sent1,
+ class _Iter2,
+ class _Sent2,
+ class _Proj1,
+ class _Proj2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(
+ _Iter1 __first1,
+ _Sent1 __sent1,
+ _Iter2 __first2,
+ _Sent2 __sent2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2,
+ random_access_iterator_tag,
+ random_access_iterator_tag) {
+ typedef typename iterator_traits<_Iter1>::difference_type _D1;
+ auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1);
+ auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2);
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
- _D2 __len2 = __last2 - __first2;
+ auto __len2 = __last2 - __first2;
if (__len2 == 0)
return __last1;
- _D1 __len1 = __last1 - __first1;
+ auto __len1 = __last1 - __first1;
if (__len1 < __len2)
return __last1;
- const _RandomAccessIterator1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here
- _RandomAccessIterator1 __l1 = __last1;
- _RandomAccessIterator2 __l2 = __last2;
+ const _Iter1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here
+ _Iter1 __l1 = __last1;
+ _Iter2 __l2 = __last2;
--__l2;
while (true) {
while (true) {
if (__s == __l1)
return __last1;
- if (__pred(*--__l1, *__l2))
+ if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2)))
break;
}
- _RandomAccessIterator1 __m1 = __l1;
- _RandomAccessIterator2 __m2 = __l2;
+ _Iter1 __m1 = __l1;
+ _Iter2 __m2 = __l2;
while (true) {
if (__m2 == __first2)
return __m1;
// no need to check range on __m1 because __s guarantees we have enough source
- if (!__pred(*--__m1, *--__m2)) {
+ if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(*--__m2))) {
break;
}
}
@@ -129,20 +189,39 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(
}
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
-find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- _BinaryPredicate __pred) {
- return _VSTD::__find_end<_BinaryPredicate&>(
- __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category());
+_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+ _BinaryPredicate& __pred) {
+ auto __proj = __identity();
+ return std::__find_end_impl<_ClassicAlgPolicy>(
+ __first1,
+ __last1,
+ __first2,
+ __last2,
+ __pred,
+ __proj,
+ __proj,
+ typename iterator_traits<_ForwardIterator1>::iterator_category(),
+ typename iterator_traits<_ForwardIterator2>::iterator_category())
+ .first;
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+ _BinaryPredicate __pred) {
+ return std::__find_end_classic(__first1, __last1, __first2, __last2, __pred);
}
template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
-find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
+ using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;
+ using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
+ return std::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_first_of.h
@@ -15,7 +15,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_if.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_if_not.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/for_each.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/for_each_n.h
@@ -14,7 +14,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/generate.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/generate_n.h
@@ -13,7 +13,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/half_positive.h
@@ -13,7 +13,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/in_found_result.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+template <class _InIter1>
+struct in_found_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in;
+ bool found;
+
+ template <class _InIter2>
+ requires convertible_to<const _InIter1&, _InIter2>
+ _LIBCPP_HIDE_FROM_ABI constexpr operator in_found_result<_InIter2>() const & {
+ return {in, found};
+ }
+
+ template <class _InIter2>
+ requires convertible_to<_InIter1, _InIter2>
+ _LIBCPP_HIDE_FROM_ABI constexpr operator in_found_result<_InIter2>() && {
+ return {std::move(in), found};
+ }
+};
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H
lib/libcxx/include/__algorithm/in_fun_result.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IN_FUN_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_FUN_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+template <class _InIter1, class _Func1>
+struct in_fun_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Func1 fun;
+
+ template <class _InIter2, class _Func2>
+ requires convertible_to<const _InIter1&, _InIter2> && convertible_to<const _Func1&, _Func2>
+ _LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_InIter2, _Func2>() const & {
+ return {in, fun};
+ }
+
+ template <class _InIter2, class _Func2>
+ requires convertible_to<_InIter1, _InIter2> && convertible_to<_Func1, _Func2>
+ _LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_InIter2, _Func2>() && {
+ return {std::move(in), std::move(fun)};
+ }
+};
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_FUN_RESULT_H
lib/libcxx/include/__algorithm/in_in_out_result.h
@@ -15,39 +15,41 @@
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
-template <class _I1, class _I2, class _O1>
+template <class _InIter1, class _InIter2, class _OutIter1>
struct in_in_out_result {
- [[no_unique_address]] _I1 in1;
- [[no_unique_address]] _I2 in2;
- [[no_unique_address]] _O1 out;
+ _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in1;
+ _LIBCPP_NO_UNIQUE_ADDRESS _InIter2 in2;
+ _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out;
- template <class _II1, class _II2, class _OO1>
- requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2> && convertible_to<const _O1&, _OO1>
+ template <class _InIter3, class _InIter4, class _OutIter2>
+ requires convertible_to<const _InIter1&, _InIter3>
+ && convertible_to<const _InIter2&, _InIter4> && convertible_to<const _OutIter1&, _OutIter2>
_LIBCPP_HIDE_FROM_ABI constexpr
- operator in_in_out_result<_II1, _II2, _OO1>() const& {
+ operator in_in_out_result<_InIter3, _InIter4, _OutIter2>() const& {
return {in1, in2, out};
}
- template <class _II1, class _II2, class _OO1>
- requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> && convertible_to<_O1, _OO1>
+ template <class _InIter3, class _InIter4, class _OutIter2>
+ requires convertible_to<_InIter1, _InIter3>
+ && convertible_to<_InIter2, _InIter4> && convertible_to<_OutIter1, _OutIter2>
_LIBCPP_HIDE_FROM_ABI constexpr
- operator in_in_out_result<_II1, _II2, _OO1>() && {
- return {_VSTD::move(in1), _VSTD::move(in2), _VSTD::move(out)};
+ operator in_in_out_result<_InIter3, _InIter4, _OutIter2>() && {
+ return {std::move(in1), std::move(in2), std::move(out)};
}
};
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/in_in_result.h
@@ -15,36 +15,38 @@
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
-template <class _I1, class _I2>
+template <class _InIter1, class _InIter2>
struct in_in_result {
- [[no_unique_address]] _I1 in1;
- [[no_unique_address]] _I2 in2;
+ _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in1;
+ _LIBCPP_NO_UNIQUE_ADDRESS _InIter2 in2;
- template <class _II1, class _II2>
- requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2>
+ template <class _InIter3, class _InIter4>
+ requires convertible_to<const _InIter1&, _InIter3> && convertible_to<const _InIter2&, _InIter4>
_LIBCPP_HIDE_FROM_ABI constexpr
- operator in_in_result<_II1, _II2>() const & {
+ operator in_in_result<_InIter3, _InIter4>() const & {
return {in1, in2};
}
- template <class _II1, class _II2>
- requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2>
+ template <class _InIter3, class _InIter4>
+ requires convertible_to<_InIter1, _InIter3> && convertible_to<_InIter2, _InIter4>
_LIBCPP_HIDE_FROM_ABI constexpr
- operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), _VSTD::move(in2)}; }
+ operator in_in_result<_InIter3, _InIter4>() && {
+ return {std::move(in1), std::move(in2)};
+ }
};
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/in_out_out_result.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+template <class _InIter1, class _OutIter1, class _OutIter2>
+struct in_out_out_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in;
+ _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out1;
+ _LIBCPP_NO_UNIQUE_ADDRESS _OutIter2 out2;
+
+ template <class _InIter2, class _OutIter3, class _OutIter4>
+ requires convertible_to<const _InIter1&, _InIter2>
+ && convertible_to<const _OutIter1&, _OutIter3> && convertible_to<const _OutIter2&, _OutIter4>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_out_out_result<_InIter2, _OutIter3, _OutIter4>() const& {
+ return {in, out1, out2};
+ }
+
+ template <class _InIter2, class _OutIter3, class _OutIter4>
+ requires convertible_to<_InIter1, _InIter2>
+ && convertible_to<_OutIter1, _OutIter3> && convertible_to<_OutIter2, _OutIter4>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_out_out_result<_InIter2, _OutIter3, _OutIter4>() && {
+ return {std::move(in), std::move(out1), std::move(out2)};
+ }
+};
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H
lib/libcxx/include/__algorithm/in_out_result.h
@@ -15,39 +15,38 @@
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
-template<class _InputIterator, class _OutputIterator>
+template<class _InIter1, class _OutIter1>
struct in_out_result {
- [[no_unique_address]] _InputIterator in;
- [[no_unique_address]] _OutputIterator out;
+ _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in;
+ _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out;
- template <class _InputIterator2, class _OutputIterator2>
- requires convertible_to<const _InputIterator&, _InputIterator2> && convertible_to<const _OutputIterator&,
- _OutputIterator2>
+ template <class _InIter2, class _OutIter2>
+ requires convertible_to<const _InIter1&, _InIter2> && convertible_to<const _OutIter1&, _OutIter2>
_LIBCPP_HIDE_FROM_ABI
- constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() const & {
+ constexpr operator in_out_result<_InIter2, _OutIter2>() const & {
return {in, out};
}
- template <class _InputIterator2, class _OutputIterator2>
- requires convertible_to<_InputIterator, _InputIterator2> && convertible_to<_OutputIterator, _OutputIterator2>
+ template <class _InIter2, class _OutIter2>
+ requires convertible_to<_InIter1, _InIter2> && convertible_to<_OutIter1, _OutIter2>
_LIBCPP_HIDE_FROM_ABI
- constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() && {
- return {_VSTD::move(in), _VSTD::move(out)};
+ constexpr operator in_out_result<_InIter2, _OutIter2>() && {
+ return {std::move(in), std::move(out)};
}
};
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/includes.h
@@ -12,49 +12,58 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_callable.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _InputIterator1, class _InputIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
- _Compare __comp)
-{
- for (; __first2 != __last2; ++__first1)
- {
- if (__first1 == __last1 || __comp(*__first2, *__first1))
- return false;
- if (!__comp(*__first1, *__first2))
- ++__first2;
- }
- return true;
+template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) {
+ for (; __first2 != __last2; ++__first1) {
+ if (__first1 == __last1 || std::__invoke(
+ __comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1)))
+ return false;
+ if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
+ ++__first2;
+ }
+ return true;
}
template <class _InputIterator1, class _InputIterator2, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
- _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool includes(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _Compare __comp) {
+ static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value,
+ "Comparator has to be callable");
+
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return std::__includes(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ static_cast<_Comp_ref>(__comp), __identity(), __identity());
}
template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
-{
- return _VSTD::includes(__first1, __last1, __first2, __last2,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
+ return std::includes(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/inplace_merge.h
@@ -9,20 +9,25 @@
#ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H
#define _LIBCPP___ALGORITHM_INPLACE_MERGE_H
+#include <__algorithm/algorithm_family.h>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/lower_bound.h>
#include <__algorithm/min.h>
#include <__algorithm/move.h>
#include <__algorithm/rotate.h>
#include <__algorithm/upper_bound.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/advance.h>
+#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
+#include <__iterator/reverse_iterator.h>
#include <memory>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -50,72 +55,79 @@ public:
bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
};
-template <class _Compare, class _InputIterator1, class _InputIterator2,
- class _OutputIterator>
-void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
+template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1,
+ class _InputIterator2, class _Sent2, class _OutputIterator>
+void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,
+ _InputIterator2 __first2, _Sent2 __last2,
+ _OutputIterator __result, _Compare&& __comp)
{
for (; __first1 != __last1; ++__result)
{
if (__first2 == __last2)
{
- _VSTD::move(__first1, __last1, __result);
+ _AlgFamily<_AlgPolicy>::__move(__first1, __last1, __result);
return;
}
if (__comp(*__first2, *__first1))
{
- *__result = _VSTD::move(*__first2);
+ *__result = _IterOps<_AlgPolicy>::__iter_move(__first2);
++__first2;
}
else
{
- *__result = _VSTD::move(*__first1);
+ *__result = _IterOps<_AlgPolicy>::__iter_move(__first1);
++__first1;
}
}
// __first2 through __last2 are already in the right spot.
}
-template <class _Compare, class _BidirectionalIterator>
-void
-__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
- typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
- typename iterator_traits<_BidirectionalIterator>::value_type* __buff)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
+void __buffered_inplace_merge(
+ _BidirectionalIterator __first,
+ _BidirectionalIterator __middle,
+ _BidirectionalIterator __last,
+ _Compare&& __comp,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __buff) {
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
if (__len1 <= __len2)
{
value_type* __p = __buff;
for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
- ::new ((void*)__p) value_type(_VSTD::move(*__i));
- _VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, __first, __comp);
+ ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));
+ std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp);
}
else
{
value_type* __p = __buff;
for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
- ::new ((void*)__p) value_type(_VSTD::move(*__i));
- typedef reverse_iterator<_BidirectionalIterator> _RBi;
- typedef reverse_iterator<value_type*> _Rv;
+ ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));
+ typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi;
+ typedef __unconstrained_reverse_iterator<value_type*> _Rv;
typedef __invert<_Compare> _Inverted;
- _VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff),
+ std::__half_inplace_merge<_AlgPolicy>(_Rv(__p), _Rv(__buff),
_RBi(__middle), _RBi(__first),
_RBi(__last), _Inverted(__comp));
}
}
-template <class _Compare, class _BidirectionalIterator>
-void
-__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
- typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
- typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size)
-{
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
+void __inplace_merge(
+ _BidirectionalIterator __first,
+ _BidirectionalIterator __middle,
+ _BidirectionalIterator __last,
+ _Compare&& __comp,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __buff,
+ ptrdiff_t __buff_size) {
+ using _Ops = _IterOps<_AlgPolicy>;
+
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
while (true)
{
@@ -123,7 +135,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
if (__len2 == 0)
return;
if (__len1 <= __buff_size || __len2 <= __buff_size)
- return _VSTD::__buffered_inplace_merge<_Compare>
+ return std::__buffered_inplace_merge<_AlgPolicy>
(__first, __middle, __last, __comp, __len1, __len2, __buff);
// shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
for (; true; ++__first, (void) --__len1)
@@ -150,36 +162,37 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
{ // __len >= 1, __len2 >= 2
__len21 = __len2 / 2;
__m2 = __middle;
- _VSTD::advance(__m2, __len21);
- __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp);
- __len11 = _VSTD::distance(__first, __m1);
+ _Ops::advance(__m2, __len21);
+ __m1 = std::__upper_bound<_AlgPolicy>(__first, __middle, *__m2, __comp, std::__identity());
+ __len11 = _Ops::distance(__first, __m1);
}
else
{
if (__len1 == 1)
{ // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1
// It is known *__first > *__middle
- swap(*__first, *__middle);
+ _Ops::iter_swap(__first, __middle);
return;
}
// __len1 >= 2, __len2 >= 1
__len11 = __len1 / 2;
__m1 = __first;
- _VSTD::advance(__m1, __len11);
- __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp);
- __len21 = _VSTD::distance(__middle, __m2);
+ _Ops::advance(__m1, __len11);
+ __m2 = std::lower_bound(__middle, __last, *__m1, __comp);
+ __len21 = _Ops::distance(__middle, __m2);
}
difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)
difference_type __len22 = __len2 - __len21; // distance(__m2, __last)
// [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)
// swap middle two partitions
+ // TODO(alg-policy): pass `_AlgPolicy` once it's supported by `rotate`.
__middle = _VSTD::rotate(__m1, __middle, __m2);
// __len12 and __len21 now have swapped meanings
// merge smaller range with recursive call and larger with tail recursion elimination
if (__len11 + __len21 < __len12 + __len22)
{
- _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
-// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
+ std::__inplace_merge<_AlgPolicy>(
+ __first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
__first = __middle;
__middle = __m2;
__len1 = __len12;
@@ -187,8 +200,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
}
else
{
- _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
-// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
+ std::__inplace_merge<_AlgPolicy>(
+ __middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
__last = __middle;
__middle = __m1;
__len1 = __len11;
@@ -197,30 +210,40 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
}
}
-template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+template <class _AlgPolicy, class _BidirectionalIterator, class _Compare>
+_LIBCPP_HIDE_FROM_ABI
void
-inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp)
+__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+ _Compare&& __comp)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
- difference_type __len1 = _VSTD::distance(__first, __middle);
- difference_type __len2 = _VSTD::distance(__middle, __last);
+ difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);
+ difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);
difference_type __buf_size = _VSTD::min(__len1, __len2);
+// TODO: Remove the use of std::get_temporary_buffer
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,
- __buf.first, __buf.second);
+ return std::__inplace_merge<_AlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second);
+}
+
+template <class _BidirectionalIterator, class _Compare>
+inline _LIBCPP_HIDE_FROM_ABI void inplace_merge(
+ _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ std::__inplace_merge<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last), static_cast<_Comp_ref>(__comp));
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
void
inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
{
- _VSTD::inplace_merge(__first, __middle, __last,
+ std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last),
__less<typename iterator_traits<_BidirectionalIterator>::value_type>());
}
lib/libcxx/include/__algorithm/is_heap.h
@@ -16,7 +16,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -28,7 +28,7 @@ bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp) == __last;
+ return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)) == __last;
}
template<class _RandomAccessIterator>
lib/libcxx/include/__algorithm/is_heap_until.h
@@ -15,14 +15,14 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Compare, class _RandomAccessIterator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
-__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
difference_type __len = __last - __first;
@@ -52,7 +52,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp);
+ return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp));
}
template<class _RandomAccessIterator>
lib/libcxx/include/__algorithm/is_partitioned.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/is_permutation.h
@@ -17,7 +17,7 @@
#include <__iterator/next.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/is_sorted.h
@@ -16,7 +16,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/is_sorted_until.h
@@ -15,7 +15,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/iter_swap.h
@@ -14,7 +14,7 @@
#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/iterator_operations.h
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H
+#define _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H
+
+#include <__algorithm/iter_swap.h>
+#include <__config>
+#include <__iterator/advance.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/readable_traits.h>
+#include <__utility/declval.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _AlgPolicy> struct _IterOps;
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+struct _RangeAlgPolicy {};
+
+template <>
+struct _IterOps<_RangeAlgPolicy> {
+
+ template <class _Iter>
+ using __value_type = iter_value_t<_Iter>;
+
+ static constexpr auto advance = ranges::advance;
+ static constexpr auto distance = ranges::distance;
+ static constexpr auto __iter_move = ranges::iter_move;
+ static constexpr auto iter_swap = ranges::iter_swap;
+ static constexpr auto next = ranges::next;
+ static constexpr auto __advance_to = ranges::advance;
+};
+
+#endif
+
+struct _ClassicAlgPolicy {};
+
+template <>
+struct _IterOps<_ClassicAlgPolicy> {
+
+ template <class _Iter>
+ using __value_type = typename iterator_traits<_Iter>::value_type;
+
+ // advance
+ template <class _Iter, class _Distance>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ static void advance(_Iter& __iter, _Distance __count) {
+ std::advance(__iter, __count);
+ }
+
+ // distance
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ static typename iterator_traits<_Iter>::difference_type distance(_Iter __first, _Iter __last) {
+ return std::distance(__first, __last);
+ }
+
+ template <class _Iter>
+ using __deref_t = decltype(*std::declval<_Iter&>());
+
+ template <class _Iter>
+ using __move_t = decltype(std::move(*std::declval<_Iter&>()));
+
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ static void __validate_iter_reference() {
+ static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
+ "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
+ "dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] "
+ "and can lead to dangling reference issues at runtime, so we are flagging this.");
+ }
+
+ // iter_move
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
+ // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note
+ // that the C++03 mode doesn't support `decltype(auto)` as the return type.
+ __enable_if_t<
+ is_reference<__deref_t<_Iter> >::value,
+ __move_t<_Iter> >
+ __iter_move(_Iter&& __i) {
+ __validate_iter_reference<_Iter>();
+
+ return std::move(*std::forward<_Iter>(__i));
+ }
+
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
+ // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a
+ // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that
+ // temporary. Note that the C++03 mode doesn't support `auto` as the return type.
+ __enable_if_t<
+ !is_reference<__deref_t<_Iter> >::value,
+ __deref_t<_Iter> >
+ __iter_move(_Iter&& __i) {
+ __validate_iter_reference<_Iter>();
+
+ return *std::forward<_Iter>(__i);
+ }
+
+ // iter_swap
+ template <class _Iter1, class _Iter2>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ static void iter_swap(_Iter1&& __a, _Iter2&& __b) {
+ std::iter_swap(std::forward<_Iter1>(__a), std::forward<_Iter2>(__b));
+ }
+
+ // next
+ template <class _Iterator>
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _Iterator next(_Iterator, _Iterator __last) {
+ return __last;
+ }
+
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
+ __uncvref_t<_Iter> next(_Iter&& __it,
+ typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1){
+ return std::next(std::forward<_Iter>(__it), __n);
+ }
+
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
+ void __advance_to(_Iter& __first, _Iter __last) {
+ __first = __last;
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H
lib/libcxx/include/__algorithm/lexicographical_compare.h
@@ -15,7 +15,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/lower_bound.h
@@ -11,54 +11,56 @@
#include <__algorithm/comp.h>
#include <__algorithm/half_positive.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
-#include <iterator>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/advance.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_callable.h>
+#include <__type_traits/remove_reference.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _ForwardIterator, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- difference_type __len = _VSTD::distance(__first, __last);
- while (__len != 0)
- {
- difference_type __l2 = _VSTD::__half_positive(__len);
- _ForwardIterator __m = __first;
- _VSTD::advance(__m, __l2);
- if (__comp(*__m, __value_))
- {
- __first = ++__m;
- __len -= __l2 + 1;
- }
- else
- __len = __l2;
+template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
+ auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
+
+ while (__len != 0) {
+ auto __l2 = std::__half_positive(__len);
+ _Iter __m = __first;
+ _IterOps<_AlgPolicy>::advance(__m, __l2);
+ if (std::__invoke(__comp, std::__invoke(__proj, *__m), __value)) {
+ __first = ++__m;
+ __len -= __l2 + 1;
+ } else {
+ __len = __l2;
}
- return __first;
+ }
+ return __first;
}
template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- return _VSTD::__lower_bound<_Compare&>(__first, __last, __value_, __comp);
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
+ static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
+ "The comparator has to be callable");
+ auto __proj = std::__identity();
+ return std::__lower_bound_impl<_ClassicAlgPolicy>(__first, __last, __value, __comp, __proj);
}
template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- return _VSTD::lower_bound(__first, __last, __value_,
- __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
+ return std::lower_bound(__first, __last, __value,
+ __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/make_heap.h
@@ -11,47 +11,45 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/sift_down.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 void
-__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- difference_type __n = __last - __first;
- if (__n > 1)
- {
- // start from the first parent, there is no need to consider children
- for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
- {
- _VSTD::__sift_down<_Compare>(__first, __comp, __n, __first + __start);
- }
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
+ using _CompRef = typename __comp_ref_type<_Compare>::type;
+ _CompRef __comp_ref = __comp;
+
+ using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
+ difference_type __n = __last - __first;
+ if (__n > 1) {
+ // start from the first parent, there is no need to consider children
+ for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) {
+ std::__sift_down<_AlgPolicy>(__first, __comp_ref, __n, __first + __start);
}
+ }
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp);
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ std::__make_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
}
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::make_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
+ std::make_heap(std::move(__first), std::move(__last),
+ __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/make_projected.h
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
+#define _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
+
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_member_pointer.h>
+#include <__type_traits/is_same.h>
+#include <__utility/declval.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Pred, class _Proj>
+struct _ProjectedPred {
+ _Pred& __pred; // Can be a unary or a binary predicate.
+ _Proj& __proj;
+
+ _LIBCPP_CONSTEXPR _ProjectedPred(_Pred& __pred_arg, _Proj& __proj_arg) : __pred(__pred_arg), __proj(__proj_arg) {}
+
+ template <class _Tp>
+ typename __invoke_of<_Pred&,
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))
+ >::type
+ _LIBCPP_CONSTEXPR operator()(_Tp&& __v) const {
+ return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));
+ }
+
+ template <class _T1, class _T2>
+ typename __invoke_of<_Pred&,
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))
+ >::type
+ _LIBCPP_CONSTEXPR operator()(_T1&& __lhs, _T2&& __rhs) const {
+ return std::__invoke(__pred,
+ std::__invoke(__proj, std::forward<_T1>(__lhs)),
+ std::__invoke(__proj, std::forward<_T2>(__rhs)));
+ }
+
+};
+
+template <class _Pred, class _Proj, class = void>
+struct __can_use_pristine_comp : false_type {};
+
+template <class _Pred, class _Proj>
+struct __can_use_pristine_comp<_Pred, _Proj, __enable_if_t<
+ !is_member_pointer<typename decay<_Pred>::type>::value && (
+#if _LIBCPP_STD_VER > 17
+ is_same<typename decay<_Proj>::type, identity>::value ||
+#endif
+ is_same<typename decay<_Proj>::type, __identity>::value
+ )
+> > : true_type {};
+
+template <class _Pred, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+__enable_if_t<
+ !__can_use_pristine_comp<_Pred, _Proj>::value,
+ _ProjectedPred<_Pred, _Proj>
+>
+__make_projected(_Pred& __pred, _Proj& __proj) {
+ return _ProjectedPred<_Pred, _Proj>(__pred, __proj);
+}
+
+// Avoid creating the functor and just use the pristine comparator -- for certain algorithms, this would enable
+// optimizations that rely on the type of the comparator. Additionally, this results in less layers of indirection in
+// the call stack when the comparator is invoked, even in an unoptimized build.
+template <class _Pred, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+__enable_if_t<
+ __can_use_pristine_comp<_Pred, _Proj>::value,
+ _Pred&
+>
+__make_projected(_Pred& __pred, _Proj&) {
+ return __pred;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Comp, class _Proj1, class _Proj2>
+_LIBCPP_HIDE_FROM_ABI constexpr static
+decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
+ if constexpr (same_as<decay_t<_Proj1>, identity> && same_as<decay_t<_Proj2>, identity> &&
+ !is_member_pointer_v<decay_t<_Comp>>) {
+ // Avoid creating the lambda and just use the pristine comparator -- for certain algorithms, this would enable
+ // optimizations that rely on the type of the comparator.
+ return __comp;
+
+ } else {
+ return [&](auto&& __lhs, auto&& __rhs) {
+ return std::invoke(__comp,
+ std::invoke(__proj1, std::forward<decltype(__lhs)>(__lhs)),
+ std::invoke(__proj2, std::forward<decltype(__rhs)>(__rhs)));
+ };
+ }
+}
+
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
lib/libcxx/include/__algorithm/max.h
@@ -16,7 +16,7 @@
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__algorithm/max_element.h
@@ -15,7 +15,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/merge.h
@@ -16,7 +16,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/min.h
@@ -16,7 +16,7 @@
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__algorithm/min_element.h
@@ -12,36 +12,50 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_callable.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _ForwardIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
-__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
- static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
- "std::min_element requires a ForwardIterator");
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- while (++__i != __last)
- if (__comp(*__i, *__first))
- __first = __i;
- }
+template <class _Comp, class _Iter, class _Sent, class _Proj>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {
+ if (__first == __last)
return __first;
+
+ _Iter __i = __first;
+ while (++__i != __last)
+ if (std::__invoke(__comp, std::__invoke(__proj, *__i), std::__invoke(__proj, *__first)))
+ __first = __i;
+
+ return __first;
+}
+
+template <class _Comp, class _Iter, class _Sent>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp) {
+ auto __proj = __identity();
+ return std::__min_element<_Comp>(std::move(__first), std::move(__last), __comp, __proj);
}
template <class _ForwardIterator, class _Compare>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__min_element<_Comp_ref>(__first, __last, __comp);
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
+ "std::min_element requires a ForwardIterator");
+ static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
+ "The comparator has to be callable");
+
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return std::__min_element<_Comp_ref>(std::move(__first), std::move(__last), __comp);
}
template <class _ForwardIterator>
lib/libcxx/include/__algorithm/min_max_result.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MIN_MAX_RESULT_H
+#define _LIBCPP___ALGORITHM_MIN_MAX_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template <class _T1>
+struct min_max_result {
+ _LIBCPP_NO_UNIQUE_ADDRESS _T1 min;
+ _LIBCPP_NO_UNIQUE_ADDRESS _T1 max;
+
+ template <class _T2>
+ requires convertible_to<const _T1&, _T2>
+ _LIBCPP_HIDE_FROM_ABI constexpr operator min_max_result<_T2>() const & {
+ return {min, max};
+ }
+
+ template <class _T2>
+ requires convertible_to<_T1, _T2>
+ _LIBCPP_HIDE_FROM_ABI constexpr operator min_max_result<_T2>() && {
+ return {std::move(min), std::move(max)};
+ }
+};
+
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MIN_MAX_RESULT_H
lib/libcxx/include/__algorithm/minmax.h
@@ -10,12 +10,15 @@
#define _LIBCPP___ALGORITHM_MINMAX_H
#include <__algorithm/comp.h>
+#include <__algorithm/minmax_element.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__type_traits/is_callable.h>
+#include <__utility/pair.h>
#include <initializer_list>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -36,47 +39,18 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b)
{
- return _VSTD::minmax(__a, __b, __less<_Tp>());
+ return std::minmax(__a, __b, __less<_Tp>());
}
#ifndef _LIBCPP_CXX03_LANG
template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_Tp, _Tp>
-minmax(initializer_list<_Tp> __t, _Compare __comp)
-{
- typedef typename initializer_list<_Tp>::const_iterator _Iter;
- _Iter __first = __t.begin();
- _Iter __last = __t.end();
- pair<_Tp, _Tp> __result(*__first, *__first);
-
- ++__first;
- if (__t.size() % 2 == 0)
- {
- if (__comp(*__first, __result.first))
- __result.first = *__first;
- else
- __result.second = *__first;
- ++__first;
- }
-
- while (__first != __last)
- {
- _Tp __prev = *__first++;
- if (__comp(*__first, __prev)) {
- if ( __comp(*__first, __result.first)) __result.first = *__first;
- if (!__comp(__prev, __result.second)) __result.second = __prev;
- }
- else {
- if ( __comp(__prev, __result.first)) __result.first = __prev;
- if (!__comp(*__first, __result.second)) __result.second = *__first;
- }
-
- __first++;
- }
- return __result;
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
+ static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");
+ __identity __proj;
+ auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj);
+ return pair<_Tp, _Tp>(*__ret.first, *__ret.second);
}
template<class _Tp>
@@ -85,7 +59,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __t)
{
- return _VSTD::minmax(__t, __less<_Tp>());
+ return std::minmax(__t, __less<_Tp>());
}
#endif // _LIBCPP_CXX03_LANG
lib/libcxx/include/__algorithm/minmax_element.h
@@ -11,73 +11,89 @@
#include <__algorithm/comp.h>
#include <__config>
+#include <__functional/identity.h>
#include <__iterator/iterator_traits.h>
-#include <utility>
+#include <__utility/pair.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Comp, class _Proj>
+class _MinmaxElementLessFunc {
+ _Comp& __comp_;
+ _Proj& __proj_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ _MinmaxElementLessFunc(_Comp& __comp, _Proj& __proj) : __comp_(__comp), __proj_(__proj) {}
+
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(_Iter& __it1, _Iter& __it2) {
+ return std::__invoke(__comp_, std::__invoke(__proj_, *__it1), std::__invoke(__proj_, *__it2));
+ }
+};
+
+template <class _Iter, class _Sent, class _Proj, class _Comp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);
+
+ pair<_Iter, _Iter> __result(__first, __first);
+ if (__first == __last || ++__first == __last)
+ return __result;
+
+ if (__less(__first, __result.first))
+ __result.first = __first;
+ else
+ __result.second = __first;
+
+ while (++__first != __last) {
+ _Iter __i = __first;
+ if (++__first == __last) {
+ if (__less(__i, __result.first))
+ __result.first = __i;
+ else if (!__less(__i, __result.second))
+ __result.second = __i;
+ return __result;
+ }
+
+ if (__less(__first, __i)) {
+ if (__less(__first, __result.first))
+ __result.first = __first;
+ if (!__less(__i, __result.second))
+ __result.second = __i;
+ } else {
+ if (__less(__i, __result.first))
+ __result.first = __i;
+ if (!__less(__first, __result.second))
+ __result.second = __first;
+ }
+ }
+
+ return __result;
+}
+
template <class _ForwardIterator, class _Compare>
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<_ForwardIterator, _ForwardIterator>
-minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
+minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
- "std::minmax_element requires a ForwardIterator");
- pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
- if (__first != __last)
- {
- if (++__first != __last)
- {
- if (__comp(*__first, *__result.first))
- __result.first = __first;
- else
- __result.second = __first;
- while (++__first != __last)
- {
- _ForwardIterator __i = __first;
- if (++__first == __last)
- {
- if (__comp(*__i, *__result.first))
- __result.first = __i;
- else if (!__comp(*__i, *__result.second))
- __result.second = __i;
- break;
- }
- else
- {
- if (__comp(*__first, *__i))
- {
- if (__comp(*__first, *__result.first))
- __result.first = __first;
- if (!__comp(*__i, *__result.second))
- __result.second = __i;
- }
- else
- {
- if (__comp(*__i, *__result.first))
- __result.first = __i;
- if (!__comp(*__first, *__result.second))
- __result.second = __first;
- }
- }
- }
- }
- }
- return __result;
+ "std::minmax_element requires a ForwardIterator");
+ static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
+ "The comparator has to be callable");
+ auto __proj = __identity();
+ return std::__minmax_element_impl(__first, __last, __comp, __proj);
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_ForwardIterator, _ForwardIterator>
-minmax_element(_ForwardIterator __first, _ForwardIterator __last)
-{
- return _VSTD::minmax_element(__first, __last,
- __less<typename iterator_traits<_ForwardIterator>::value_type>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
+ return std::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/mismatch.h
@@ -13,10 +13,10 @@
#include <__algorithm/comp.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <utility>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/move.h
@@ -11,66 +11,103 @@
#include <__algorithm/unwrap_iter.h>
#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#include <cstring>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
// move
-template <class _InputIterator, class _OutputIterator>
+template <class _InIter, class _Sent, class _OutIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- *__result = _VSTD::move(*__first);
- return __result;
+pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
+ while (__first != __last) {
+ *__result = std::move(*__first);
+ ++__first;
+ ++__result;
+ }
+ return std::make_pair(std::move(__first), std::move(__result));
}
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return _VSTD::__move_constexpr(__first, __last, __result);
+template <class _InType,
+ class _OutType,
+ class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value
+ && is_trivially_move_assignable<_OutType>::value> >
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutType* __result) {
+ if (__libcpp_is_constant_evaluated()
+// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
+#ifndef _LIBCPP_COMPILER_GCC
+ && !is_trivially_copyable<_InType>::value
+#endif
+ )
+ return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result);
+ const size_t __n = static_cast<size_t>(__last - __first);
+ ::__builtin_memmove(__result, __first, __n * sizeof(_OutType));
+ return std::make_pair(__first + __n, __result + __n);
}
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_move_assignable<_Up>::value,
- _Up*
->::type
-__move(_Tp* __first, _Tp* __last, _Up* __result)
-{
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- return __result + __n;
+template <class>
+struct __is_trivially_move_assignable_unwrapped_impl : false_type {};
+
+template <class _Type>
+struct __is_trivially_move_assignable_unwrapped_impl<_Type*> : is_trivially_move_assignable<_Type> {};
+
+template <class _Iter>
+struct __is_trivially_move_assignable_unwrapped
+ : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {};
+
+template <class _InIter,
+ class _OutIter,
+ __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type,
+ typename iterator_traits<_OutIter>::value_type>::value
+ && __is_cpp17_contiguous_iterator<_InIter>::value
+ && __is_cpp17_contiguous_iterator<_OutIter>::value
+ && is_trivially_move_assignable<__iter_value_type<_OutIter> >::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> >
+__move_impl(reverse_iterator<_InIter> __first,
+ reverse_iterator<_InIter> __last,
+ reverse_iterator<_OutIter> __result) {
+ auto __first_base = std::__unwrap_iter(__first.base());
+ auto __last_base = std::__unwrap_iter(__last.base());
+ auto __result_base = std::__unwrap_iter(__result.base());
+ auto __result_first = __result_base - (__first_base - __last_base);
+ std::__move_impl(__last_base, __first_base, __result_first);
+ return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first)));
+}
+
+template <class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+__enable_if_t<is_copy_constructible<_InIter>::value
+ && is_copy_constructible<_Sent>::value
+ && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
+__move(_InIter __first, _Sent __last, _OutIter __result) {
+ auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
+ return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
+}
+
+template <class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+__enable_if_t<!is_copy_constructible<_InIter>::value
+ || !is_copy_constructible<_Sent>::value
+ || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
+__move(_InIter __first, _Sent __last, _OutIter __result) {
+ return std::__move_impl(std::move(__first), std::move(__last), std::move(__result));
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__move_constexpr(__first, __last, __result);
- } else {
- return _VSTD::__rewrap_iter(__result,
- _VSTD::__move(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result)));
- }
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ return std::__move(__first, __last, __result).second;
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/move_backward.h
@@ -11,12 +11,12 @@
#include <__algorithm/unwrap_iter.h>
#include <__config>
+#include <__utility/move.h>
#include <cstring>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/next_permutation.h
@@ -17,7 +17,7 @@
#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/none_of.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/nth_element.h
@@ -11,17 +11,16 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/sort.h>
#include <__config>
+#include <__debug>
+#include <__debug_utils/randomize_range.h>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
-
-#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
-# include <__algorithm/shuffle.h>
-#endif
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -42,10 +41,12 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
}
}
-template <class _Compare, class _RandomAccessIterator>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
{
+ using _Ops = _IterOps<_AlgPolicy>;
+
// _Compare is known to be a reference type
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
const difference_type __limit = 7;
@@ -61,24 +62,24 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
return;
case 2:
if (__comp(*--__last, *__first))
- swap(*__first, *__last);
+ _Ops::iter_swap(__first, __last);
return;
case 3:
{
_RandomAccessIterator __m = __first;
- _VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp);
+ std::__sort3<_AlgPolicy, _Compare>(__first, ++__m, --__last, __comp);
return;
}
}
if (__len <= __limit)
{
- _VSTD::__selection_sort<_Compare>(__first, __last, __comp);
+ std::__selection_sort<_AlgPolicy, _Compare>(__first, __last, __comp);
return;
}
// __len > __limit >= 3
_RandomAccessIterator __m = __first + __len/2;
_RandomAccessIterator __lm1 = __last;
- unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp);
+ unsigned __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, --__lm1, __comp);
// *__m is median
// partition [__first, __m) < *__m and *__m <= [__m, __last)
// (this inhibits tossing elements equivalent to __m around unnecessarily)
@@ -91,7 +92,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
{
// *__first == *__m, *__first doesn't go in first part
if (_VSTD::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) {
- swap(*__i, *__j);
+ _Ops::iter_swap(__i, __j);
++__n_swaps;
} else {
// *__first == *__m, *__m <= all other elements
@@ -103,7 +104,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
if (__i == __j) {
return; // [__first, __last) all equivalent elements
} else if (__comp(*__first, *__i)) {
- swap(*__i, *__j);
+ _Ops::iter_swap(__i, __j);
++__n_swaps;
++__i;
break;
@@ -122,7 +123,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
;
if (__i >= __j)
break;
- swap(*__i, *__j);
+ _Ops::iter_swap(__i, __j);
++__n_swaps;
++__i;
}
@@ -153,7 +154,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
;
if (__i >= __j)
break;
- swap(*__i, *__j);
+ _Ops::iter_swap(__i, __j);
++__n_swaps;
// It is known that __m != __j
// If __m just moved, follow it
@@ -165,7 +166,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
// [__first, __i) < *__m and *__m <= [__i, __last)
if (__i != __m && __comp(*__m, *__i))
{
- swap(*__i, *__m);
+ _Ops::iter_swap(__i, __m);
++__n_swaps;
}
// [__first, __i) < *__i and *__i <= [__i+1, __last)
@@ -221,26 +222,36 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
}
}
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
-{
- _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp);
- _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __nth);
+template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
+ _Compare& __comp) {
+ if (__nth == __last)
+ return;
+
+ std::__debug_randomize_range<_AlgPolicy>(__first, __last);
+
+ using _Comp_ref = typename __comp_ref_type<_Compare>::type;
+ std::__nth_element<_AlgPolicy, _Comp_ref>(__first, __nth, __last, __comp);
+
+ std::__debug_randomize_range<_AlgPolicy>(__first, __nth);
if (__nth != __last) {
- _LIBCPP_DEBUG_RANDOMIZE_RANGE(++__nth, __last);
+ std::__debug_randomize_range<_AlgPolicy>(++__nth, __last);
}
}
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
+ _Compare __comp) {
+ std::__nth_element_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__nth), std::move(__last), __comp);
+}
+
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last)
-{
- _VSTD::nth_element(__first, __nth, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) {
+ std::nth_element(std::move(__first), std::move(__nth), std::move(__last), __less<typename
+ iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/partial_sort.h
@@ -11,41 +11,64 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_heap.h>
#include <__algorithm/sift_down.h>
#include <__algorithm/sort_heap.h>
#include <__config>
+#include <__debug>
+#include <__debug_utils/randomize_range.h>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
-
-#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
-# include <__algorithm/shuffle.h>
-#endif
+#include <__utility/move.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 void
-__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
- _Compare __comp)
-{
- if (__first == __middle)
- return;
- _VSTD::__make_heap<_Compare>(__first, __middle, __comp);
- typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
- for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)
- {
- if (__comp(*__i, *__first))
- {
- swap(*__i, *__first);
- _VSTD::__sift_down<_Compare>(__first, __comp, __len, __first);
- }
- }
- _VSTD::__sort_heap<_Compare>(__first, __middle, __comp);
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
+_RandomAccessIterator __partial_sort_impl(
+ _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare&& __comp) {
+ if (__first == __middle) {
+ return _IterOps<_AlgPolicy>::next(__middle, __last);
+ }
+
+ std::__make_heap<_AlgPolicy>(__first, __middle, __comp);
+
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
+ _RandomAccessIterator __i = __middle;
+ for (; __i != __last; ++__i)
+ {
+ if (__comp(*__i, *__first))
+ {
+ _IterOps<_AlgPolicy>::iter_swap(__i, __first);
+ std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first);
+ }
+
+ }
+ std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp);
+
+ return __i;
+}
+
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
+_RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last,
+ _Compare& __comp) {
+ if (__first == __middle)
+ return _IterOps<_AlgPolicy>::next(__middle, __last);
+
+ std::__debug_randomize_range<_AlgPolicy>(__first, __last);
+
+ using _Comp_ref = typename __comp_ref_type<_Compare>::type;
+ auto __last_iter = std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<_Comp_ref>(__comp));
+
+ std::__debug_randomize_range<_AlgPolicy>(__middle, __last);
+
+ return __last_iter;
}
template <class _RandomAccessIterator, class _Compare>
@@ -54,10 +77,10 @@ void
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
_Compare __comp)
{
- _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
- _LIBCPP_DEBUG_RANDOMIZE_RANGE(__middle, __last);
+ static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
+ static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
+
+ (void)std::__partial_sort<_ClassicAlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __comp);
}
template <class _RandomAccessIterator>
lib/libcxx/include/__algorithm/partial_sort_copy.h
@@ -11,39 +11,52 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_heap.h>
+#include <__algorithm/make_projected.h>
#include <__algorithm/sift_down.h>
#include <__algorithm/sort_heap.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_callable.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _InputIterator, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
-__partial_sort_copy(_InputIterator __first, _InputIterator __last,
- _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
+template <class _AlgPolicy, class _Compare,
+ class _InputIterator, class _Sentinel1, class _RandomAccessIterator, class _Sentinel2,
+ class _Proj1, class _Proj2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator, _RandomAccessIterator>
+__partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
+ _RandomAccessIterator __result_first, _Sentinel2 __result_last,
+ _Compare&& __comp, _Proj1&& __proj1, _Proj2&& __proj2)
{
_RandomAccessIterator __r = __result_first;
+ auto&& __projected_comp = std::__make_projected(__comp, __proj2);
+
if (__r != __result_last)
{
for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
*__r = *__first;
- _VSTD::__make_heap<_Compare>(__result_first, __r, __comp);
+ std::__make_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
for (; __first != __last; ++__first)
- if (__comp(*__first, *__result_first))
- {
+ if (std::__invoke(__comp, std::__invoke(__proj1, *__first), std::__invoke(__proj2, *__result_first))) {
*__result_first = *__first;
- _VSTD::__sift_down<_Compare>(__result_first, __comp, __len, __result_first);
+ std::__sift_down<_AlgPolicy>(__result_first, __projected_comp, __len, __result_first);
}
- _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp);
+ std::__sort_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
}
- return __r;
+
+ return pair<_InputIterator, _RandomAccessIterator>(
+ _IterOps<_AlgPolicy>::next(std::move(__first), std::move(__last)), std::move(__r));
}
template <class _InputIterator, class _RandomAccessIterator, class _Compare>
@@ -52,8 +65,13 @@ _RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
+ static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,
+ "Comparator has to be callable");
+
+ using _Comp_ref = typename __comp_ref_type<_Compare>::type;
+ auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(__first, __last, __result_first, __result_last,
+ static_cast<_Comp_ref>(__comp), __identity(), __identity());
+ return __result.second;
}
template <class _InputIterator, class _RandomAccessIterator>
lib/libcxx/include/__algorithm/partition.h
@@ -9,50 +9,58 @@
#ifndef _LIBCPP___ALGORITHM_PARTITION_H
#define _LIBCPP___ALGORITHM_PARTITION_H
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Predicate, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
+template <class _Predicate, class _AlgPolicy, class _ForwardIterator, class _Sentinel>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
+__partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag)
{
while (true)
{
if (__first == __last)
- return __first;
+ return std::make_pair(std::move(__first), std::move(__first));
if (!__pred(*__first))
break;
++__first;
}
- for (_ForwardIterator __p = __first; ++__p != __last;)
+
+ _ForwardIterator __p = __first;
+ while (++__p != __last)
{
if (__pred(*__p))
{
- swap(*__first, *__p);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __p);
++__first;
}
}
- return __first;
+ return std::make_pair(std::move(__first), std::move(__p));
}
-template <class _Predicate, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator
-__partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+template <class _Predicate, class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_BidirectionalIterator, _BidirectionalIterator>
+__partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicate __pred,
bidirectional_iterator_tag)
{
+ _BidirectionalIterator __original_last = _IterOps<_AlgPolicy>::next(__first, __sentinel);
+ _BidirectionalIterator __last = __original_last;
+
while (true)
{
while (true)
{
if (__first == __last)
- return __first;
+ return std::make_pair(std::move(__first), std::move(__original_last));
if (!__pred(*__first))
break;
++__first;
@@ -60,20 +68,29 @@ __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Pred
do
{
if (__first == --__last)
- return __first;
+ return std::make_pair(std::move(__first), std::move(__original_last));
} while (!__pred(*__last));
- swap(*__first, *__last);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __last);
++__first;
}
}
+template <class _AlgPolicy, class _ForwardIterator, class _Sentinel, class _Predicate, class _IterCategory>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+pair<_ForwardIterator, _ForwardIterator> __partition(
+ _ForwardIterator __first, _Sentinel __last, _Predicate&& __pred, _IterCategory __iter_category) {
+ return std::__partition_impl<__uncvref_t<_Predicate>&, _AlgPolicy>(
+ std::move(__first), std::move(__last), __pred, __iter_category);
+}
+
template <class _ForwardIterator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
- return _VSTD::__partition<_Predicate&>(
- __first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+ using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category;
+ auto __result = std::__partition<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred, _IterCategory());
+ return __result.first;
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/partition_copy.h
@@ -11,10 +11,10 @@
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <utility> // pair
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/partition_point.h
@@ -11,10 +11,12 @@
#include <__algorithm/half_positive.h>
#include <__config>
-#include <iterator>
+#include <__iterator/advance.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/pop_heap.h
@@ -11,45 +11,62 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/push_heap.h>
#include <__algorithm/sift_down.h>
+#include <__assert>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
+#include <__utility/move.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __len)
-{
- if (__len > 1)
- {
- swap(*__first, *--__last);
- _VSTD::__sift_down<_Compare>(__first, __comp, __len - 1, __first);
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
+ _LIBCPP_ASSERT(__len > 0, "The heap given to pop_heap must be non-empty");
+
+ using _CompRef = typename __comp_ref_type<_Compare>::type;
+ _CompRef __comp_ref = __comp;
+
+ using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
+ if (__len > 1) {
+ value_type __top = _IterOps<_AlgPolicy>::__iter_move(__first); // create a hole at __first
+ _RandomAccessIterator __hole = std::__floyd_sift_down<_AlgPolicy>(__first, __comp_ref, __len);
+ --__last;
+
+ if (__hole == __last) {
+ *__hole = std::move(__top);
+ } else {
+ *__hole = _IterOps<_AlgPolicy>::__iter_move(__last);
+ ++__hole;
+ *__last = std::move(__top);
+ std::__sift_up<_AlgPolicy>(__first, __hole, __comp_ref, __hole - __first);
}
+ }
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
+ static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
+
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first;
+ std::__pop_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp, __len);
}
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::pop_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
+ std::pop_heap(std::move(__first), std::move(__last),
+ __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/prev_permutation.h
@@ -17,7 +17,7 @@
#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/push_heap.h
@@ -11,58 +11,66 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 void
-__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __len)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- if (__len > 1)
- {
- __len = (__len - 2) / 2;
- _RandomAccessIterator __ptr = __first + __len;
- if (__comp(*__ptr, *--__last))
- {
- value_type __t(_VSTD::move(*__last));
- do
- {
- *__last = _VSTD::move(*__ptr);
- __last = __ptr;
- if (__len == 0)
- break;
- __len = (__len - 1) / 2;
- __ptr = __first + __len;
- } while (__comp(*__ptr, __t));
- *__last = _VSTD::move(__t);
- }
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
+ using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
+
+ if (__len > 1) {
+ __len = (__len - 2) / 2;
+ _RandomAccessIterator __ptr = __first + __len;
+
+ if (__comp(*__ptr, *--__last)) {
+ value_type __t(_IterOps<_AlgPolicy>::__iter_move(__last));
+ do {
+ *__last = _IterOps<_AlgPolicy>::__iter_move(__ptr);
+ __last = __ptr;
+ if (__len == 0)
+ break;
+ __len = (__len - 1) / 2;
+ __ptr = __first + __len;
+ } while (__comp(*__ptr, __t));
+
+ *__last = std::move(__t);
}
+ }
+}
+
+template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
+ using _CompRef = typename __comp_ref_type<_Compare>::type;
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first;
+ std::__sift_up<_AlgPolicy, _CompRef>(std::move(__first), std::move(__last), __comp, __len);
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
+ static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
+
+ std::__push_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
}
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::push_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
+ std::push_heap(std::move(__first), std::move(__last),
+ __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/ranges_adjacent_find.h
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
+#define _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __adjacent_find {
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
+ if (__first == __last)
+ return __first;
+
+ auto __i = __first;
+ while (++__i != __last) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first), std::invoke(__proj, *__i)))
+ return __first;
+ __first = __i;
+ }
+ return __i;
+ }
+
+ template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
+ return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <forward_range _Range,
+ class _Proj = identity,
+ indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>,
+ projected<iterator_t<_Range>, _Proj>> _Pred = ranges::equal_to>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {
+ return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+};
+} // namespace __adjacent_find
+
+inline namespace __cpo {
+ inline constexpr auto adjacent_find = __adjacent_find::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
lib/libcxx/include/__algorithm/ranges_all_of.h
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
+#define _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __all_of {
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ bool __all_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (!std::invoke(__pred, std::invoke(__proj, *__first)))
+ return false;
+ }
+ return true;
+ }
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
+ return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <input_range _Range, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
+ return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+};
+} // namespace __all_of
+
+inline namespace __cpo {
+ inline constexpr auto all_of = __all_of::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
lib/libcxx/include/__algorithm/ranges_any_of.h
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
+#define _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __any_of {
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ bool __any_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first)))
+ return true;
+ }
+ return false;
+ }
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
+ return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <input_range _Range, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
+ return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+};
+} // namespace __any_of
+
+inline namespace __cpo {
+ inline constexpr auto any_of = __any_of::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
lib/libcxx/include/__algorithm/ranges_binary_search.h
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
+#define _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/lower_bound.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __binary_search {
+struct __fn {
+ template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
+ indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
+ return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first));
+ }
+
+ template <forward_range _Range, class _Type, class _Proj = identity,
+ indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __first = ranges::begin(__r);
+ auto __last = ranges::end(__r);
+ auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
+ return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first));
+ }
+};
+} // namespace __binary_search
+
+inline namespace __cpo {
+ inline constexpr auto binary_search = __binary_search::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
lib/libcxx/include/__algorithm/ranges_copy.h
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_COPY_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/in_out_result.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/concepts.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using copy_result = in_out_result<_InIter, _OutIter>;
+
+namespace __copy {
+struct __fn {
+
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __r, _OutIter __result) const {
+ auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+};
+} // namespace __copy
+
+inline namespace __cpo {
+ inline constexpr auto copy = __copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COPY_H
lib/libcxx/include/__algorithm/ranges_copy_backward.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
+#define _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
+
+#include <__algorithm/copy_backward.h>
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template<class _Ip, class _Op>
+using copy_backward_result = in_out_result<_Ip, _Op>;
+
+namespace __copy_backward {
+struct __fn {
+
+ template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2>
+ requires indirectly_copyable<_InIter1, _InIter2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_backward_result<_InIter1, _InIter2> operator()(_InIter1 __first, _Sent1 __last, _InIter2 __result) const {
+ auto __ret = std::__copy_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <bidirectional_range _Range, bidirectional_iterator _Iter>
+ requires indirectly_copyable<iterator_t<_Range>, _Iter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __r, _Iter __result) const {
+ auto __ret = std::__copy_backward<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+};
+} // namespace __copy_backward
+
+inline namespace __cpo {
+ inline constexpr auto copy_backward = __copy_backward::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
lib/libcxx/include/__algorithm/ranges_copy_if.h
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
+#define _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
+
+#include <__algorithm/in_out_result.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template<class _Ip, class _Op>
+using copy_if_result = in_out_result<_Ip, _Op>;
+
+namespace __copy_if {
+struct __fn {
+
+ template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI static constexpr
+ copy_if_result <_InIter, _OutIter>
+ __copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first))) {
+ *__result = *__first;
+ ++__result;
+ }
+ }
+ return {std::move(__first), std::move(__result)};
+ }
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ requires indirectly_copyable<_Iter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_if_result<_Iter, _OutIter>
+ operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ return __copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj);
+ }
+};
+} // namespace __copy_if
+
+inline namespace __cpo {
+ inline constexpr auto copy_if = __copy_if::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_copy_n.h
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_N_H
+#define _LIBCPP___ALGORITHM_RANGES_COPY_N_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/ranges_copy.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/unreachable_sentinel.h>
+#include <__iterator/wrap_iter.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template <class _Ip, class _Op>
+using copy_n_result = in_out_result<_Ip, _Op>;
+
+namespace __copy_n {
+struct __fn {
+
+ template <class _InIter, class _DiffType, class _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {
+ while (__n != 0) {
+ *__result = *__first;
+ ++__first;
+ ++__result;
+ --__n;
+ }
+ return {std::move(__first), std::move(__result)};
+ }
+
+ template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {
+ auto __ret = std::__copy(__first, __first + __n, __result);
+ return {__ret.first, __ret.second};
+ }
+
+ template <input_iterator _Ip, weakly_incrementable _Op>
+ requires indirectly_copyable<_Ip, _Op>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_n_result<_Ip, _Op> operator()(_Ip __first, iter_difference_t<_Ip> __n, _Op __result) const {
+ return __go(std::move(__first), __n, std::move(__result));
+ }
+};
+} // namespace __copy_n
+
+inline namespace __cpo {
+ inline constexpr auto copy_n = __copy_n::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COPY_N_H
lib/libcxx/include/__algorithm/ranges_count.h
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_H
+#define _LIBCPP___ALGORITHM_RANGES_COUNT_H
+
+#include <__algorithm/ranges_count_if.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __count {
+struct __fn {
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __e) { return __e == __value; };
+ return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <input_range _Range, class _Type, class _Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __e) { return __e == __value; };
+ return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
+ }
+};
+} // namespace __count
+
+inline namespace __cpo {
+ inline constexpr auto count = __count::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_H
lib/libcxx/include/__algorithm/ranges_count_if.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
+#define _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+template <class _Iter, class _Sent, class _Proj, class _Pred>
+_LIBCPP_HIDE_FROM_ABI constexpr
+iter_difference_t<_Iter> __count_if_impl(_Iter __first, _Sent __last,
+ _Pred& __pred, _Proj& __proj) {
+ iter_difference_t<_Iter> __counter(0);
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first)))
+ ++__counter;
+ }
+ return __counter;
+}
+
+namespace __count_if {
+struct __fn {
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {
+ return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <input_range _Range, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ range_difference_t<_Range> operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {
+ return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
+ }
+};
+} // namespace __count_if
+
+inline namespace __cpo {
+ inline constexpr auto count_if = __count_if::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
lib/libcxx/include/__algorithm/ranges_equal.h
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_EQUAL_H
+#define _LIBCPP___ALGORITHM_RANGES_EQUAL_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __equal {
+struct __fn {
+private:
+ template <class _Iter1, class _Sent1,
+ class _Iter2, class _Sent2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ bool __equal_impl(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2) {
+ while (__first1 != __last1 && __first2 != __last2) {
+ if (!std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))
+ return false;
+ ++__first1;
+ ++__first2;
+ }
+ return __first1 == __last1 && __first2 == __last2;
+ }
+
+public:
+
+ template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
+ input_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ if constexpr (sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>) {
+ if (__last1 - __first1 != __last2 - __first2)
+ return false;
+ }
+ return __equal_impl(std::move(__first1), std::move(__last1),
+ std::move(__first2), std::move(__last2),
+ __pred,
+ __proj1,
+ __proj2);
+ }
+
+ template <input_range _Range1,
+ input_range _Range2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range1&& __range1,
+ _Range2&& __range2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
+ if (ranges::distance(__range1) != ranges::distance(__range2))
+ return false;
+ }
+ return __equal_impl(ranges::begin(__range1), ranges::end(__range1),
+ ranges::begin(__range2), ranges::end(__range2),
+ __pred,
+ __proj1,
+ __proj2);
+ return false;
+ }
+};
+} // namespace __equal
+
+inline namespace __cpo {
+ inline constexpr auto equal = __equal::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_H
lib/libcxx/include/__algorithm/ranges_equal_range.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM __project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
+
+#include <__algorithm/equal_range.h>
+#include <__algorithm/iterator_operations.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__ranges/subrange.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __equal_range {
+
+struct __fn {
+ template <
+ forward_iterator _Iter,
+ sentinel_for<_Iter> _Sent,
+ class _Tp,
+ class _Proj = identity,
+ indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
+ operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__equal_range<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), __value, __comp, __proj);
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <
+ forward_range _Range,
+ class _Tp,
+ class _Proj = identity,
+ indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
+ operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__equal_range<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), __value, __comp, __proj);
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+};
+
+} // namespace __equal_range
+
+inline namespace __cpo {
+ inline constexpr auto equal_range = __equal_range::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
lib/libcxx/include/__algorithm/ranges_fill.h
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FILL_H
+#define _LIBCPP___ALGORITHM_RANGES_FILL_H
+
+#include <__algorithm/ranges_fill_n.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __fill {
+struct __fn {
+ template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const {
+ if constexpr(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) {
+ return ranges::fill_n(__first, __last - __first, __value);
+ } else {
+ for (; __first != __last; ++__first)
+ *__first = __value;
+ return __first;
+ }
+ }
+
+ template <class _Type, output_range<const _Type&> _Range>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __range, const _Type& __value) const {
+ return (*this)(ranges::begin(__range), ranges::end(__range), __value);
+ }
+};
+} // namespace __fill
+
+inline namespace __cpo {
+ inline constexpr auto fill = __fill::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FILL_H
lib/libcxx/include/__algorithm/ranges_fill_n.h
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FILL_N_H
+#define _LIBCPP___ALGORITHM_RANGES_FILL_N_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __fill_n {
+struct __fn {
+ template <class _Type, output_iterator<const _Type&> _Iter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const {
+ for (; __n != 0; --__n) {
+ *__first = __value;
+ ++__first;
+ }
+ return __first;
+ }
+};
+} // namespace __fill_n
+
+inline namespace __cpo {
+ inline constexpr auto fill_n = __fill_n::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FILL_N_H
lib/libcxx/include/__algorithm/ranges_find.h
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_H
+#define _LIBCPP___ALGORITHM_RANGES_FIND_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __find {
+struct __fn {
+ template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
+ return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <input_range _Rp, class _Tp, class _Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
+ return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
+ }
+};
+} // namespace __find
+
+inline namespace __cpo {
+ inline constexpr auto find = __find::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FIND_H
lib/libcxx/include/__algorithm/ranges_find_end.h
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_END_H
+#define _LIBCPP___ALGORITHM_RANGES_FIND_END_H
+
+#include <__algorithm/find_end.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/ranges_iterator_concept.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/subrange.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __find_end {
+struct __fn {
+ template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
+ forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__find_end_impl<_RangeAlgPolicy>(
+ __first1,
+ __last1,
+ __first2,
+ __last2,
+ __pred,
+ __proj1,
+ __proj2,
+ __iterator_concept<_Iter1>(),
+ __iterator_concept<_Iter2>());
+ return {__ret.first, __ret.second};
+ }
+
+ template <forward_range _Range1,
+ forward_range _Range2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
+ _Range2&& __range2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__find_end_impl<_RangeAlgPolicy>(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ __pred,
+ __proj1,
+ __proj2,
+ __iterator_concept<iterator_t<_Range1>>(),
+ __iterator_concept<iterator_t<_Range2>>());
+ return {__ret.first, __ret.second};
+ }
+};
+} // namespace __find_end
+
+inline namespace __cpo {
+ inline constexpr auto find_end = __find_end::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H
lib/libcxx/include/__algorithm/ranges_find_first_of.h
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
+#define _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __find_first_of {
+struct __fn {
+
+ template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter1 __find_first_of_impl(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2) {
+ for (; __first1 != __last1; ++__first1) {
+ for (auto __j = __first2; __j != __last2; ++__j) {
+ if (std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__j)))
+ return __first1;
+ }
+ }
+ return __first1;
+ }
+
+ template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
+ forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter1 operator()(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ return __find_first_of_impl(std::move(__first1), std::move(__last1),
+ std::move(__first2), std::move(__last2),
+ __pred,
+ __proj1,
+ __proj2);
+ }
+
+ template <input_range _Range1,
+ forward_range _Range2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range1> operator()(_Range1&& __range1,
+ _Range2&& __range2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ return __find_first_of_impl(ranges::begin(__range1), ranges::end(__range1),
+ ranges::begin(__range2), ranges::end(__range2),
+ __pred,
+ __proj1,
+ __proj2);
+ }
+
+};
+} // namespace __find_first_of
+
+inline namespace __cpo {
+ inline constexpr auto find_first_of = __find_first_of::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
lib/libcxx/include/__algorithm/ranges_find_if.h
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
+#define _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Ip, class _Sp, class _Pred, class _Proj>
+_LIBCPP_HIDE_FROM_ABI static constexpr
+_Ip __find_if_impl(_Ip __first, _Sp __last, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first)))
+ break;
+ }
+ return __first;
+}
+
+namespace __find_if {
+struct __fn {
+
+ template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
+ indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
+ return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <input_range _Rp, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
+ return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
+ }
+};
+} // namespace __find_if
+
+inline namespace __cpo {
+ inline constexpr auto find_if = __find_if::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
lib/libcxx/include/__algorithm/ranges_find_if_not.h
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
+#define _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __find_if_not {
+struct __fn {
+ template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
+ indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
+ auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
+ return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);
+ }
+
+ template <input_range _Rp, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
+ auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
+ return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
+ }
+};
+} // namespace __find_if_not
+
+inline namespace __cpo {
+ inline constexpr auto find_if_not = __find_if_not::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
lib/libcxx/include/__algorithm/ranges_for_each.h
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
+#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
+
+#include <__algorithm/in_fun_result.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Iter, class _Func>
+using for_each_result = in_fun_result<_Iter, _Func>;
+
+namespace __for_each {
+struct __fn {
+private:
+ template <class _Iter, class _Sent, class _Proj, class _Func>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ for_each_result<_Iter, _Func> __for_each_impl(_Iter __first, _Sent __last, _Func& __func, _Proj& __proj) {
+ for (; __first != __last; ++__first)
+ std::invoke(__func, std::invoke(__proj, *__first));
+ return {std::move(__first), std::move(__func)};
+ }
+
+public:
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirectly_unary_invocable<projected<_Iter, _Proj>> _Func>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ for_each_result<_Iter, _Func> operator()(_Iter __first, _Sent __last, _Func __func, _Proj __proj = {}) const {
+ return __for_each_impl(std::move(__first), std::move(__last), __func, __proj);
+ }
+
+ template <input_range _Range,
+ class _Proj = identity,
+ indirectly_unary_invocable<projected<iterator_t<_Range>, _Proj>> _Func>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ for_each_result<borrowed_iterator_t<_Range>, _Func> operator()(_Range&& __range,
+ _Func __func,
+ _Proj __proj = {}) const {
+ return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj);
+ }
+
+};
+} // namespace __for_each
+
+inline namespace __cpo {
+ inline constexpr auto for_each = __for_each::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
lib/libcxx/include/__algorithm/ranges_for_each_n.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
+#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
+
+#include <__algorithm/in_fun_result.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Iter, class _Func>
+using for_each_n_result = in_fun_result<_Iter, _Func>;
+
+namespace __for_each_n {
+struct __fn {
+
+ template <input_iterator _Iter,
+ class _Proj = identity,
+ indirectly_unary_invocable<projected<_Iter, _Proj>> _Func>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ for_each_n_result<_Iter, _Func> operator()(_Iter __first,
+ iter_difference_t<_Iter> __count,
+ _Func __func,
+ _Proj __proj = {}) const {
+ while (__count-- > 0) {
+ std::invoke(__func, std::invoke(__proj, *__first));
+ ++__first;
+ }
+ return {std::move(__first), std::move(__func)};
+ }
+
+};
+} // namespace __for_each_n
+
+inline namespace __cpo {
+ inline constexpr auto for_each_n = __for_each_n::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
lib/libcxx/include/__algorithm/ranges_generate.h
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_H
+#define _LIBCPP___ALGORITHM_RANGES_GENERATE_H
+
+#include <__concepts/constructible.h>
+#include <__concepts/invocable.h>
+#include <__config>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __generate {
+
+struct __fn {
+
+ template <class _OutIter, class _Sent, class _Func>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) {
+ for (; __first != __last; ++__first) {
+ *__first = __gen();
+ }
+
+ return __first;
+ }
+
+ template <input_or_output_iterator _OutIter, sentinel_for<_OutIter> _Sent, copy_constructible _Func>
+ requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _OutIter operator()(_OutIter __first, _Sent __last, _Func __gen) const {
+ return __generate_fn_impl(std::move(__first), std::move(__last), __gen);
+ }
+
+ template <class _Range, copy_constructible _Func>
+ requires invocable<_Func&> && output_range<_Range, invoke_result_t<_Func&>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __range, _Func __gen) const {
+ return __generate_fn_impl(ranges::begin(__range), ranges::end(__range), __gen);
+ }
+
+};
+
+} // namespace __generate
+
+inline namespace __cpo {
+ inline constexpr auto generate = __generate::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H
lib/libcxx/include/__algorithm/ranges_generate_n.h
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
+#define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
+
+#include <__concepts/constructible.h>
+#include <__concepts/invocable.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __generate_n {
+
+struct __fn {
+
+ template <input_or_output_iterator _OutIter, copy_constructible _Func>
+ requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _OutIter operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const {
+ for (; __n > 0; --__n) {
+ *__first = __gen();
+ ++__first;
+ }
+
+ return __first;
+ }
+
+};
+
+} // namespace __generate_n
+
+inline namespace __cpo {
+ inline constexpr auto generate_n = __generate_n::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
lib/libcxx/include/__algorithm/ranges_includes.h
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
+#define _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
+
+#include <__algorithm/includes.h>
+#include <__algorithm/make_projected.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __includes {
+
+struct __fn {
+ template <
+ input_iterator _Iter1,
+ sentinel_for<_Iter1> _Sent1,
+ input_iterator _Iter2,
+ sentinel_for<_Iter2> _Sent2,
+ class _Proj1 = identity,
+ class _Proj2 = identity,
+ indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+ _Iter1 __first1,
+ _Sent1 __last1,
+ _Iter2 __first2,
+ _Sent2 __last2,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ return std::__includes(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__comp),
+ std::move(__proj1),
+ std::move(__proj2));
+ }
+
+ template <
+ input_range _Range1,
+ input_range _Range2,
+ class _Proj1 = identity,
+ class _Proj2 = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
+ _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+ _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ return std::__includes(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ std::move(__comp),
+ std::move(__proj1),
+ std::move(__proj2));
+ }
+};
+
+} // namespace __includes
+
+inline namespace __cpo {
+ inline constexpr auto includes = __includes::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
lib/libcxx/include/__algorithm/ranges_inplace_merge.h
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
+#define _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
+
+#include <__algorithm/inplace_merge.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __inplace_merge {
+
+ struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {
+ auto __last_iter = ranges::next(__middle, __last);
+ std::__inplace_merge<_RangeAlgPolicy>(
+ std::move(__first), std::move(__middle), __last_iter, std::__make_projected(__comp, __proj));
+ return __last_iter;
+ }
+
+ template <
+ bidirectional_iterator _Iter,
+ sentinel_for<_Iter> _Sent,
+ class _Comp = ranges::less,
+ class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI _Iter
+ operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __inplace_merge_impl(
+ std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj));
+ }
+
+ template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<
+ iterator_t<_Range>,
+ _Comp,
+ _Proj> _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range>
+ operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __inplace_merge_impl(
+ ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj));
+ }
+ };
+
+} // namespace __inplace_merge
+
+inline namespace __cpo {
+ inline constexpr auto inplace_merge = __inplace_merge::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
lib/libcxx/include/__algorithm/ranges_is_heap.h
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
+#define _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
+
+#include <__algorithm/is_heap_until.h>
+#include <__algorithm/make_projected.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __is_heap {
+
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Comp>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ static bool __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+
+ auto __result = std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
+ return __result == __last;
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
+ }
+};
+
+} // namespace __is_heap
+
+inline namespace __cpo {
+ inline constexpr auto is_heap = __is_heap::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
lib/libcxx/include/__algorithm/ranges_is_heap_until.h
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
+#define _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
+
+#include <__algorithm/is_heap_until.h>
+#include <__algorithm/make_projected.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __is_heap_until {
+
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Comp>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ static _Iter __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+
+ return std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
+ }
+
+};
+
+} // namespace __is_heap_until
+
+inline namespace __cpo {
+ inline constexpr auto is_heap_until = __is_heap_until::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
lib/libcxx/include/__algorithm/ranges_is_partitioned.h
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
+#define _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __is_partitioned {
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ bool __is_parititioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (!std::invoke(__pred, std::invoke(__proj, *__first)))
+ break;
+ }
+
+ if (__first == __last)
+ return true;
+ ++__first;
+
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first)))
+ return false;
+ }
+
+ return true;
+ }
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
+ return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <input_range _Range,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
+ return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+};
+} // namespace __is_partitioned
+
+inline namespace __cpo {
+ inline constexpr auto is_partitioned = __is_partitioned::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
lib/libcxx/include/__algorithm/ranges_is_sorted.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
+#define _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
+
+#include <__algorithm/ranges_is_sorted_until.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __is_sorted {
+struct __fn {
+ template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last;
+ }
+
+ template <forward_range _Range,
+ class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __last = ranges::end(__range);
+ return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;
+ }
+};
+} // namespace __is_sorted
+
+inline namespace __cpo {
+ inline constexpr auto is_sorted = __is_sorted::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
+#define _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Iter, class _Sent, class _Proj, class _Comp>
+_LIBCPP_HIDE_FROM_ABI constexpr
+_Iter __is_sorted_until_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ if (__first == __last)
+ return __first;
+ auto __i = __first;
+ while (++__i != __last) {
+ if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first)))
+ return __i;
+ __first = __i;
+ }
+ return __i;
+}
+
+namespace __is_sorted_until {
+struct __fn {
+ template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <forward_range _Range,
+ class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
+ }
+};
+} // namespace __is_sorted_until
+
+inline namespace __cpo {
+ inline constexpr auto is_sorted_until = __is_sorted_until::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
lib/libcxx/include/__algorithm/ranges_iterator_concept.h
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
+#define _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _IterMaybeQualified>
+consteval auto __get_iterator_concept() {
+ using _Iter = __uncvref_t<_IterMaybeQualified>;
+
+ if constexpr (contiguous_iterator<_Iter>)
+ return contiguous_iterator_tag();
+ else if constexpr (random_access_iterator<_Iter>)
+ return random_access_iterator_tag();
+ else if constexpr (bidirectional_iterator<_Iter>)
+ return bidirectional_iterator_tag();
+ else if constexpr (forward_iterator<_Iter>)
+ return forward_iterator_tag();
+ else if constexpr (input_iterator<_Iter>)
+ return input_iterator_tag();
+}
+
+template <class _Iter>
+using __iterator_concept = decltype(__get_iterator_concept<_Iter>());
+
+} // namespace ranges
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
+#define _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __lexicographical_compare {
+struct __fn {
+
+ template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ bool __lexicographical_compare_impl(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Comp& __comp,
+ _Proj1& __proj1,
+ _Proj2& __proj2) {
+ while (__first2 != __last2) {
+ if (__first1 == __last1
+ || std::invoke(__comp, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))
+ return true;
+ if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1)))
+ return false;
+ ++__first1;
+ ++__first2;
+ }
+ return false;
+ }
+
+ template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
+ input_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
+ class _Proj1 = identity,
+ class _Proj2 = identity,
+ indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ return __lexicographical_compare_impl(std::move(__first1), std::move(__last1),
+ std::move(__first2), std::move(__last2),
+ __comp,
+ __proj1,
+ __proj2);
+ }
+
+ template <input_range _Range1,
+ input_range _Range2,
+ class _Proj1 = identity,
+ class _Proj2 = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>,
+ projected<iterator_t<_Range2>, _Proj2>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ return __lexicographical_compare_impl(ranges::begin(__range1), ranges::end(__range1),
+ ranges::begin(__range2), ranges::end(__range2),
+ __comp,
+ __proj1,
+ __proj2);
+ }
+
+};
+} // namespace __lexicographical_compare
+
+inline namespace __cpo {
+ inline constexpr auto lexicographical_compare = __lexicographical_compare::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
lib/libcxx/include/__algorithm/ranges_lower_bound.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
+#define _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/lower_bound.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+namespace __lower_bound {
+struct __fn {
+ template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
+ indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
+ return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
+ }
+
+ template <forward_range _Range, class _Type, class _Proj = identity,
+ indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r,
+ const _Type& __value,
+ _Comp __comp = {},
+ _Proj __proj = {}) const {
+ return std::__lower_bound_impl<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj);
+ }
+};
+} // namespace __lower_bound
+
+inline namespace __cpo {
+ inline constexpr auto lower_bound = __lower_bound::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
lib/libcxx/include/__algorithm/ranges_make_heap.h
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
+#define _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_heap.h>
+#include <__algorithm/make_projected.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __make_heap {
+
+struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+ std::__make_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
+
+ return __last_iter;
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __make_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __make_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ }
+};
+
+} // namespace __make_heap
+
+inline namespace __cpo {
+ inline constexpr auto make_heap = __make_heap::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
lib/libcxx/include/__algorithm/ranges_max.h
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MAX_H
+#define _LIBCPP___ALGORITHM_RANGES_MAX_H
+
+#include <__algorithm/ranges_min_element.h>
+#include <__assert>
+#include <__concepts/copyable.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __max {
+struct __fn {
+ template <class _Tp, class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
+ return std::invoke(__comp, std::invoke(__proj, __a), std::invoke(__proj, __b)) ? __b : __a;
+ }
+
+ template <copyable _Tp, class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
+ _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
+
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
+ return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj);
+ }
+
+ template <input_range _Rp, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
+ requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __first = ranges::begin(__r);
+ auto __last = ranges::end(__r);
+
+ _LIBCPP_ASSERT(__first != __last, "range must contain at least one element");
+
+ if constexpr (forward_range<_Rp>) {
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
+ return *ranges::__min_element_impl(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj);
+ } else {
+ range_value_t<_Rp> __result = *__first;
+ while (++__first != __last) {
+ if (std::invoke(__comp, std::invoke(__proj, __result), std::invoke(__proj, *__first)))
+ __result = *__first;
+ }
+ return __result;
+ }
+ }
+};
+} // namespace __max
+
+inline namespace __cpo {
+ inline constexpr auto max = __max::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MAX_H
lib/libcxx/include/__algorithm/ranges_max_element.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
+#define _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
+
+#include <__algorithm/ranges_min_element.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __max_element {
+struct __fn {
+ template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
+ indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
+ return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
+ }
+
+ template <forward_range _Rp, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
+ return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
+ }
+};
+} // namespace __max_element
+
+inline namespace __cpo {
+ inline constexpr auto max_element = __max_element::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_merge.h
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MERGE_H
+#define _LIBCPP___ALGORITHM_RANGES_MERGE_H
+
+#include <__algorithm/in_in_out_result.h>
+#include <__algorithm/ranges_copy.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/mergeable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter1, class _InIter2, class _OutIter>
+using merge_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
+
+namespace __merge {
+
+template <
+ class _InIter1,
+ class _Sent1,
+ class _InIter2,
+ class _Sent2,
+ class _OutIter,
+ class _Comp,
+ class _Proj1,
+ class _Proj2>
+_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__uncvref_t<_InIter1>, __uncvref_t<_InIter2>, __uncvref_t<_OutIter>>
+__merge_impl(
+ _InIter1&& __first1,
+ _Sent1&& __last1,
+ _InIter2&& __first2,
+ _Sent2&& __last2,
+ _OutIter&& __result,
+ _Comp&& __comp,
+ _Proj1&& __proj1,
+ _Proj2&& __proj2) {
+ for (; __first1 != __last1 && __first2 != __last2; ++__result) {
+ if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) {
+ *__result = *__first2;
+ ++__first2;
+ } else {
+ *__result = *__first1;
+ ++__first1;
+ }
+ }
+ auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result));
+ auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out));
+ return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)};
+}
+
+struct __fn {
+ template <
+ input_iterator _InIter1,
+ sentinel_for<_InIter1> _Sent1,
+ input_iterator _InIter2,
+ sentinel_for<_InIter2> _Sent2,
+ weakly_incrementable _OutIter,
+ class _Comp = less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr merge_result<_InIter1, _InIter2, _OutIter> operator()(
+ _InIter1 __first1,
+ _Sent1 __last1,
+ _InIter2 __first2,
+ _Sent2 __last2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ return __merge::__merge_impl(__first1, __last1, __first2, __last2, __result, __comp, __proj1, __proj2);
+ }
+
+ template <
+ input_range _Range1,
+ input_range _Range2,
+ weakly_incrementable _OutIter,
+ class _Comp = less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<
+ iterator_t<_Range1>,
+ iterator_t<_Range2>,
+ _OutIter,
+ _Comp,
+ _Proj1,
+ _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr merge_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter>
+ operator()(
+ _Range1&& __range1,
+ _Range2&& __range2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ return __merge::__merge_impl(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ __result,
+ __comp,
+ __proj1,
+ __proj2);
+ }
+};
+
+} // namespace __merge
+
+inline namespace __cpo {
+ inline constexpr auto merge = __merge::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MERGE_H
lib/libcxx/include/__algorithm/ranges_min.h
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MIN_H
+#define _LIBCPP___ALGORITHM_RANGES_MIN_H
+
+#include <__algorithm/ranges_min_element.h>
+#include <__assert>
+#include <__concepts/copyable.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __min {
+struct __fn {
+ template <class _Tp, class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
+ return std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)) ? __b : __a;
+ }
+
+ template <copyable _Tp, class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
+ _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
+ return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);
+ }
+
+ template <input_range _Rp, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
+ requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __first = ranges::begin(__r);
+ auto __last = ranges::end(__r);
+
+ _LIBCPP_ASSERT(__first != __last, "range must contain at least one element");
+
+ if constexpr (forward_range<_Rp>) {
+ return *ranges::__min_element_impl(__first, __last, __comp, __proj);
+ } else {
+ range_value_t<_Rp> __result = *__first;
+ while (++__first != __last) {
+ if (std::invoke(__comp, std::invoke(__proj, *__first), std::invoke(__proj, __result)))
+ __result = *__first;
+ }
+ return __result;
+ }
+ }
+};
+} // namespace __min
+
+inline namespace __cpo {
+ inline constexpr auto min = __min::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MIN_H
lib/libcxx/include/__algorithm/ranges_min_element.h
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
+#define _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+// TODO(ranges): `ranges::min_element` can now simply delegate to `std::__min_element`.
+template <class _Ip, class _Sp, class _Proj, class _Comp>
+_LIBCPP_HIDE_FROM_ABI static constexpr
+_Ip __min_element_impl(_Ip __first, _Sp __last, _Comp& __comp, _Proj& __proj) {
+ if (__first == __last)
+ return __first;
+
+ _Ip __i = __first;
+ while (++__i != __last)
+ if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first)))
+ __first = __i;
+ return __first;
+}
+
+namespace __min_element {
+struct __fn {
+ template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
+ indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return ranges::__min_element_impl(__first, __last, __comp, __proj);
+ }
+
+ template <forward_range _Rp, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ }
+};
+} // namespace __min_element
+
+inline namespace __cpo {
+ inline constexpr auto min_element = __min_element::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_minmax.h
@@ -0,0 +1,133 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MINMAX_H
+#define _LIBCPP___ALGORITHM_RANGES_MINMAX_H
+
+#include <__algorithm/min_max_result.h>
+#include <__algorithm/minmax_element.h>
+#include <__assert>
+#include <__concepts/copyable.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+template <class _T1>
+using minmax_result = min_max_result<_T1>;
+
+namespace __minmax {
+struct __fn {
+ template <class _Type, class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
+ operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const {
+ if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)))
+ return {__b, __a};
+ return {__a, __b};
+ }
+
+ template <copyable _Type, class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
+ _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element");
+ auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);
+ return ranges::minmax_result<_Type> { *__iters.first, *__iters.second };
+ }
+
+ template <input_range _Range, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ ranges::minmax_result<range_value_t<_Range>> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __first = ranges::begin(__r);
+ auto __last = ranges::end(__r);
+ using _ValueT = range_value_t<_Range>;
+
+ _LIBCPP_ASSERT(__first != __last, "range has to contain at least one element");
+
+ if constexpr (forward_range<_Range>) {
+ auto __result = std::__minmax_element_impl(__first, __last, __comp, __proj);
+ return {*__result.first, *__result.second};
+ } else {
+ // input_iterators can't be copied, so the implementation for input_iterators has to store
+ // the values instead of a pointer to the correct values
+ auto __less = [&](auto&& __a, auto&& __b) -> bool {
+ return std::invoke(__comp, std::invoke(__proj, std::forward<decltype(__a)>(__a)),
+ std::invoke(__proj, std::forward<decltype(__b)>(__b)));
+ };
+
+ ranges::minmax_result<_ValueT> __result = {*__first, __result.min};
+ if (__first == __last || ++__first == __last)
+ return __result;
+
+ if (__less(*__first, __result.min))
+ __result.min = *__first;
+ else
+ __result.max = *__first;
+
+ while (++__first != __last) {
+ _ValueT __i = *__first;
+ if (++__first == __last) {
+ if (__less(__i, __result.min))
+ __result.min = __i;
+ else if (!__less(__i, __result.max))
+ __result.max = __i;
+ return __result;
+ }
+
+ if (__less(*__first, __i)) {
+ if (__less(*__first, __result.min))
+ __result.min = *__first;
+ if (!__less(__i, __result.max))
+ __result.max = std::move(__i);
+ } else {
+ if (__less(__i, __result.min))
+ __result.min = std::move(__i);
+ if (!__less(*__first, __result.max))
+ __result.max = *__first;
+ }
+ }
+ return __result;
+ }
+ }
+};
+} // namespace __minmax
+
+inline namespace __cpo {
+ inline constexpr auto minmax = __minmax::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
lib/libcxx/include/__algorithm/ranges_minmax_element.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MINMAX_ELEMENT_H
+#define _LIBCPP___ALGORITHM_RANGES_MINMAX_ELEMENT_H
+
+#include <__algorithm/min_max_result.h>
+#include <__algorithm/minmax_element.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _T1>
+using minmax_element_result = min_max_result<_T1>;
+
+namespace __minmax_element {
+struct __fn {
+ template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
+ indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj);
+ return {__ret.first, __ret.second};
+ }
+
+ template <forward_range _Rp, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ ranges::minmax_element_result<borrowed_iterator_t<_Rp>>
+ operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ return {__ret.first, __ret.second};
+ }
+};
+} // namespace __minmax_element
+
+inline namespace __cpo {
+ inline constexpr auto minmax_element = __minmax_element::__fn{};
+} // namespace __cpo
+
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
lib/libcxx/include/__algorithm/ranges_mismatch.h
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MISMATCH_H
+#define _LIBCPP___ALGORITHM_RANGES_MISMATCH_H
+
+#include <__algorithm/in_in_result.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template <class _I1, class _I2>
+using mismatch_result = in_in_result<_I1, _I2>;
+
+namespace __mismatch {
+struct __fn {
+ template <class _I1, class _S1, class _I2, class _S2,
+ class _Pred, class _Proj1, class _Proj2>
+ static _LIBCPP_HIDE_FROM_ABI constexpr
+ mismatch_result<_I1, _I2>
+ __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2,
+ _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
+ while (__first1 != __last1 && __first2 != __last2) {
+ if (!std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))
+ break;
+ ++__first1;
+ ++__first2;
+ }
+ return {std::move(__first1), std::move(__first2)};
+ }
+
+ template <input_iterator _I1, sentinel_for<_I1> _S1,
+ input_iterator _I2, sentinel_for<_I2> _S2,
+ class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
+ requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ mismatch_result<_I1, _I2> operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2,
+ _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);
+ }
+
+ template <input_range _R1, input_range _R2,
+ class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
+ requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
+ operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ return __go(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2),
+ __pred, __proj1, __proj2);
+ }
+};
+} // namespace __mismatch
+
+inline namespace __cpo {
+ constexpr inline auto mismatch = __mismatch::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MISMATCH_H
lib/libcxx/include/__algorithm/ranges_move.h
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MOVE_H
+#define _LIBCPP___ALGORITHM_RANGES_MOVE_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/move.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_move.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using move_result = in_out_result<_InIter, _OutIter>;
+
+namespace __move {
+struct __fn {
+
+ template <class _InIter, class _Sent, class _OutIter>
+ requires __iter_move::__move_deref<_InIter> // check that we are allowed to std::move() the value
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
+ auto __ret = std::__move(std::move(__first), std::move(__last), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <class _InIter, class _Sent, class _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
+ while (__first != __last) {
+ *__result = ranges::iter_move(__first);
+ ++__first;
+ ++__result;
+ }
+ return {std::move(__first), std::move(__result)};
+ }
+
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
+ requires indirectly_movable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ return __move_impl(std::move(__first), std::move(__last), std::move(__result));
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter>
+ requires indirectly_movable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, _OutIter __result) const {
+ return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
+ }
+
+};
+} // namespace __move
+
+inline namespace __cpo {
+ inline constexpr auto move = __move::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H
lib/libcxx/include/__algorithm/ranges_move_backward.h
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
+#define _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/ranges_move.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/next.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using move_backward_result = in_out_result<_InIter, _OutIter>;
+
+namespace __move_backward {
+struct __fn {
+
+ template <class _InIter, class _Sent, class _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {
+ auto __ret = ranges::move(std::make_reverse_iterator(ranges::next(__first, __last)),
+ std::make_reverse_iterator(__first),
+ std::make_reverse_iterator(__result));
+ return {std::move(__ret.in.base()), std::move(__ret.out.base())};
+ }
+
+ template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter>
+ requires indirectly_movable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_backward_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ return __move_backward_impl(std::move(__first), std::move(__last), std::move(__result));
+ }
+
+ template <bidirectional_range _Range, bidirectional_iterator _Iter>
+ requires indirectly_movable<iterator_t<_Range>, _Iter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __range, _Iter __result) const {
+ return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
+ }
+
+};
+} // namespace __move_backward
+
+inline namespace __cpo {
+ inline constexpr auto move_backward = __move_backward::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
lib/libcxx/include/__algorithm/ranges_none_of.h
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
+#define _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __none_of {
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ bool __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first)))
+ return false;
+ }
+ return true;
+ }
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
+ return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <input_range _Range, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
+ return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+};
+} // namespace __none_of
+
+inline namespace __cpo {
+ inline constexpr auto none_of = __none_of::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
lib/libcxx/include/__algorithm/ranges_nth_element.h
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
+#define _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/nth_element.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __nth_element {
+
+struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+ std::__nth_element_impl<_RangeAlgPolicy>(std::move(__first), std::move(__nth), __last_iter, __projected_comp);
+
+ return __last_iter;
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Iter __nth, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __nth_element_fn_impl(std::move(__first), std::move(__nth), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r, iterator_t<_Range> __nth, _Comp __comp = {},
+ _Proj __proj = {}) const {
+ return __nth_element_fn_impl(ranges::begin(__r), std::move(__nth), ranges::end(__r), __comp, __proj);
+ }
+};
+
+} // namespace __nth_element
+
+inline namespace __cpo {
+ inline constexpr auto nth_element = __nth_element::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_partial_sort.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
+#define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/partial_sort.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __partial_sort {
+
+struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+ return std::__partial_sort<_RangeAlgPolicy>(std::move(__first), std::move(__middle), __last, __projected_comp);
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __partial_sort_fn_impl(std::move(__first), std::move(__middle), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r, iterator_t<_Range> __middle, _Comp __comp = {},
+ _Proj __proj = {}) const {
+ return __partial_sort_fn_impl(ranges::begin(__r), std::move(__middle), ranges::end(__r), __comp, __proj);
+ }
+};
+
+} // namespace __partial_sort
+
+inline namespace __cpo {
+ inline constexpr auto partial_sort = __partial_sort::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
lib/libcxx/include/__algorithm/ranges_partial_sort_copy.h
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/partial_sort_copy.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using partial_sort_copy_result = in_out_result<_InIter, _OutIter>;
+
+namespace __partial_sort_copy {
+
+struct __fn {
+
+ template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
+ random_access_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
+ class _Comp = ranges::less, class _Proj1 = identity, class _Proj2 = identity>
+ requires indirectly_copyable<_Iter1, _Iter2> && sortable<_Iter2, _Comp, _Proj2> &&
+ indirect_strict_weak_order<_Comp, projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ partial_sort_copy_result<_Iter1, _Iter2>
+ operator()(_Iter1 __first, _Sent1 __last, _Iter2 __result_first, _Sent2 __result_last,
+ _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__result_first), std::move(__result_last),
+ __comp, __proj1, __proj2
+ );
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+ template <input_range _Range1, random_access_range _Range2, class _Comp = ranges::less,
+ class _Proj1 = identity, class _Proj2 = identity>
+ requires indirectly_copyable<iterator_t<_Range1>, iterator_t<_Range2>> &&
+ sortable<iterator_t<_Range2>, _Comp, _Proj2> &&
+ indirect_strict_weak_order<_Comp, projected<iterator_t<_Range1>, _Proj1>,
+ projected<iterator_t<_Range2>, _Proj2>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ partial_sort_copy_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>>
+ operator()(_Range1&& __range, _Range2&& __result_range, _Comp __comp = {},
+ _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), ranges::begin(__result_range), ranges::end(__result_range),
+ __comp, __proj1, __proj2
+ );
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+};
+
+} // namespace __partial_sort_copy
+
+inline namespace __cpo {
+ inline constexpr auto partial_sort_copy = __partial_sort_copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
lib/libcxx/include/__algorithm/ranges_partition.h
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_PARTITION_H
+#define _LIBCPP___ALGORITHM_RANGES_PARTITION_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/partition.h>
+#include <__algorithm/ranges_iterator_concept.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/permutable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/subrange.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __partition {
+
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI static constexpr
+ subrange<__uncvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
+ auto&& __projected_pred = std::__make_projected(__pred, __proj);
+ auto __result = std::__partition<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>());
+
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+ template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
+ return __partition_fn_impl(__first, __last, __pred, __proj);
+ }
+
+ template <forward_range _Range, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
+ return __partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+
+};
+
+} // namespace __partition
+
+inline namespace __cpo {
+ inline constexpr auto partition = __partition::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_H
lib/libcxx/include/__algorithm/ranges_partition_copy.h
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
+
+#include <__algorithm/in_out_out_result.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter1, class _OutIter2>
+using partition_copy_result = in_out_out_result<_InIter, _OutIter1, _OutIter2>;
+
+namespace __partition_copy {
+
+struct __fn {
+
+ // TODO(ranges): delegate to the classic algorithm.
+ template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ static partition_copy_result<
+ __uncvref_t<_InIter>, __uncvref_t<_OutIter1>, __uncvref_t<_OutIter2>
+ > __partition_copy_fn_impl( _InIter&& __first, _Sent&& __last, _OutIter1&& __out_true, _OutIter2&& __out_false,
+ _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first))) {
+ *__out_true = *__first;
+ ++__out_true;
+
+ } else {
+ *__out_false = *__first;
+ ++__out_false;
+ }
+ }
+
+ return {std::move(__first), std::move(__out_true), std::move(__out_false)};
+ }
+
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter1, weakly_incrementable _OutIter2,
+ class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
+ requires indirectly_copyable<_InIter, _OutIter1> && indirectly_copyable<_InIter, _OutIter2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ partition_copy_result<_InIter, _OutIter1, _OutIter2>
+ operator()(_InIter __first, _Sent __last, _OutIter1 __out_true, _OutIter2 __out_false,
+ _Pred __pred, _Proj __proj = {}) const {
+ return __partition_copy_fn_impl(
+ std::move(__first), std::move(__last), std::move(__out_true), std::move(__out_false), __pred, __proj);
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter1, weakly_incrementable _OutIter2,
+ class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter1> && indirectly_copyable<iterator_t<_Range>, _OutIter2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ partition_copy_result<borrowed_iterator_t<_Range>, _OutIter1, _OutIter2>
+ operator()(_Range&& __range, _OutIter1 __out_true, _OutIter2 __out_false, _Pred __pred, _Proj __proj = {}) const {
+ return __partition_copy_fn_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__out_true), std::move(__out_false), __pred, __proj);
+ }
+
+};
+
+} // namespace __partition_copy
+
+inline namespace __cpo {
+ inline constexpr auto partition_copy = __partition_copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
lib/libcxx/include/__algorithm/ranges_partition_point.h
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H
+#define _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H
+
+#include <__algorithm/half_positive.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __partition_point {
+
+struct __fn {
+
+ // TODO(ranges): delegate to the classic algorithm.
+ template <class _Iter, class _Sent, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ static _Iter __partition_point_fn_impl(_Iter&& __first, _Sent&& __last, _Pred& __pred, _Proj& __proj) {
+ auto __len = ranges::distance(__first, __last);
+
+ while (__len != 0) {
+ auto __half_len = std::__half_positive(__len);
+ auto __mid = ranges::next(__first, __half_len);
+
+ if (std::invoke(__pred, std::invoke(__proj, *__mid))) {
+ __first = ++__mid;
+ __len -= __half_len + 1;
+
+ } else {
+ __len = __half_len;
+ }
+ }
+
+ return __first;
+ }
+
+ template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
+ return __partition_point_fn_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <forward_range _Range, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
+ return __partition_point_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+
+};
+
+} // namespace __partition_point
+
+inline namespace __cpo {
+ inline constexpr auto partition_point = __partition_point::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H
lib/libcxx/include/__algorithm/ranges_pop_heap.h
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
+#define _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/pop_heap.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __pop_heap {
+
+struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter __pop_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+ auto __len = __last_iter - __first;
+
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+ std::__pop_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp, __len);
+
+ return __last_iter;
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __pop_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __pop_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ }
+};
+
+} // namespace __pop_heap
+
+inline namespace __cpo {
+ inline constexpr auto pop_heap = __pop_heap::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
lib/libcxx/include/__algorithm/ranges_push_heap.h
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
+#define _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/push_heap.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __push_heap {
+
+struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+ std::__push_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
+
+ return __last_iter;
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __push_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __push_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ }
+};
+
+} // namespace __push_heap
+
+inline namespace __cpo {
+ inline constexpr auto push_heap = __push_heap::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
lib/libcxx/include/__algorithm/ranges_remove.h
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_H
+#define _LIBCPP___ALGORITHM_RANGES_REMOVE_H
+#include <__config>
+
+#include <__algorithm/ranges_remove_if.h>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/permutable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/subrange.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __remove {
+struct __fn {
+
+ template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __other) { return __value == __other; };
+ return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <forward_range _Range, class _Type, class _Proj = identity>
+ requires permutable<iterator_t<_Range>>
+ && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __other) { return __value == __other; };
+ return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+};
+} // namespace __remove
+
+inline namespace __cpo {
+ inline constexpr auto remove = __remove::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_H
lib/libcxx/include/__algorithm/ranges_remove_copy.h
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/remove_copy.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using remove_copy_result = in_out_result<_InIter, _OutIter>;
+
+namespace __remove_copy {
+
+struct __fn {
+
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, class _Type,
+ class _Proj = identity>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ remove_copy_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
+ // TODO: implement
+ (void)__first; (void)__last; (void)__result; (void)__value; (void)__proj;
+ return {};
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ remove_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
+ // TODO: implement
+ (void)__range; (void)__result; (void)__value; (void)__proj;
+ return {};
+ }
+
+};
+
+} // namespace __remove_copy
+
+inline namespace __cpo {
+ inline constexpr auto remove_copy = __remove_copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
lib/libcxx/include/__algorithm/ranges_remove_copy_if.h
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
+#define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/remove_copy_if.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using remove_copy_if_result = in_out_result<_InIter, _OutIter>;
+
+namespace __remove_copy_if {
+
+struct __fn {
+
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter,
+ class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ remove_copy_if_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ // TODO: implement
+ (void)__first; (void)__last; (void)__result; (void)__pred; (void)__proj;
+ return {};
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ // TODO: implement
+ (void)__range; (void)__result; (void)__pred; (void)__proj;
+ return {};
+ }
+
+};
+
+} // namespace __remove_copy_if
+
+inline namespace __cpo {
+ inline constexpr auto remove_copy_if = __remove_copy_if::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_remove_if.h
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
+#define _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
+#include <__config>
+
+#include <__algorithm/ranges_find_if.h>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/permutable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/subrange.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Iter, class _Sent, class _Proj, class _Pred>
+_LIBCPP_HIDE_FROM_ABI constexpr
+subrange<_Iter> __remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
+ auto __new_end = ranges::__find_if_impl(__first, __last, __pred, __proj);
+ if (__new_end == __last)
+ return {__new_end, __new_end};
+
+ _Iter __i = __new_end;
+ while (++__i != __last) {
+ if (!std::invoke(__pred, std::invoke(__proj, *__i))) {
+ *__new_end = ranges::iter_move(__i);
+ ++__new_end;
+ }
+ }
+ return {__new_end, __i};
+}
+
+namespace __remove_if {
+struct __fn {
+
+ template <permutable _Iter, sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
+ return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
+ }
+
+ template <forward_range _Range,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
+ return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+
+};
+} // namespace __remove_if
+
+inline namespace __cpo {
+ inline constexpr auto remove_if = __remove_if::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
lib/libcxx/include/__algorithm/ranges_replace.h
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_H
+#define _LIBCPP___ALGORITHM_RANGES_REPLACE_H
+
+#include <__algorithm/ranges_replace_if.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __replace {
+struct __fn {
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Type1,
+ class _Type2,
+ class _Proj = identity>
+ requires indirectly_writable<_Iter, const _Type2&>
+ && indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type1*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last,
+ const _Type1& __old_value,
+ const _Type2& __new_value,
+ _Proj __proj = {}) const {
+ auto __pred = [&](const auto& __val) { return __val == __old_value; };
+ return ranges::__replace_if_impl(std::move(__first), std::move(__last), __pred, __new_value, __proj);
+ }
+
+ template <input_range _Range,
+ class _Type1,
+ class _Type2,
+ class _Proj = identity>
+ requires indirectly_writable<iterator_t<_Range>, const _Type2&>
+ && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*>
+ _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
+ operator()(_Range&& __range, const _Type1& __old_value, const _Type2& __new_value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __val) { return __val == __old_value; };
+ return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);
+ }
+
+};
+} // namespace __replace
+
+inline namespace __cpo {
+ inline constexpr auto replace = __replace::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_H
lib/libcxx/include/__algorithm/ranges_replace_copy.h
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/replace_copy.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using replace_copy_result = in_out_result<_InIter, _OutIter>;
+
+namespace __replace_copy {
+
+struct __fn {
+
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type1, class _Type2,
+ output_iterator<const _Type2&> _OutIter, class _Proj = identity>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type1*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ replace_copy_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value,
+ _Proj __proj = {}) const {
+ // TODO: implement
+ (void)__first; (void)__last; (void)__result; (void)__old_value; (void)__new_value; (void)__proj;
+ return {};
+ }
+
+ template <input_range _Range, class _Type1, class _Type2, output_iterator<const _Type2&> _OutIter,
+ class _Proj = identity>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ replace_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value,
+ _Proj __proj = {}) const {
+ // TODO: implement
+ (void)__range; (void)__result; (void)__old_value; (void)__new_value; (void)__proj;
+ return {};
+ }
+
+};
+
+} // namespace __replace_copy
+
+inline namespace __cpo {
+ inline constexpr auto replace_copy = __replace_copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
lib/libcxx/include/__algorithm/ranges_replace_copy_if.h
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
+#define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/replace_copy_if.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using replace_copy_if_result = in_out_result<_InIter, _OutIter>;
+
+namespace __replace_copy_if {
+
+struct __fn {
+
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type, output_iterator<const _Type&> _OutIter,
+ class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ replace_copy_if_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value,
+ _Proj __proj = {}) const {
+ // TODO: implement
+ (void)__first; (void)__last; (void)__result; (void)__pred; (void)__new_value; (void)__proj;
+ return {};
+ }
+
+ template <input_range _Range, class _Type, output_iterator<const _Type&> _OutIter, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
+ // TODO: implement
+ (void)__range; (void)__result; (void)__pred; (void)__new_value; (void)__proj;
+ return {};
+ }
+
+};
+
+} // namespace __replace_copy_if
+
+inline namespace __cpo {
+ inline constexpr auto replace_copy_if = __replace_copy_if::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_replace_if.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H
+#define _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Iter, class _Sent, class _Type, class _Proj, class _Pred>
+_LIBCPP_HIDE_FROM_ABI constexpr
+_Iter __replace_if_impl(_Iter __first, _Sent __last, _Pred& __pred, const _Type& __new_value, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first)))
+ *__first = __new_value;
+ }
+ return __first;
+}
+
+namespace __replace_if {
+struct __fn {
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Type,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ requires indirectly_writable<_Iter, const _Type&>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
+ return ranges::__replace_if_impl(std::move(__first), std::move(__last), __pred, __new_value, __proj);
+ }
+
+ template <input_range _Range,
+ class _Type,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_writable<iterator_t<_Range>, const _Type&>
+ _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
+ operator()(_Range&& __range, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
+ return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);
+ }
+
+};
+} // namespace __replace_if
+
+inline namespace __cpo {
+ inline constexpr auto replace_if = __replace_if::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H
lib/libcxx/include/__algorithm/ranges_reverse.h
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REVERSE_H
+#define _LIBCPP___ALGORITHM_RANGES_REVERSE_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/next.h>
+#include <__iterator/permutable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __reverse {
+struct __fn {
+
+ template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent>
+ requires permutable<_Iter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last) const {
+ if constexpr (random_access_iterator<_Iter>) {
+ if (__first == __last)
+ return __first;
+
+ auto __end = ranges::next(__first, __last);
+ auto __ret = __end;
+
+ while (__first < --__end) {
+ ranges::iter_swap(__first, __end);
+ ++__first;
+ }
+ return __ret;
+ } else {
+ auto __end = ranges::next(__first, __last);
+ auto __ret = __end;
+
+ while (__first != __end) {
+ if (__first == --__end)
+ break;
+
+ ranges::iter_swap(__first, __end);
+ ++__first;
+ }
+ return __ret;
+ }
+ }
+
+ template <bidirectional_range _Range>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __range) const {
+ return (*this)(ranges::begin(__range), ranges::end(__range));
+ }
+
+};
+} // namespace __reverse
+
+inline namespace __cpo {
+ inline constexpr auto reverse = __reverse::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_H
lib/libcxx/include/__algorithm/ranges_reverse_copy.h
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/ranges_copy.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/next.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__ranges/subrange.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using reverse_copy_result = in_out_result<_InIter, _OutIter>;
+
+namespace __reverse_copy {
+struct __fn {
+
+ template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ reverse_copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ return (*this)(subrange(std::move(__first), std::move(__last)), std::move(__result));
+ }
+
+ template <bidirectional_range _Range, weakly_incrementable _OutIter>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ reverse_copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, _OutIter __result) const {
+ auto __ret = ranges::copy(std::__reverse_range(__range), std::move(__result));
+ return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)};
+ }
+
+};
+} // namespace __reverse_copy
+
+inline namespace __cpo {
+ inline constexpr auto reverse_copy = __reverse_copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
lib/libcxx/include/__algorithm/ranges_rotate_copy.h
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/ranges_copy.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using rotate_copy_result = in_out_result<_InIter, _OutIter>;
+
+namespace __rotate_copy {
+struct __fn {
+
+ template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ rotate_copy_result<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __middle, _Sent __last, _OutIter __result) const {
+ auto __res1 = ranges::copy(__middle, __last, std::move(__result));
+ auto __res2 = ranges::copy(__first, __middle, std::move(__res1.out));
+ return {std::move(__res1.in), std::move(__res2.out)};
+ }
+
+ template <bidirectional_range _Range, weakly_incrementable _OutIter>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ rotate_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, iterator_t<_Range> __middle, _OutIter __result) const {
+ return (*this)(ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__result));
+ }
+
+};
+} // namespace __rotate_copy
+
+inline namespace __cpo {
+ inline constexpr auto rotate_copy = __rotate_copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
lib/libcxx/include/__algorithm/ranges_search.h
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SEARCH_H
+#define _LIBCPP___ALGORITHM_RANGES_SEARCH_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/search.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/size.h>
+#include <__ranges/subrange.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __search {
+struct __fn {
+ template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
+ _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_impl(
+ _Iter1 __first1,
+ _Sent1 __last1,
+ _Iter2 __first2,
+ _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2) {
+ if constexpr (sized_sentinel_for<_Sent2, _Iter2>) {
+ auto __size2 = ranges::distance(__first2, __last2);
+ if (__size2 == 0)
+ return {__first1, __first1};
+
+ if constexpr (sized_sentinel_for<_Sent1, _Iter1>) {
+ auto __size1 = ranges::distance(__first1, __last1);
+ if (__size1 < __size2) {
+ ranges::advance(__first1, __last1);
+ return {__first1, __first1};
+ }
+
+ if constexpr (random_access_iterator<_Iter1> && random_access_iterator<_Iter2>) {
+ auto __ret = std::__search_random_access_impl<_RangeAlgPolicy>(
+ __first1, __last1, __first2, __last2, __pred, __proj1, __proj2, __size1, __size2);
+ return {__ret.first, __ret.second};
+ }
+ }
+ }
+
+ auto __ret =
+ std::__search_forward_impl<_RangeAlgPolicy>(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);
+ return {__ret.first, __ret.second};
+ }
+
+ template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
+ forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ return __ranges_search_impl(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);
+ }
+
+ template <forward_range _Range1,
+ forward_range _Range2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
+ _Range2&& __range2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __first1 = ranges::begin(__range1);
+ if constexpr (sized_range<_Range2>) {
+ auto __size2 = ranges::size(__range2);
+ if (__size2 == 0)
+ return {__first1, __first1};
+ if constexpr (sized_range<_Range1>) {
+ auto __size1 = ranges::size(__range1);
+ if (__size1 < __size2) {
+ ranges::advance(__first1, ranges::end(__range1));
+ return {__first1, __first1};
+ }
+ }
+ }
+
+ return __ranges_search_impl(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ __pred,
+ __proj1,
+ __proj2);
+ }
+
+};
+} // namespace __search
+
+inline namespace __cpo {
+ inline constexpr auto search = __search::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_H
lib/libcxx/include/__algorithm/ranges_search_n.h
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
+#define _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/search_n.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/size.h>
+#include <__ranges/subrange.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __search_n {
+struct __fn {
+
+ template <class _Iter1, class _Sent1, class _SizeT, class _Type, class _Pred, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_n_impl(
+ _Iter1 __first, _Sent1 __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {
+ if (__count == 0)
+ return {__first, __first};
+
+ if constexpr (sized_sentinel_for<_Sent1, _Iter1>) {
+ auto __size = ranges::distance(__first, __last);
+ if (__size < __count) {
+ ranges::advance(__first, __last);
+ return {__first, __first};
+ }
+
+ if constexpr (random_access_iterator<_Iter1>) {
+ auto __ret = __search_n_random_access_impl<_RangeAlgPolicy>(__first, __last,
+ __count,
+ __value,
+ __pred,
+ __proj,
+ __size);
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+ }
+
+ auto __ret = std::__search_n_forward_impl<_RangeAlgPolicy>(__first, __last,
+ __count,
+ __value,
+ __pred,
+ __proj);
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Type,
+ class _Pred = ranges::equal_to,
+ class _Proj = identity>
+ requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ subrange<_Iter> operator()(_Iter __first, _Sent __last,
+ iter_difference_t<_Iter> __count,
+ const _Type& __value,
+ _Pred __pred = {},
+ _Proj __proj = _Proj{}) const {
+ return __ranges_search_n_impl(__first, __last, __count, __value, __pred, __proj);
+ }
+
+ template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity>
+ requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_subrange_t<_Range> operator()(_Range&& __range,
+ range_difference_t<_Range> __count,
+ const _Type& __value,
+ _Pred __pred = {},
+ _Proj __proj = {}) const {
+ auto __first = ranges::begin(__range);
+ if (__count <= 0)
+ return {__first, __first};
+ if constexpr (sized_range<_Range>) {
+ auto __size1 = ranges::size(__range);
+ if (__size1 < static_cast<range_size_t<_Range>>(__count)) {
+ ranges::advance(__first, ranges::end(__range));
+ return {__first, __first};
+ }
+ }
+
+ return __ranges_search_n_impl(ranges::begin(__range), ranges::end(__range), __count, __value, __pred, __proj);
+ }
+};
+} // namespace __search_n
+
+inline namespace __cpo {
+ inline constexpr auto search_n = __search_n::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
lib/libcxx/include/__algorithm/ranges_set_difference.h
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
+#define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/set_difference.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/mergeable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__type_traits/decay.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using set_difference_result = in_out_result<_InIter, _OutIter>;
+
+namespace __set_difference {
+
+struct __fn {
+ template <
+ input_iterator _InIter1,
+ sentinel_for<_InIter1> _Sent1,
+ input_iterator _InIter2,
+ sentinel_for<_InIter2> _Sent2,
+ weakly_incrementable _OutIter,
+ class _Comp = less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<_InIter1, _OutIter> operator()(
+ _InIter1 __first1,
+ _Sent1 __last1,
+ _InIter2 __first2,
+ _Sent2 __last2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__set_difference(
+ __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <
+ input_range _Range1,
+ input_range _Range2,
+ weakly_incrementable _OutIter,
+ class _Comp = less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter>
+ operator()(
+ _Range1&& __range1,
+ _Range2&& __range2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__set_difference(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ __result,
+ ranges::__make_projected_comp(__comp, __proj1, __proj2));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+};
+
+} // namespace __set_difference
+
+inline namespace __cpo {
+ inline constexpr auto set_difference = __set_difference::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
lib/libcxx/include/__algorithm/ranges_set_intersection.h
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
+#define _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
+
+#include <__algorithm/in_in_out_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/set_intersection.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/mergeable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter1, class _InIter2, class _OutIter>
+using set_intersection_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
+
+namespace __set_intersection {
+
+struct __fn {
+ template <
+ input_iterator _InIter1,
+ sentinel_for<_InIter1> _Sent1,
+ input_iterator _InIter2,
+ sentinel_for<_InIter2> _Sent2,
+ weakly_incrementable _OutIter,
+ class _Comp = less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<_InIter1, _InIter2, _OutIter> operator()(
+ _InIter1 __first1,
+ _Sent1 __last1,
+ _InIter2 __first2,
+ _Sent2 __last2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__set_intersection<_RangeAlgPolicy>(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ ranges::__make_projected_comp(__comp, __proj1, __proj2));
+ return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
+ }
+
+ template <
+ input_range _Range1,
+ input_range _Range2,
+ weakly_incrementable _OutIter,
+ class _Comp = less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<
+ iterator_t<_Range1>,
+ iterator_t<_Range2>,
+ _OutIter,
+ _Comp,
+ _Proj1,
+ _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<borrowed_iterator_t<_Range1>,
+ borrowed_iterator_t<_Range2>,
+ _OutIter>
+ operator()(
+ _Range1&& __range1,
+ _Range2&& __range2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__set_intersection<_RangeAlgPolicy>(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ std::move(__result),
+ ranges::__make_projected_comp(__comp, __proj1, __proj2));
+ return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
+ }
+};
+
+} // namespace __set_intersection
+
+inline namespace __cpo {
+ inline constexpr auto set_intersection = __set_intersection::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
lib/libcxx/include/__algorithm/ranges_set_symmetric_difference.h
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
+#define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
+
+#include <__algorithm/in_in_out_result.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/set_symmetric_difference.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/mergeable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter1, class _InIter2, class _OutIter>
+using set_symmetric_difference_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
+
+namespace __set_symmetric_difference {
+
+struct __fn {
+ template <
+ input_iterator _InIter1,
+ sentinel_for<_InIter1> _Sent1,
+ input_iterator _InIter2,
+ sentinel_for<_InIter2> _Sent2,
+ weakly_incrementable _OutIter,
+ class _Comp = ranges::less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<_InIter1, _InIter2, _OutIter> operator()(
+ _InIter1 __first1,
+ _Sent1 __last1,
+ _InIter2 __first2,
+ _Sent2 __last2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__set_symmetric_difference(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ ranges::__make_projected_comp(__comp, __proj1, __proj2));
+ return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
+ }
+
+ template <
+ input_range _Range1,
+ input_range _Range2,
+ weakly_incrementable _OutIter,
+ class _Comp = ranges::less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<
+ iterator_t<_Range1>,
+ iterator_t<_Range2>,
+ _OutIter,
+ _Comp,
+ _Proj1,
+ _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<borrowed_iterator_t<_Range1>,
+ borrowed_iterator_t<_Range2>,
+ _OutIter>
+ operator()(
+ _Range1&& __range1,
+ _Range2&& __range2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__set_symmetric_difference(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ std::move(__result),
+ ranges::__make_projected_comp(__comp, __proj1, __proj2));
+ return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
+ }
+};
+
+} // namespace __set_symmetric_difference
+
+inline namespace __cpo {
+ inline constexpr auto set_symmetric_difference = __set_symmetric_difference::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
lib/libcxx/include/__algorithm/ranges_set_union.h
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
+#define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
+
+#include <__algorithm/in_in_out_result.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/set_union.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/mergeable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter1, class _InIter2, class _OutIter>
+using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
+
+namespace __set_union {
+
+struct __fn {
+ template <
+ input_iterator _InIter1,
+ sentinel_for<_InIter1> _Sent1,
+ input_iterator _InIter2,
+ sentinel_for<_InIter2> _Sent2,
+ weakly_incrementable _OutIter,
+ class _Comp = ranges::less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<_InIter1, _InIter2, _OutIter> operator()(
+ _InIter1 __first1,
+ _Sent1 __last1,
+ _InIter2 __first2,
+ _Sent2 __last2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__set_union(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ ranges::__make_projected_comp(__comp, __proj1, __proj2));
+ return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
+ }
+
+ template <
+ input_range _Range1,
+ input_range _Range2,
+ weakly_incrementable _OutIter,
+ class _Comp = ranges::less,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires mergeable<
+ iterator_t<_Range1>,
+ iterator_t<_Range2>,
+ _OutIter,
+ _Comp,
+ _Proj1,
+ _Proj2>
+ _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<borrowed_iterator_t<_Range1>,
+ borrowed_iterator_t<_Range2>,
+ _OutIter>
+ operator()(
+ _Range1&& __range1,
+ _Range2&& __range2,
+ _OutIter __result,
+ _Comp __comp = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ auto __ret = std::__set_union(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ std::move(__result),
+ ranges::__make_projected_comp(__comp, __proj1, __proj2));
+ return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)};
+ }
+};
+
+} // namespace __set_union
+
+inline namespace __cpo {
+ inline constexpr auto set_union = __set_union::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
lib/libcxx/include/__algorithm/ranges_shuffle.h
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
+#define _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/shuffle.h>
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/permutable.h>
+#include <__random/uniform_random_bit_generator.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __shuffle {
+
+struct __fn {
+ // `std::shuffle` is more constrained than `std::ranges::shuffle`. `std::ranges::shuffle` only requires the given
+ // generator to satisfy the `std::uniform_random_bit_generator` concept. `std::shuffle` requires the given
+ // generator to meet the uniform random bit generator requirements; these requirements include satisfying
+ // `std::uniform_random_bit_generator` and add a requirement for the generator to provide a nested `result_type`
+ // typedef (see `[rand.req.urng]`).
+ //
+ // To reuse the implementation from `std::shuffle`, make the given generator meet the classic requirements by wrapping
+ // it into an adaptor type that forwards all of its interface and adds the required typedef.
+ template <class _Gen>
+ class _ClassicGenAdaptor {
+ private:
+ // The generator is not required to be copyable or movable, so it has to be stored as a reference.
+ _Gen& __gen;
+
+ public:
+ using result_type = invoke_result_t<_Gen&>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto min() { return __uncvref_t<_Gen>::min(); }
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto max() { return __uncvref_t<_Gen>::max(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()() const { return __gen(); }
+ };
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen>
+ requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>>
+ _LIBCPP_HIDE_FROM_ABI
+ _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const {
+ _ClassicGenAdaptor<_Gen> __adapted_gen(__gen);
+ return std::__shuffle<_RangeAlgPolicy>(std::move(__first), std::move(__last), __adapted_gen);
+ }
+
+ template<random_access_range _Range, class _Gen>
+ requires permutable<iterator_t<_Range>> && uniform_random_bit_generator<remove_reference_t<_Gen>>
+ _LIBCPP_HIDE_FROM_ABI
+ borrowed_iterator_t<_Range> operator()(_Range&& __range, _Gen&& __gen) const {
+ return (*this)(ranges::begin(__range), ranges::end(__range), std::forward<_Gen>(__gen));
+ }
+
+};
+
+} // namespace __shuffle
+
+inline namespace __cpo {
+ inline constexpr auto shuffle = __shuffle::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
lib/libcxx/include/__algorithm/ranges_sort.h
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SORT_H
+#define _LIBCPP___ALGORITHM_RANGES_SORT_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/sort.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __sort {
+
+struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+ std::__sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
+
+ return __last_iter;
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ }
+};
+
+} // namespace __sort
+
+inline namespace __cpo {
+ inline constexpr auto sort = __sort::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SORT_H
lib/libcxx/include/__algorithm/ranges_sort_heap.h
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
+#define _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/sort_heap.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __sort_heap {
+
+struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ _Iter __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+ std::__sort_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
+
+ return __last_iter;
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __sort_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __sort_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ }
+};
+
+} // namespace __sort_heap
+
+inline namespace __cpo {
+ inline constexpr auto sort_heap = __sort_heap::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
lib/libcxx/include/__algorithm/ranges_stable_partition.h
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
+#define _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/ranges_iterator_concept.h>
+#include <__algorithm/stable_partition.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/permutable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__ranges/subrange.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __stable_partition {
+
+struct __fn {
+
+ template <class _Iter, class _Sent, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI static
+ subrange<__uncvref_t<_Iter>> __stable_partition_fn_impl(
+ _Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+
+ auto&& __projected_pred = std::__make_projected(__pred, __proj);
+ auto __result = std::__stable_partition<_RangeAlgPolicy>(
+ std::move(__first), __last_iter, __projected_pred, __iterator_concept<_Iter>());
+
+ return {std::move(__result), std::move(__last_iter)};
+ }
+
+ template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ requires permutable<_Iter>
+ _LIBCPP_HIDE_FROM_ABI
+ subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
+ return __stable_partition_fn_impl(__first, __last, __pred, __proj);
+ }
+
+ template <bidirectional_range _Range, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_HIDE_FROM_ABI
+ borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
+ return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
+ }
+
+};
+
+} // namespace __stable_partition
+
+inline namespace __cpo {
+ inline constexpr auto stable_partition = __stable_partition::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
lib/libcxx/include/__algorithm/ranges_stable_sort.h
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
+#define _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/stable_sort.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/projected.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __stable_sort {
+
+struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI
+ static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __last_iter = ranges::next(__first, __last);
+
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
+ std::__stable_sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
+
+ return __last_iter;
+ }
+
+ template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI
+ _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __stable_sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
+ }
+
+ template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI
+ borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __stable_sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ }
+};
+
+} // namespace __stable_sort
+
+inline namespace __cpo {
+ inline constexpr auto stable_sort = __stable_sort::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
lib/libcxx/include/__algorithm/ranges_swap_ranges.h
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
+#define _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
+
+#include <__algorithm/in_in_result.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_swap.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _I1, class _I2>
+using swap_ranges_result = in_in_result<_I1, _I2>;
+
+namespace __swap_ranges {
+struct __fn {
+ template <input_iterator _I1, sentinel_for<_I1> _S1,
+ input_iterator _I2, sentinel_for<_I2> _S2>
+ requires indirectly_swappable<_I1, _I2>
+ _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2>
+ operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2) const {
+ while (__first1 != __last1 && __first2 != __last2) {
+ ranges::iter_swap(__first1, __first2);
+ ++__first1;
+ ++__first2;
+ }
+ return {_VSTD::move(__first1), _VSTD::move(__first2)};
+ }
+
+ template <input_range _R1, input_range _R2>
+ requires indirectly_swappable<iterator_t<_R1>, iterator_t<_R2>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ swap_ranges_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
+ operator()(_R1&& __r1, _R2&& __r2) const {
+ return operator()(ranges::begin(__r1), ranges::end(__r1),
+ ranges::begin(__r2), ranges::end(__r2));
+ }
+};
+} // namespace __swap_ranges
+
+inline namespace __cpo {
+ inline constexpr auto swap_ranges = __swap_ranges::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
lib/libcxx/include/__algorithm/ranges_transform.h
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
+#define _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
+
+#include <__algorithm/in_in_out_result.h>
+#include <__algorithm/in_out_result.h>
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Ip, class _Op>
+using unary_transform_result = in_out_result<_Ip, _Op>;
+
+template <class _I1, class _I2, class _O1>
+using binary_transform_result = in_in_out_result<_I1, _I2, _O1>;
+
+namespace __transform {
+struct __fn {
+private:
+ template <class _InIter, class _Sent,
+ class _OutIter,
+ class _Func,
+ class _Proj>
+ _LIBCPP_HIDE_FROM_ABI static constexpr
+ unary_transform_result<_InIter, _OutIter> __unary(_InIter __first, _Sent __last,
+ _OutIter __result,
+ _Func& __operation,
+ _Proj& __projection) {
+ while (__first != __last) {
+ *__result = std::invoke(__operation, std::invoke(__projection, *__first));
+ ++__first;
+ ++__result;
+ }
+
+ return {std::move(__first), std::move(__result)};
+ }
+
+ template <class _InIter1, class _Sent1,
+ class _InIter2, class _Sent2,
+ class _OutIter,
+ class _Func,
+ class _Proj1,
+ class _Proj2>
+ _LIBCPP_HIDE_FROM_ABI static constexpr binary_transform_result<_InIter1, _InIter2, _OutIter>
+ __binary(_InIter1 __first1, _Sent1 __last1,
+ _InIter2 __first2, _Sent2 __last2,
+ _OutIter __result,
+ _Func& __binary_operation,
+ _Proj1& __projection1,
+ _Proj2& __projection2) {
+ while (__first1 != __last1 && __first2 != __last2) {
+ *__result = std::invoke(__binary_operation, std::invoke(__projection1, *__first1),
+ std::invoke(__projection2, *__first2));
+ ++__first1;
+ ++__first2;
+ ++__result;
+ }
+ return {std::move(__first1), std::move(__first2), std::move(__result)};
+ }
+public:
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter,
+ copy_constructible _Func,
+ class _Proj = identity>
+ requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<_InIter, _Proj>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ unary_transform_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last,
+ _OutIter __result,
+ _Func __operation,
+ _Proj __proj = {}) const {
+ return __unary(std::move(__first), std::move(__last), std::move(__result), __operation, __proj);
+ }
+
+ template <input_range _Range,
+ weakly_incrementable _OutIter,
+ copy_constructible _Func,
+ class _Proj = identity>
+ requires indirectly_writable<_OutIter, indirect_result_t<_Func, projected<iterator_t<_Range>, _Proj>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ unary_transform_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range,
+ _OutIter __result,
+ _Func __operation,
+ _Proj __projection = {}) const {
+ return __unary(ranges::begin(__range), ranges::end(__range), std::move(__result), __operation, __projection);
+ }
+
+ template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1,
+ input_iterator _InIter2, sentinel_for<_InIter2> _Sent2,
+ weakly_incrementable _OutIter,
+ copy_constructible _Func,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<_InIter1, _Proj1>,
+ projected<_InIter2, _Proj2>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ binary_transform_result<_InIter1, _InIter2, _OutIter> operator()(_InIter1 __first1, _Sent1 __last1,
+ _InIter2 __first2, _Sent2 __last2,
+ _OutIter __result,
+ _Func __binary_operation,
+ _Proj1 __projection1 = {},
+ _Proj2 __projection2 = {}) const {
+ return __binary(std::move(__first1), std::move(__last1),
+ std::move(__first2), std::move(__last2),
+ std::move(__result),
+ __binary_operation,
+ __projection1,
+ __projection2);
+ }
+
+ template <input_range _Range1,
+ input_range _Range2,
+ weakly_incrementable _OutIter,
+ copy_constructible _Func,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<iterator_t<_Range1>, _Proj1>,
+ projected<iterator_t<_Range2>, _Proj2>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ binary_transform_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter>
+ operator()(_Range1&& __range1,
+ _Range2&& __range2,
+ _OutIter __result,
+ _Func __binary_operation,
+ _Proj1 __projection1 = {},
+ _Proj2 __projection2 = {}) const {
+ return __binary(ranges::begin(__range1), ranges::end(__range1),
+ ranges::begin(__range2), ranges::end(__range2),
+ std::move(__result),
+ __binary_operation,
+ __projection1,
+ __projection2);
+ }
+
+};
+} // namespace __transform
+
+inline namespace __cpo {
+ inline constexpr auto transform = __transform::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
lib/libcxx/include/__algorithm/ranges_unique.h
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
+#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/unique.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/permutable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__ranges/subrange.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __unique {
+
+ struct __fn {
+ template <
+ permutable _Iter,
+ sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
+ _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <
+ forward_range _Range,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+ };
+
+} // namespace __unique
+
+inline namespace __cpo {
+ inline constexpr auto unique = __unique::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
lib/libcxx/include/__algorithm/ranges_unique_copy.h
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
+
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/unique_copy.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/projected.h>
+#include <__iterator/readable_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter, class _OutIter>
+using unique_copy_result = in_out_result<_InIter, _OutIter>;
+
+namespace __unique_copy {
+
+template <class _InIter, class _OutIter>
+concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>);
+
+struct __fn {
+ template <class _InIter, class _OutIter>
+ static consteval auto __get_algo_tag() {
+ if constexpr (forward_iterator<_InIter>) {
+ return __unique_copy_tags::__reread_from_input_tag{};
+ } else if constexpr (__can_reread_from_output<_InIter, _OutIter>) {
+ return __unique_copy_tags::__reread_from_output_tag{};
+ } else if constexpr (indirectly_copyable_storable<_InIter, _OutIter>) {
+ return __unique_copy_tags::__read_from_tmp_value_tag{};
+ }
+ }
+
+ template <class _InIter, class _OutIter>
+ using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>());
+
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<_InIter, _Proj>> _Comp = ranges::equal_to>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ (forward_iterator<_InIter> ||
+ (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>) ||
+ indirectly_copyable_storable<_InIter, _OutIter>)
+ _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique_copy<_RangeAlgPolicy>(
+ std::move(__first),
+ std::move(__last),
+ std::move(__result),
+ std::__make_projected(__comp, __proj),
+ __algo_tag_t<_InIter, _OutIter>());
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <input_range _Range,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ (forward_iterator<iterator_t<_Range>> ||
+ (input_iterator<_OutIter> && same_as<range_value_t<_Range>, iter_value_t<_OutIter>>) ||
+ indirectly_copyable_storable<iterator_t<_Range>, _OutIter>)
+ _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique_copy<_RangeAlgPolicy>(
+ ranges::begin(__range),
+ ranges::end(__range),
+ std::move(__result),
+ std::__make_projected(__comp, __proj),
+ __algo_tag_t<iterator_t<_Range>, _OutIter>());
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+};
+
+} // namespace __unique_copy
+
+inline namespace __cpo {
+inline constexpr auto unique_copy = __unique_copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
lib/libcxx/include/__algorithm/ranges_upper_bound.h
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
+#define _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/lower_bound.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __upper_bound {
+struct __fn {
+ template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
+ indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
+ return !std::invoke(__comp, __rhs, __lhs);
+ };
+
+ return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp_lhs_rhs_swapped, __proj);
+ }
+
+ template <forward_range _Range, class _Type, class _Proj = identity,
+ indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_iterator_t<_Range> operator()(_Range&& __r,
+ const _Type& __value,
+ _Comp __comp = {},
+ _Proj __proj = {}) const {
+ auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
+ return !std::invoke(__comp, __rhs, __lhs);
+ };
+
+ return std::__lower_bound_impl<_RangeAlgPolicy>(ranges::begin(__r),
+ ranges::end(__r),
+ __value,
+ __comp_lhs_rhs_swapped,
+ __proj);
+ }
+};
+} // namespace __upper_bound
+
+inline namespace __cpo {
+ inline constexpr auto upper_bound = __upper_bound::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
lib/libcxx/include/__algorithm/remove.h
@@ -15,22 +15,22 @@
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp>
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
- __first = _VSTD::find(__first, __last, __value_);
+ __first = _VSTD::find(__first, __last, __value);
if (__first != __last)
{
_ForwardIterator __i = __first;
while (++__i != __last)
{
- if (!(*__i == __value_))
+ if (!(*__i == __value))
{
*__first = _VSTD::move(*__i);
++__first;
lib/libcxx/include/__algorithm/remove_copy.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -20,11 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
-remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_)
+remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value)
{
for (; __first != __last; ++__first)
{
- if (!(*__first == __value_))
+ if (!(*__first == __value))
{
*__result = *__first;
++__result;
lib/libcxx/include/__algorithm/remove_copy_if.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/remove_if.h
@@ -11,10 +11,10 @@
#include <__algorithm/find_if.h>
#include <__config>
-#include <utility>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/replace.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/replace_copy.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/replace_copy_if.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/replace_if.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/reverse.h
@@ -14,7 +14,7 @@
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/reverse_copy.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/rotate.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___ALGORITHM_ROTATE_H
#define _LIBCPP___ALGORITHM_ROTATE_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/move.h>
#include <__algorithm/move_backward.h>
#include <__algorithm/swap_ranges.h>
@@ -16,46 +17,50 @@
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
#include <__iterator/prev.h>
+#include <__utility/move.h>
#include <__utility/swap.h>
-#include <iterator>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator>
+template <class _AlgPolicy, class _ForwardIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
- value_type __tmp = _VSTD::move(*__first);
+ value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__first);
+ // TODO(ranges): pass `_AlgPolicy` to `move`.
_ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);
*__lm1 = _VSTD::move(__tmp);
return __lm1;
}
-template <class _BidirectionalIterator>
+template <class _AlgPolicy, class _BidirectionalIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ // TODO(ranges): pass `_AlgPolicy` to `prev`.
_BidirectionalIterator __lm1 = _VSTD::prev(__last);
- value_type __tmp = _VSTD::move(*__lm1);
+ value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__lm1);
+ // TODO(ranges): pass `_AlgPolicy` to `move_backward`.
_BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);
*__first = _VSTD::move(__tmp);
return __fp1;
}
-template <class _ForwardIterator>
+template <class _AlgPolicy, class _ForwardIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
_ForwardIterator __i = __middle;
while (true)
{
- swap(*__first, *__i);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __i);
++__first;
if (++__i == __last)
break;
@@ -68,7 +73,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
__i = __middle;
while (true)
{
- swap(*__first, *__i);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __i);
++__first;
if (++__i == __last)
{
@@ -97,7 +102,7 @@ __algo_gcd(_Integral __x, _Integral __y)
return __x;
}
-template<typename _RandomAccessIterator>
+template <class _AlgPolicy, typename _RandomAccessIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
{
@@ -108,18 +113,19 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
const difference_type __m2 = __last - __middle;
if (__m1 == __m2)
{
+ // TODO(ranges): pass `_AlgPolicy` to `swap_ranges`.
_VSTD::swap_ranges(__first, __middle, __middle);
return __middle;
}
const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
for (_RandomAccessIterator __p = __first + __g; __p != __first;)
{
- value_type __t(_VSTD::move(*--__p));
+ value_type __t(_IterOps<_AlgPolicy>::__iter_move(--__p));
_RandomAccessIterator __p1 = __p;
_RandomAccessIterator __p2 = __p1 + __m1;
do
{
- *__p1 = _VSTD::move(*__p2);
+ *__p1 = _IterOps<_AlgPolicy>::__iter_move(__p2);
__p1 = __p2;
const difference_type __d = __last - __p2;
if (__m1 < __d)
@@ -132,54 +138,66 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
return __first + __m2;
}
-template <class _ForwardIterator>
+template <class _AlgPolicy, class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
-__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
+__rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
_VSTD::forward_iterator_tag)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
if (is_trivially_move_assignable<value_type>::value)
{
- if (_VSTD::next(__first) == __middle)
- return _VSTD::__rotate_left(__first, __last);
+ if (_IterOps<_AlgPolicy>::next(__first) == __middle)
+ return std::__rotate_left<_AlgPolicy>(__first, __last);
}
- return _VSTD::__rotate_forward(__first, __middle, __last);
+ return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last);
}
-template <class _BidirectionalIterator>
+template <class _AlgPolicy, class _BidirectionalIterator>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
-__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+__rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
bidirectional_iterator_tag)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
if (is_trivially_move_assignable<value_type>::value)
{
- if (_VSTD::next(__first) == __middle)
- return _VSTD::__rotate_left(__first, __last);
- if (_VSTD::next(__middle) == __last)
- return _VSTD::__rotate_right(__first, __last);
+ if (_IterOps<_AlgPolicy>::next(__first) == __middle)
+ return std::__rotate_left<_AlgPolicy>(__first, __last);
+ if (_IterOps<_AlgPolicy>::next(__middle) == __last)
+ return std::__rotate_right<_AlgPolicy>(__first, __last);
}
- return _VSTD::__rotate_forward(__first, __middle, __last);
+ return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last);
}
-template <class _RandomAccessIterator>
+template <class _AlgPolicy, class _RandomAccessIterator>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
-__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
+__rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
random_access_iterator_tag)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
if (is_trivially_move_assignable<value_type>::value)
{
- if (_VSTD::next(__first) == __middle)
- return _VSTD::__rotate_left(__first, __last);
- if (_VSTD::next(__middle) == __last)
- return _VSTD::__rotate_right(__first, __last);
- return _VSTD::__rotate_gcd(__first, __middle, __last);
+ if (_IterOps<_AlgPolicy>::next(__first) == __middle)
+ return std::__rotate_left<_AlgPolicy>(__first, __last);
+ if (_IterOps<_AlgPolicy>::next(__middle) == __last)
+ return std::__rotate_right<_AlgPolicy>(__first, __last);
+ return std::__rotate_gcd<_AlgPolicy>(__first, __middle, __last);
}
- return _VSTD::__rotate_forward(__first, __middle, __last);
+ return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last);
+}
+
+template <class _AlgPolicy, class _RandomAccessIterator, class _IterCategory>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle,
+ _RandomAccessIterator __last, _IterCategory __iter_category) {
+ if (__first == __middle)
+ return __last;
+ if (__middle == __last)
+ return __first;
+
+ return std::__rotate_impl<_AlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __iter_category);
}
template <class _ForwardIterator>
@@ -187,12 +205,8 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
- if (__first == __middle)
- return __last;
- if (__middle == __last)
- return __first;
- return _VSTD::__rotate(__first, __middle, __last,
- typename iterator_traits<_ForwardIterator>::iterator_category());
+ return std::__rotate<_ClassicAlgPolicy>(__first, __middle, __last,
+ typename iterator_traits<_ForwardIterator>::iterator_category());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/rotate_copy.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/sample.h
@@ -10,13 +10,15 @@
#define _LIBCPP___ALGORITHM_SAMPLE_H
#include <__algorithm/min.h>
+#include <__assert>
#include <__config>
-#include <__debug>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
#include <__random/uniform_int_distribution.h>
-#include <iterator>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__algorithm/search.h
@@ -11,41 +11,59 @@
#define _LIBCPP___ALGORITHM_SEARCH_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
-#include <utility>
+#include <__type_traits/is_callable.h>
+#include <__utility/pair.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-pair<_ForwardIterator1, _ForwardIterator1>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) {
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1,
+ class _Iter2, class _Sent2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter1, _Iter1> __search_forward_impl(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2) {
if (__first2 == __last2)
- return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence
+ return std::make_pair(__first1, __first1); // Everything matches an empty sequence
while (true) {
// Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks
while (true) {
- if (__first1 == __last1) // return __last1 if no element matches *__first2
- return _VSTD::make_pair(__last1, __last1);
- if (__pred(*__first1, *__first2))
+ if (__first1 == __last1) { // return __last1 if no element matches *__first2
+ _IterOps<_AlgPolicy>::__advance_to(__first1, __last1);
+ return std::make_pair(__first1, __first1);
+ }
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
break;
++__first1;
}
// *__first1 matches *__first2, now match elements after here
- _ForwardIterator1 __m1 = __first1;
- _ForwardIterator2 __m2 = __first2;
+ _Iter1 __m1 = __first1;
+ _Iter2 __m2 = __first2;
while (true) {
if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
- return _VSTD::make_pair(__first1, __m1);
- if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found
- return _VSTD::make_pair(__last1, __last1);
- if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1
+ return std::make_pair(__first1, ++__m1);
+ if (++__m1 == __last1) { // Otherwise if source exhaused, pattern not found
+ return std::make_pair(__m1, __m1);
+ }
+
+ // if there is a mismatch, restart with a new __first1
+ if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2)))
{
++__first1;
break;
@@ -54,38 +72,42 @@ pair<_ForwardIterator1, _ForwardIterator1>
}
}
-template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_RandomAccessIterator1, _RandomAccessIterator1>
-__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
- _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
- random_access_iterator_tag) {
- typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
- typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
- // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
- const _D2 __len2 = __last2 - __first2;
- if (__len2 == 0)
- return _VSTD::make_pair(__first1, __first1);
- const _D1 __len1 = __last1 - __first1;
- if (__len1 < __len2)
- return _VSTD::make_pair(__last1, __last1);
- const _RandomAccessIterator1 __s = __last1 - _D1(__len2 - 1); // Start of pattern match can't go beyond here
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1,
+ class _Iter2, class _Sent2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2,
+ class _DiffT1,
+ class _DiffT2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter1, _Iter1> __search_random_access_impl(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2,
+ _DiffT1 __size1,
+ _DiffT2 __size2) {
+ const _Iter1 __s = __first1 + __size1 - _DiffT1(__size2 - 1); // Start of pattern match can't go beyond here
while (true) {
while (true) {
- if (__first1 == __s)
- return _VSTD::make_pair(__last1, __last1);
- if (__pred(*__first1, *__first2))
+ if (__first1 == __s) {
+ _IterOps<_AlgPolicy>::__advance_to(__first1, __last1);
+ return std::make_pair(__first1, __first1);
+ }
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
break;
++__first1;
}
- _RandomAccessIterator1 __m1 = __first1;
- _RandomAccessIterator2 __m2 = __first2;
+ _Iter1 __m1 = __first1;
+ _Iter2 __m2 = __first2;
while (true) {
if (++__m2 == __last2)
- return _VSTD::make_pair(__first1, __first1 + _D1(__len2));
+ return std::make_pair(__first1, __first1 + _DiffT1(__size2));
++__m1; // no need to check range on __m1 because __s guarantees we have enough source
- if (!__pred(*__m1, *__m2)) {
+ if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2))) {
++__first1;
break;
}
@@ -93,22 +115,78 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando
}
}
+template <class _Iter1, class _Sent1,
+ class _Iter2, class _Sent2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2,
+ __enable_if_t<__is_cpp17_random_access_iterator<_Iter1>::value
+ && __is_cpp17_random_access_iterator<_Iter2>::value>* = nullptr) {
+
+ auto __size2 = __last2 - __first2;
+ if (__size2 == 0)
+ return std::make_pair(__first1, __first1);
+
+ auto __size1 = __last1 - __first1;
+ if (__size1 < __size2) {
+ return std::make_pair(__last1, __last1);
+ }
+
+ return std::__search_random_access_impl<_ClassicAlgPolicy>(__first1, __last1,
+ __first2, __last2,
+ __pred,
+ __proj1,
+ __proj2,
+ __size1,
+ __size2);
+}
+
+template <class _Iter1, class _Sent1,
+ class _Iter2, class _Sent2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
+ _Iter2 __first2, _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2,
+ __enable_if_t<__is_cpp17_forward_iterator<_Iter1>::value
+ && __is_cpp17_forward_iterator<_Iter2>::value
+ && !(__is_cpp17_random_access_iterator<_Iter1>::value
+ && __is_cpp17_random_access_iterator<_Iter2>::value)>* = nullptr) {
+ return std::__search_forward_impl<_ClassicAlgPolicy>(__first1, __last1,
+ __first2, __last2,
+ __pred,
+ __proj1,
+ __proj2);
+}
+
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
-search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- _BinaryPredicate __pred) {
- return _VSTD::__search<_BinaryPredicate&>(
- __first1, __last1, __first2, __last2, __pred,
- typename iterator_traits<_ForwardIterator1>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category()).first;
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+ _BinaryPredicate __pred) {
+ static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
+ "BinaryPredicate has to be callable");
+ auto __proj = __identity();
+ return std::__search_impl(__first1, __last1, __first2, __last2, __pred, __proj, __proj).first;
}
template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
-search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
+ using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;
+ using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
+ return std::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
}
#if _LIBCPP_STD_VER > 14
lib/libcxx/include/__algorithm/search_n.h
@@ -11,40 +11,56 @@
#define _LIBCPP___ALGORITHM_SEARCH_N_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
+#include <__ranges/concepts.h>
+#include <__utility/pair.h>
#include <type_traits> // __convert_to_integral
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last,
- _Size __count, const _Tp& __value_, _BinaryPredicate __pred,
- forward_iterator_tag) {
+template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
+ _SizeT __count,
+ const _Type& __value,
+ _Pred& __pred,
+ _Proj& __proj) {
if (__count <= 0)
- return __first;
+ return std::make_pair(__first, __first);
while (true) {
- // Find first element in sequence that matchs __value_, with a mininum of loop checks
+ // Find first element in sequence that matchs __value, with a mininum of loop checks
while (true) {
- if (__first == __last) // return __last if no element matches __value_
- return __last;
- if (__pred(*__first, __value_))
+ if (__first == __last) { // return __last if no element matches __value
+ _IterOps<_AlgPolicy>::__advance_to(__first, __last);
+ return std::make_pair(__first, __first);
+ }
+ if (std::__invoke(__pred, std::__invoke(__proj, *__first), __value))
break;
++__first;
}
- // *__first matches __value_, now match elements after here
- _ForwardIterator __m = __first;
- _Size __c(0);
+ // *__first matches __value, now match elements after here
+ _Iter __m = __first;
+ _SizeT __c(0);
while (true) {
if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
- return __first;
- if (++__m == __last) // Otherwise if source exhaused, pattern not found
- return __last;
- if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
+ return std::make_pair(__first, ++__m);
+ if (++__m == __last) { // Otherwise if source exhaused, pattern not found
+ _IterOps<_AlgPolicy>::__advance_to(__first, __last);
+ return std::make_pair(__first, __first);
+ }
+
+ // if there is a mismatch, restart with a new __first
+ if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value))
{
__first = __m;
++__first;
@@ -54,35 +70,44 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __fir
}
}
-template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIterator __first,
- _RandomAccessIterator __last, _Size __count,
- const _Tp& __value_, _BinaryPredicate __pred,
- random_access_iterator_tag) {
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- if (__count <= 0)
- return __first;
- _Size __len = static_cast<_Size>(__last - __first);
- if (__len < __count)
- return __last;
- const _RandomAccessIterator __s = __last - difference_type(__count - 1); // Start of pattern match can't go beyond here
+template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __last,
+ _SizeT __count,
+ const _Type& __value,
+ _Pred& __pred,
+ _Proj& __proj,
+ _DiffT __size1) {
+ using difference_type = typename iterator_traits<_Iter>::difference_type;
+ if (__count == 0)
+ return std::make_pair(__first, __first);
+ if (__size1 < static_cast<_DiffT>(__count)) {
+ _IterOps<_AlgPolicy>::__advance_to(__first, __last);
+ return std::make_pair(__first, __first);
+ }
+
+ const auto __s = __first + __size1 - difference_type(__count - 1); // Start of pattern match can't go beyond here
while (true) {
- // Find first element in sequence that matchs __value_, with a mininum of loop checks
+ // Find first element in sequence that matchs __value, with a mininum of loop checks
while (true) {
- if (__first >= __s) // return __last if no element matches __value_
- return __last;
- if (__pred(*__first, __value_))
+ if (__first >= __s) { // return __last if no element matches __value
+ _IterOps<_AlgPolicy>::__advance_to(__first, __last);
+ return std::make_pair(__first, __first);
+ }
+ if (std::__invoke(__pred, std::__invoke(__proj, *__first), __value))
break;
++__first;
}
// *__first matches __value_, now match elements after here
- _RandomAccessIterator __m = __first;
- _Size __c(0);
+ auto __m = __first;
+ _SizeT __c(0);
while (true) {
if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
- return __first;
- ++__m; // no need to check range on __m because __s guarantees we have enough source
- if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
+ return std::make_pair(__first, __first + _DiffT(__count));
+ ++__m; // no need to check range on __m because __s guarantees we have enough source
+
+ // if there is a mismatch, restart with a new __first
+ if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value))
{
__first = __m;
++__first;
@@ -92,19 +117,63 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter
}
}
+template <class _Iter, class _Sent,
+ class _DiffT,
+ class _Type,
+ class _Pred,
+ class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter, _Iter> __search_n_impl(_Iter __first, _Sent __last,
+ _DiffT __count,
+ const _Type& __value,
+ _Pred& __pred,
+ _Proj& __proj,
+ __enable_if_t<__is_cpp17_random_access_iterator<_Iter>::value>* = nullptr) {
+ return std::__search_n_random_access_impl<_ClassicAlgPolicy>(__first, __last,
+ __count,
+ __value,
+ __pred,
+ __proj,
+ __last - __first);
+}
+
+template <class _Iter1, class _Sent1,
+ class _DiffT,
+ class _Type,
+ class _Pred,
+ class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
+ _DiffT __count,
+ const _Type& __value,
+ _Pred& __pred,
+ _Proj& __proj,
+ __enable_if_t<__is_cpp17_forward_iterator<_Iter1>::value
+ && !__is_cpp17_random_access_iterator<_Iter1>::value>* = nullptr) {
+ return std::__search_n_forward_impl<_ClassicAlgPolicy>(__first, __last,
+ __count,
+ __value,
+ __pred,
+ __proj);
+}
+
template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n(
- _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) {
- return _VSTD::__search_n<_BinaryPredicate&>(
- __first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred,
- typename iterator_traits<_ForwardIterator>::iterator_category());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
+ _Size __count,
+ const _Tp& __value,
+ _BinaryPredicate __pred) {
+ static_assert(__is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value,
+ "BinaryPredicate has to be callable");
+ auto __proj = __identity();
+ return std::__search_n_impl(__first, __last, std::__convert_to_integral(__count), __value, __pred, __proj).first;
}
template <class _ForwardIterator, class _Size, class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) {
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count), __value_, __equal_to<__v, _Tp>());
+ return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to<__v, _Tp>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_difference.h
@@ -13,58 +13,65 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/copy.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- while (__first1 != __last1)
- {
- if (__first2 == __last2)
- return _VSTD::copy(__first1, __last1, __result);
- if (__comp(*__first1, *__first2))
- {
- *__result = *__first1;
- ++__result;
- ++__first1;
- }
- else
- {
- if (!__comp(*__first2, *__first1))
- ++__first1;
- ++__first2;
- }
+template < class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<__uncvref_t<_InIter1>, __uncvref_t<_OutIter> >
+__set_difference(
+ _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
+ while (__first1 != __last1 && __first2 != __last2) {
+ if (__comp(*__first1, *__first2)) {
+ *__result = *__first1;
+ ++__first1;
+ ++__result;
+ } else if (__comp(*__first2, *__first1)) {
+ ++__first2;
+ } else {
+ ++__first1;
+ ++__first2;
}
- return __result;
+ }
+ return std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _OutputIterator __result,
+ _Compare __comp) {
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return std::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp).second;
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _OutputIterator __result) {
+ return std::__set_difference(
+ __first1,
+ __last1,
+ __first2,
+ __last2,
+ __result,
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>()).second;
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_intersection.h
@@ -11,57 +11,88 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- while (__first1 != __last1 && __first2 != __last2)
- {
- if (__comp(*__first1, *__first2))
- ++__first1;
- else
- {
- if (!__comp(*__first2, *__first1))
- {
- *__result = *__first1;
- ++__result;
- ++__first1;
- }
- ++__first2;
- }
+template <class _InIter1, class _InIter2, class _OutIter>
+struct __set_intersection_result {
+ _InIter1 __in1_;
+ _InIter2 __in2_;
+ _OutIter __out_;
+
+ // need a constructor as C++03 aggregate init is hard
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ __set_intersection_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
+ : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
+};
+
+template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_intersection_result<_InIter1, _InIter2, _OutIter>
+__set_intersection(
+ _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
+ while (__first1 != __last1 && __first2 != __last2) {
+ if (__comp(*__first1, *__first2))
+ ++__first1;
+ else {
+ if (!__comp(*__first2, *__first1)) {
+ *__result = *__first1;
+ ++__result;
+ ++__first1;
+ }
+ ++__first2;
}
- return __result;
+ }
+
+ return __set_intersection_result<_InIter1, _InIter2, _OutIter>(
+ _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)),
+ _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)),
+ std::move(__result));
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _OutputIterator __result,
+ _Compare __comp) {
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return std::__set_intersection<_ClassicAlgPolicy, _Comp_ref>(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ __comp)
+ .__out_;
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _OutputIterator __result) {
+ return std::__set_intersection<_ClassicAlgPolicy>(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>())
+ .__out_;
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_symmetric_difference.h
@@ -14,62 +14,89 @@
#include <__algorithm/copy.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- while (__first1 != __last1)
- {
- if (__first2 == __last2)
- return _VSTD::copy(__first1, __last1, __result);
- if (__comp(*__first1, *__first2))
- {
- *__result = *__first1;
- ++__result;
- ++__first1;
- }
- else
- {
- if (__comp(*__first2, *__first1))
- {
- *__result = *__first2;
- ++__result;
- }
- else
- ++__first1;
- ++__first2;
- }
+template <class _InIter1, class _InIter2, class _OutIter>
+struct __set_symmetric_difference_result {
+ _InIter1 __in1_;
+ _InIter2 __in2_;
+ _OutIter __out_;
+
+ // need a constructor as C++03 aggregate init is hard
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ __set_symmetric_difference_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
+ : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
+};
+
+template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
+__set_symmetric_difference(
+ _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
+ while (__first1 != __last1) {
+ if (__first2 == __last2) {
+ auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result));
+ return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
+ std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
+ }
+ if (__comp(*__first1, *__first2)) {
+ *__result = *__first1;
+ ++__result;
+ ++__first1;
+ } else {
+ if (__comp(*__first2, *__first1)) {
+ *__result = *__first2;
+ ++__result;
+ } else {
+ ++__first1;
+ }
+ ++__first2;
}
- return _VSTD::copy(__first2, __last2, __result);
+ }
+ auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result));
+ return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
+ std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _OutputIterator __result,
+ _Compare __comp) {
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return std::__set_symmetric_difference<_Comp_ref>(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ __comp)
+ .__out_;
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _OutputIterator __result) {
+ return std::set_symmetric_difference(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_union.h
@@ -14,57 +14,85 @@
#include <__algorithm/copy.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__set_union(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- for (; __first1 != __last1; ++__result)
- {
- if (__first2 == __last2)
- return _VSTD::copy(__first1, __last1, __result);
- if (__comp(*__first2, *__first1))
- {
- *__result = *__first2;
- ++__first2;
- }
- else
- {
- if (!__comp(*__first1, *__first2))
- ++__first2;
- *__result = *__first1;
- ++__first1;
- }
+template <class _InIter1, class _InIter2, class _OutIter>
+struct __set_union_result {
+ _InIter1 __in1_;
+ _InIter2 __in2_;
+ _OutIter __out_;
+
+ // need a constructor as C++03 aggregate init is hard
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ __set_union_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
+ : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
+};
+
+template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
+ _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
+ for (; __first1 != __last1; ++__result) {
+ if (__first2 == __last2) {
+ auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result));
+ return __set_union_result<_InIter1, _InIter2, _OutIter>(
+ std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
+ }
+ if (__comp(*__first2, *__first1)) {
+ *__result = *__first2;
+ ++__first2;
+ } else {
+ if (!__comp(*__first1, *__first2)) {
+ ++__first2;
+ }
+ *__result = *__first1;
+ ++__first1;
}
- return _VSTD::copy(__first2, __last2, __result);
+ }
+ auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result));
+ return __set_union_result<_InIter1, _InIter2, _OutIter>(
+ std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_union(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _OutputIterator __result,
+ _Compare __comp) {
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return std::__set_union<_Comp_ref>(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ __comp)
+ .__out_;
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_union(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- return _VSTD::set_union(__first1, __last1, __first2, __last2, __result,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
+ _InputIterator1 __first1,
+ _InputIterator1 __last1,
+ _InputIterator2 __first2,
+ _InputIterator2 __last2,
+ _OutputIterator __result) {
+ return std::set_union(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/shift_left.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/shift_right.h
@@ -18,7 +18,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/shuffle.h
@@ -9,15 +9,18 @@
#ifndef _LIBCPP___ALGORITHM_SHUFFLE_H
#define _LIBCPP___ALGORITHM_SHUFFLE_H
+#include <__algorithm/iterator_operations.h>
#include <__config>
+#include <__debug>
#include <__iterator/iterator_traits.h>
#include <__random/uniform_int_distribution.h>
-#include <__utility/swap.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
#include <cstddef>
#include <cstdint>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -133,13 +136,15 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
}
#endif
-template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
- void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _UniformRandomNumberGenerator&& __g)
-{
+template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator>
+_RandomAccessIterator __shuffle(
+ _RandomAccessIterator __first, _Sentinel __last_sentinel, _UniformRandomNumberGenerator&& __g) {
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef uniform_int_distribution<ptrdiff_t> _Dp;
typedef typename _Dp::param_type _Pp;
+
+ auto __original_last = _IterOps<_AlgPolicy>::next(__first, __last_sentinel);
+ auto __last = __original_last;
difference_type __d = __last - __first;
if (__d > 1)
{
@@ -148,9 +153,18 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
{
difference_type __i = __uid(__g, _Pp(0, __d));
if (__i != difference_type(0))
- swap(*__first, *(__first + __i));
+ _IterOps<_AlgPolicy>::iter_swap(__first, __first + __i);
}
}
+
+ return __original_last;
+}
+
+template <class _RandomAccessIterator, class _UniformRandomNumberGenerator>
+void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
+ _UniformRandomNumberGenerator&& __g) {
+ (void)std::__shuffle<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g));
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/sift_down.h
@@ -9,22 +9,26 @@
#ifndef _LIBCPP___ALGORITHM_SIFT_DOWN_H
#define _LIBCPP___ALGORITHM_SIFT_DOWN_H
+#include <__algorithm/iterator_operations.h>
+#include <__assert>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _RandomAccessIterator>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
-__sift_down(_RandomAccessIterator __first, _Compare __comp,
+__sift_down(_RandomAccessIterator __first, _Compare&& __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
_RandomAccessIterator __start)
{
+ using _Ops = _IterOps<_AlgPolicy>;
+
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
// left-child of __start is at 2 * __start + 1
@@ -48,11 +52,11 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp,
// we are, __start is larger than its largest child
return;
- value_type __top(_VSTD::move(*__start));
+ value_type __top(_Ops::__iter_move(__start));
do
{
// we are not in heap-order, swap the parent with its largest child
- *__start = _VSTD::move(*__child_i);
+ *__start = _Ops::__iter_move(__child_i);
__start = __child_i;
if ((__len - 2) / 2 < __child)
@@ -73,6 +77,38 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp,
*__start = _VSTD::move(__top);
}
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
+__floyd_sift_down(_RandomAccessIterator __first, _Compare&& __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len)
+{
+ using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
+ _LIBCPP_ASSERT(__len >= 2, "shouldn't be called unless __len >= 2");
+
+ _RandomAccessIterator __hole = __first;
+ _RandomAccessIterator __child_i = __first;
+ difference_type __child = 0;
+
+ while (true) {
+ __child_i += difference_type(__child + 1);
+ __child = 2 * __child + 1;
+
+ if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) {
+ // right-child exists and is greater than left-child
+ ++__child_i;
+ ++__child;
+ }
+
+ // swap __hole with its largest child
+ *__hole = _IterOps<_AlgPolicy>::__iter_move(__child_i);
+ __hole = __child_i;
+
+ // if __hole is now a leaf, we're done
+ if (__child > (__len - 2) / 2)
+ return __hole;
+ }
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H
lib/libcxx/include/__algorithm/sort.h
@@ -11,462 +11,602 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/min_element.h>
#include <__algorithm/partial_sort.h>
#include <__algorithm/unwrap_iter.h>
+#include <__bits>
#include <__config>
-#include <__utility/swap.h>
+#include <__debug>
+#include <__debug_utils/randomize_range.h>
+#include <__functional/operations.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/iterator_traits.h>
+#include <climits>
#include <memory>
-#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
-# include <__algorithm/shuffle.h>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+// Wraps an algorithm policy tag and a comparator in a single struct, used to pass the policy tag around without
+// changing the number of template arguments (to keep the ABI stable). This is only used for the "range" policy tag.
+//
+// To create an object of this type, use `_WrapAlgPolicy<T, C>::type` -- see the specialization below for the rationale.
+template <class _PolicyT, class _CompT, class = void>
+struct _WrapAlgPolicy {
+ using type = _WrapAlgPolicy;
+
+ using _AlgPolicy = _PolicyT;
+ using _Comp = _CompT;
+ _Comp& __comp;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _WrapAlgPolicy(_Comp& __c) : __comp(__c) {}
+};
+
+// Specialization for the "classic" policy tag that avoids creating a struct and simply defines an alias for the
+// comparator. When unwrapping, a pristine comparator is always considered to have the "classic" tag attached. Passing
+// the pristine comparator where possible allows using template instantiations from the dylib.
+template <class _PolicyT, class _CompT>
+struct _WrapAlgPolicy<_PolicyT, _CompT, __enable_if_t<std::is_same<_PolicyT, _ClassicAlgPolicy>::value> > {
+ using type = _CompT;
+};
+
+// Unwraps a pristine functor (e.g. `std::less`) as if it were wrapped using `_WrapAlgPolicy`. The policy tag is always
+// set to "classic".
+template <class _CompT>
+struct _UnwrapAlgPolicy {
+ using _AlgPolicy = _ClassicAlgPolicy;
+ using _Comp = _CompT;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
+ _Comp __get_comp(_Comp __comp) { return __comp; }
+};
+
+// Unwraps a `_WrapAlgPolicy` struct.
+template <class... _Ts>
+struct _UnwrapAlgPolicy<_WrapAlgPolicy<_Ts...> > {
+ using _Wrapped = _WrapAlgPolicy<_Ts...>;
+ using _AlgPolicy = typename _Wrapped::_AlgPolicy;
+ using _Comp = typename _Wrapped::_Comp;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
+ _Comp __get_comp(_Wrapped& __w) { return __w.__comp; }
+};
+
// stable, 2-3 compares, 0-2 swaps
-template <class _Compare, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned
-__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c)
-{
- unsigned __r = 0;
- if (!__c(*__y, *__x)) // if x <= y
- {
- if (!__c(*__z, *__y)) // if y <= z
- return __r; // x <= y && y <= z
- // x <= y && y > z
- swap(*__y, *__z); // x <= z && y < z
- __r = 1;
- if (__c(*__y, *__x)) // if x > y
- {
- swap(*__x, *__y); // x < y && y <= z
- __r = 2;
- }
- return __r; // x <= y && y < z
- }
- if (__c(*__z, *__y)) // x > y, if y > z
- {
- swap(*__x, *__z); // x < y && y < z
- __r = 1;
- return __r;
- }
- swap(*__x, *__y); // x > y && y <= z
- __r = 1; // x < y && x <= z
- if (__c(*__z, *__y)) // if y > z
+template <class _AlgPolicy, class _Compare, class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z,
+ _Compare __c) {
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ unsigned __r = 0;
+ if (!__c(*__y, *__x)) // if x <= y
+ {
+ if (!__c(*__z, *__y)) // if y <= z
+ return __r; // x <= y && y <= z
+ // x <= y && y > z
+ _Ops::iter_swap(__y, __z); // x <= z && y < z
+ __r = 1;
+ if (__c(*__y, *__x)) // if x > y
{
- swap(*__y, *__z); // x <= y && y < z
- __r = 2;
+ _Ops::iter_swap(__x, __y); // x < y && y <= z
+ __r = 2;
}
+ return __r; // x <= y && y < z
+ }
+ if (__c(*__z, *__y)) // x > y, if y > z
+ {
+ _Ops::iter_swap(__x, __z); // x < y && y < z
+ __r = 1;
return __r;
-} // x <= y && y <= z
+ }
+ _Ops::iter_swap(__x, __y); // x > y && y <= z
+ __r = 1; // x < y && x <= z
+ if (__c(*__z, *__y)) // if y > z
+ {
+ _Ops::iter_swap(__y, __z); // x <= y && y < z
+ __r = 2;
+ }
+ return __r;
+} // x <= y && y <= z
// stable, 3-6 compares, 0-5 swaps
-template <class _Compare, class _ForwardIterator>
-unsigned
-__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
- _ForwardIterator __x4, _Compare __c)
-{
- unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c);
- if (__c(*__x4, *__x3))
- {
- swap(*__x3, *__x4);
+template <class _AlgPolicy, class _Compare, class _ForwardIterator>
+unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4,
+ _Compare __c) {
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ unsigned __r = std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
+ if (__c(*__x4, *__x3)) {
+ _Ops::iter_swap(__x3, __x4);
+ ++__r;
+ if (__c(*__x3, *__x2)) {
+ _Ops::iter_swap(__x2, __x3);
+ ++__r;
+ if (__c(*__x2, *__x1)) {
+ _Ops::iter_swap(__x1, __x2);
++__r;
- if (__c(*__x3, *__x2))
- {
- swap(*__x2, *__x3);
- ++__r;
- if (__c(*__x2, *__x1))
- {
- swap(*__x1, *__x2);
- ++__r;
- }
- }
+ }
}
- return __r;
+ }
+ return __r;
}
// stable, 4-10 compares, 0-9 swaps
-template <class _Compare, class _ForwardIterator>
-_LIBCPP_HIDDEN
-unsigned
-__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
- _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)
-{
- unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
- if (__c(*__x5, *__x4))
- {
- swap(*__x4, *__x5);
+template <class _WrappedComp, class _ForwardIterator>
+_LIBCPP_HIDDEN unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
+ _ForwardIterator __x4, _ForwardIterator __x5, _WrappedComp __wrapped_comp) {
+ using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
+ using _AlgPolicy = typename _Unwrap::_AlgPolicy;
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ using _Compare = typename _Unwrap::_Comp;
+ _Compare __c = _Unwrap::__get_comp(__wrapped_comp);
+
+ unsigned __r = std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
+ if (__c(*__x5, *__x4)) {
+ _Ops::iter_swap(__x4, __x5);
+ ++__r;
+ if (__c(*__x4, *__x3)) {
+ _Ops::iter_swap(__x3, __x4);
+ ++__r;
+ if (__c(*__x3, *__x2)) {
+ _Ops::iter_swap(__x2, __x3);
++__r;
- if (__c(*__x4, *__x3))
- {
- swap(*__x3, *__x4);
- ++__r;
- if (__c(*__x3, *__x2))
- {
- swap(*__x2, *__x3);
- ++__r;
- if (__c(*__x2, *__x1))
- {
- swap(*__x1, *__x2);
- ++__r;
- }
- }
+ if (__c(*__x2, *__x1)) {
+ _Ops::iter_swap(__x1, __x2);
+ ++__r;
}
+ }
}
- return __r;
+ }
+ return __r;
+}
+
+template <class _AlgPolicy, class _Compare, class _ForwardIterator>
+_LIBCPP_HIDDEN unsigned __sort5_wrap_policy(
+ _ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5,
+ _Compare __c) {
+ using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
+ _WrappedComp __wrapped_comp(__c);
+ return std::__sort5<_WrappedComp>(
+ std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __wrapped_comp);
+}
+
+// The comparator being simple is a prerequisite for using the branchless optimization.
+template <class _Tp>
+struct __is_simple_comparator : false_type {};
+template <class _Tp>
+struct __is_simple_comparator<__less<_Tp>&> : true_type {};
+template <class _Tp>
+struct __is_simple_comparator<less<_Tp>&> : true_type {};
+template <class _Tp>
+struct __is_simple_comparator<greater<_Tp>&> : true_type {};
+#if _LIBCPP_STD_VER > 17
+template <>
+struct __is_simple_comparator<ranges::less&> : true_type {};
+template <>
+struct __is_simple_comparator<ranges::greater&> : true_type {};
+#endif
+
+template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type>
+using __use_branchless_sort =
+ integral_constant<bool, __is_cpp17_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) &&
+ is_arithmetic<_Tp>::value && __is_simple_comparator<_Compare>::value>;
+
+// Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.
+template <class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {
+ // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
+ using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
+ bool __r = __c(*__x, *__y);
+ value_type __tmp = __r ? *__x : *__y;
+ *__y = __r ? *__y : *__x;
+ *__x = __tmp;
+}
+
+// Ensures that *__x, *__y and *__z are ordered according to the comparator __c,
+// under the assumption that *__y and *__z are already ordered.
+template <class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI void __partially_sorted_swap(_RandomAccessIterator __x, _RandomAccessIterator __y,
+ _RandomAccessIterator __z, _Compare __c) {
+ // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
+ using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
+ bool __r = __c(*__z, *__x);
+ value_type __tmp = __r ? *__z : *__x;
+ *__z = __r ? *__x : *__z;
+ __r = __c(__tmp, *__y);
+ *__x = __r ? *__x : *__y;
+ *__y = __r ? *__y : __tmp;
+}
+
+template <class, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
+ _Compare __c) {
+ _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);
+ _VSTD::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
+}
+
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
+ _Compare __c) {
+ std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
+}
+
+template <class, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
+ _RandomAccessIterator __x4, _Compare __c) {
+ _VSTD::__cond_swap<_Compare>(__x1, __x3, __c);
+ _VSTD::__cond_swap<_Compare>(__x2, __x4, __c);
+ _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);
+ _VSTD::__cond_swap<_Compare>(__x3, __x4, __c);
+ _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);
+}
+
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
+ _RandomAccessIterator __x4, _Compare __c) {
+ std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
+}
+
+template <class, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
+ _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {
+ _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);
+ _VSTD::__cond_swap<_Compare>(__x4, __x5, __c);
+ _VSTD::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);
+ _VSTD::__cond_swap<_Compare>(__x2, __x5, __c);
+ _VSTD::__partially_sorted_swap<_Compare>(__x1, __x3, __x4, __c);
+ _VSTD::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c);
+}
+
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
+ _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {
+ std::__sort5_wrap_policy<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __x5, __c);
}
// Assumes size > 0
-template <class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 void
-__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
-{
- _BidirectionalIterator __lm1 = __last;
- for (--__lm1; __first != __lm1; ++__first)
- {
- _BidirectionalIterator __i = _VSTD::min_element(__first, __last, __comp);
- if (__i != __first)
- swap(*__first, *__i);
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
+ _Compare __comp) {
+ _BidirectionalIterator __lm1 = __last;
+ for (--__lm1; __first != __lm1; ++__first) {
+ _BidirectionalIterator __i = std::__min_element<_Compare>(__first, __last, __comp);
+ if (__i != __first)
+ _IterOps<_AlgPolicy>::iter_swap(__first, __i);
+ }
+}
+
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
+void __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ if (__first != __last) {
+ _BidirectionalIterator __i = __first;
+ for (++__i; __i != __last; ++__i) {
+ _BidirectionalIterator __j = __i;
+ value_type __t(_Ops::__iter_move(__j));
+ for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
+ *__j = _Ops::__iter_move(__k);
+ *__j = _VSTD::move(__t);
}
+ }
}
-template <class _Compare, class _BidirectionalIterator>
-void
-__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- if (__first != __last)
- {
- _BidirectionalIterator __i = __first;
- for (++__i; __i != __last; ++__i)
- {
- _BidirectionalIterator __j = __i;
- value_type __t(_VSTD::move(*__j));
- for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
- *__j = _VSTD::move(*__k);
- *__j = _VSTD::move(__t);
- }
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ _RandomAccessIterator __j = __first + difference_type(2);
+ std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp);
+ for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {
+ if (__comp(*__i, *__j)) {
+ value_type __t(_Ops::__iter_move(__i));
+ _RandomAccessIterator __k = __j;
+ __j = __i;
+ do {
+ *__j = _Ops::__iter_move(__k);
+ __j = __k;
+ } while (__j != __first && __comp(__t, *--__k));
+ *__j = _VSTD::move(__t);
}
+ __j = __i;
+ }
}
-template <class _Compare, class _RandomAccessIterator>
-void
-__insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- _RandomAccessIterator __j = __first+difference_type(2);
- _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp);
- for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i)
- {
- if (__comp(*__i, *__j))
- {
- value_type __t(_VSTD::move(*__i));
- _RandomAccessIterator __k = __j;
- __j = __i;
- do
- {
- *__j = _VSTD::move(*__k);
- __j = __k;
- } while (__j != __first && __comp(__t, *--__k));
- *__j = _VSTD::move(__t);
- }
- __j = __i;
+template <class _WrappedComp, class _RandomAccessIterator>
+bool __insertion_sort_incomplete(
+ _RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
+ using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
+ using _AlgPolicy = typename _Unwrap::_AlgPolicy;
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ using _Compare = typename _Unwrap::_Comp;
+ _Compare __comp = _Unwrap::__get_comp(__wrapped_comp);
+
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ switch (__last - __first) {
+ case 0:
+ case 1:
+ return true;
+ case 2:
+ if (__comp(*--__last, *__first))
+ _IterOps<_AlgPolicy>::iter_swap(__first, __last);
+ return true;
+ case 3:
+ std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
+ return true;
+ case 4:
+ std::__sort4_maybe_branchless<_AlgPolicy, _Compare>(
+ __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);
+ return true;
+ case 5:
+ std::__sort5_maybe_branchless<_AlgPolicy, _Compare>(
+ __first, __first + difference_type(1), __first + difference_type(2), __first + difference_type(3),
+ --__last, __comp);
+ return true;
+ }
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ _RandomAccessIterator __j = __first + difference_type(2);
+ std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp);
+ const unsigned __limit = 8;
+ unsigned __count = 0;
+ for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {
+ if (__comp(*__i, *__j)) {
+ value_type __t(_Ops::__iter_move(__i));
+ _RandomAccessIterator __k = __j;
+ __j = __i;
+ do {
+ *__j = _Ops::__iter_move(__k);
+ __j = __k;
+ } while (__j != __first && __comp(__t, *--__k));
+ *__j = _VSTD::move(__t);
+ if (++__count == __limit)
+ return ++__i == __last;
}
+ __j = __i;
+ }
+ return true;
}
-template <class _Compare, class _RandomAccessIterator>
-bool
-__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- switch (__last - __first)
- {
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
+void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) {
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ if (__first1 != __last1) {
+ __destruct_n __d(0);
+ unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
+ value_type* __last2 = __first2;
+ ::new ((void*)__last2) value_type(_Ops::__iter_move(__first1));
+ __d.template __incr<value_type>();
+ for (++__last2; ++__first1 != __last1; ++__last2) {
+ value_type* __j2 = __last2;
+ value_type* __i2 = __j2;
+ if (__comp(*__first1, *--__i2)) {
+ ::new ((void*)__j2) value_type(std::move(*__i2));
+ __d.template __incr<value_type>();
+ for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
+ *__j2 = std::move(*__i2);
+ *__j2 = _Ops::__iter_move(__first1);
+ } else {
+ ::new ((void*)__j2) value_type(_Ops::__iter_move(__first1));
+ __d.template __incr<value_type>();
+ }
+ }
+ __h.release();
+ }
+}
+
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __depth) {
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ const difference_type __limit =
+ is_trivially_copy_constructible<value_type>::value && is_trivially_copy_assignable<value_type>::value ? 30 : 6;
+ while (true) {
+ __restart:
+ difference_type __len = __last - __first;
+ switch (__len) {
case 0:
case 1:
- return true;
+ return;
case 2:
- if (__comp(*--__last, *__first))
- swap(*__first, *__last);
- return true;
+ if (__comp(*--__last, *__first))
+ _IterOps<_AlgPolicy>::iter_swap(__first, __last);
+ return;
case 3:
- _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp);
- return true;
+ std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
+ return;
case 4:
- _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp);
- return true;
+ std::__sort4_maybe_branchless<_AlgPolicy, _Compare>(
+ __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);
+ return;
case 5:
- _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp);
- return true;
+ std::__sort5_maybe_branchless<_AlgPolicy, _Compare>(
+ __first, __first + difference_type(1), __first + difference_type(2), __first + difference_type(3),
+ --__last, __comp);
+ return;
}
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- _RandomAccessIterator __j = __first+difference_type(2);
- _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp);
- const unsigned __limit = 8;
- unsigned __count = 0;
- for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i)
- {
- if (__comp(*__i, *__j))
- {
- value_type __t(_VSTD::move(*__i));
- _RandomAccessIterator __k = __j;
- __j = __i;
- do
- {
- *__j = _VSTD::move(*__k);
- __j = __k;
- } while (__j != __first && __comp(__t, *--__k));
- *__j = _VSTD::move(__t);
- if (++__count == __limit)
- return ++__i == __last;
- }
- __j = __i;
+ if (__len <= __limit) {
+ std::__insertion_sort_3<_AlgPolicy, _Compare>(__first, __last, __comp);
+ return;
}
- return true;
-}
-
-template <class _Compare, class _BidirectionalIterator>
-void
-__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
- typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- if (__first1 != __last1)
+ // __len > 5
+ if (__depth == 0) {
+ // Fallback to heap sort as Introsort suggests.
+ std::__partial_sort<_AlgPolicy, _Compare>(__first, __last, __last, __comp);
+ return;
+ }
+ --__depth;
+ _RandomAccessIterator __m = __first;
+ _RandomAccessIterator __lm1 = __last;
+ --__lm1;
+ unsigned __n_swaps;
{
- __destruct_n __d(0);
- unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
- value_type* __last2 = __first2;
- ::new ((void*)__last2) value_type(_VSTD::move(*__first1));
- __d.template __incr<value_type>();
- for (++__last2; ++__first1 != __last1; ++__last2)
- {
- value_type* __j2 = __last2;
- value_type* __i2 = __j2;
- if (__comp(*__first1, *--__i2))
- {
- ::new ((void*)__j2) value_type(_VSTD::move(*__i2));
- __d.template __incr<value_type>();
- for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
- *__j2 = _VSTD::move(*__i2);
- *__j2 = _VSTD::move(*__first1);
- }
- else
- {
- ::new ((void*)__j2) value_type(_VSTD::move(*__first1));
- __d.template __incr<value_type>();
- }
- }
- __h.release();
+ difference_type __delta;
+ if (__len >= 1000) {
+ __delta = __len / 2;
+ __m += __delta;
+ __delta /= 2;
+ __n_swaps = std::__sort5_wrap_policy<_AlgPolicy, _Compare>(
+ __first, __first + __delta, __m, __m + __delta, __lm1, __comp);
+ } else {
+ __delta = __len / 2;
+ __m += __delta;
+ __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, __lm1, __comp);
+ }
}
-}
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __depth)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- const difference_type __limit = is_trivially_copy_constructible<value_type>::value &&
- is_trivially_copy_assignable<value_type>::value ? 30 : 6;
- while (true)
+ // *__m is median
+ // partition [__first, __m) < *__m and *__m <= [__m, __last)
+ // (this inhibits tossing elements equivalent to __m around unnecessarily)
+ _RandomAccessIterator __i = __first;
+ _RandomAccessIterator __j = __lm1;
+ // j points beyond range to be tested, *__m is known to be <= *__lm1
+ // The search going up is known to be guarded but the search coming down isn't.
+ // Prime the downward search with a guard.
+ if (!__comp(*__i, *__m)) // if *__first == *__m
{
- __restart:
- difference_type __len = __last - __first;
- switch (__len)
- {
- case 0:
- case 1:
- return;
- case 2:
- if (__comp(*--__last, *__first))
- swap(*__first, *__last);
- return;
- case 3:
- _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp);
- return;
- case 4:
- _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp);
- return;
- case 5:
- _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp);
- return;
- }
- if (__len <= __limit)
- {
- _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
- return;
- }
- // __len > 5
- if (__depth == 0)
- {
- // Fallback to heap sort as Introsort suggests.
- _VSTD::__partial_sort<_Compare>(__first, __last, __last, __comp);
- return;
- }
- --__depth;
- _RandomAccessIterator __m = __first;
- _RandomAccessIterator __lm1 = __last;
- --__lm1;
- unsigned __n_swaps;
- {
- difference_type __delta;
- if (__len >= 1000)
- {
- __delta = __len/2;
- __m += __delta;
- __delta /= 2;
- __n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp);
- }
- else
- {
- __delta = __len/2;
- __m += __delta;
- __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp);
- }
- }
- // *__m is median
- // partition [__first, __m) < *__m and *__m <= [__m, __last)
- // (this inhibits tossing elements equivalent to __m around unnecessarily)
- _RandomAccessIterator __i = __first;
- _RandomAccessIterator __j = __lm1;
- // j points beyond range to be tested, *__m is known to be <= *__lm1
- // The search going up is known to be guarded but the search coming down isn't.
- // Prime the downward search with a guard.
- if (!__comp(*__i, *__m)) // if *__first == *__m
- {
- // *__first == *__m, *__first doesn't go in first part
- // manually guard downward moving __j against __i
- while (true)
- {
- if (__i == --__j)
- {
- // *__first == *__m, *__m <= all other elements
- // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
- ++__i; // __first + 1
- __j = __last;
- if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
- {
- while (true)
- {
- if (__i == __j)
- return; // [__first, __last) all equivalent elements
- if (__comp(*__first, *__i))
- {
- swap(*__i, *__j);
- ++__n_swaps;
- ++__i;
- break;
- }
- ++__i;
- }
- }
- // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
- if (__i == __j)
- return;
- while (true)
- {
- while (!__comp(*__first, *__i))
- ++__i;
- while (__comp(*__first, *--__j))
- ;
- if (__i >= __j)
- break;
- swap(*__i, *__j);
- ++__n_swaps;
- ++__i;
- }
- // [__first, __i) == *__first and *__first < [__i, __last)
- // The first part is sorted, sort the second part
- // _VSTD::__sort<_Compare>(__i, __last, __comp);
- __first = __i;
- goto __restart;
- }
- if (__comp(*__j, *__m))
- {
- swap(*__i, *__j);
- ++__n_swaps;
- break; // found guard for downward moving __j, now use unguarded partition
- }
- }
- }
- // It is known that *__i < *__m
- ++__i;
- // j points beyond range to be tested, *__m is known to be <= *__lm1
- // if not yet partitioned...
- if (__i < __j)
- {
- // known that *(__i - 1) < *__m
- // known that __i <= __m
- while (true)
- {
- // __m still guards upward moving __i
- while (__comp(*__i, *__m))
- ++__i;
- // It is now known that a guard exists for downward moving __j
- while (!__comp(*--__j, *__m))
- ;
- if (__i > __j)
- break;
- swap(*__i, *__j);
+ // *__first == *__m, *__first doesn't go in first part
+ // manually guard downward moving __j against __i
+ while (true) {
+ if (__i == --__j) {
+ // *__first == *__m, *__m <= all other elements
+ // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
+ ++__i; // __first + 1
+ __j = __last;
+ if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
+ {
+ while (true) {
+ if (__i == __j)
+ return; // [__first, __last) all equivalent elements
+ if (__comp(*__first, *__i)) {
+ _Ops::iter_swap(__i, __j);
++__n_swaps;
- // It is known that __m != __j
- // If __m just moved, follow it
- if (__m == __i)
- __m = __j;
++__i;
+ break;
+ }
+ ++__i;
}
- }
- // [__first, __i) < *__m and *__m <= [__i, __last)
- if (__i != __m && __comp(*__m, *__i))
- {
- swap(*__i, *__m);
+ }
+ // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
+ if (__i == __j)
+ return;
+ while (true) {
+ while (!__comp(*__first, *__i))
+ ++__i;
+ while (__comp(*__first, *--__j))
+ ;
+ if (__i >= __j)
+ break;
+ _Ops::iter_swap(__i, __j);
++__n_swaps;
+ ++__i;
+ }
+ // [__first, __i) == *__first and *__first < [__i, __last)
+ // The first part is sorted, sort the second part
+ // _VSTD::__sort<_Compare>(__i, __last, __comp);
+ __first = __i;
+ goto __restart;
}
- // [__first, __i) < *__i and *__i <= [__i+1, __last)
- // If we were given a perfect partition, see if insertion sort is quick...
- if (__n_swaps == 0)
- {
- bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp);
- if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+difference_type(1), __last, __comp))
- {
- if (__fs)
- return;
- __last = __i;
- continue;
- }
- else
- {
- if (__fs)
- {
- __first = ++__i;
- continue;
- }
- }
+ if (__comp(*__j, *__m)) {
+ _Ops::iter_swap(__i, __j);
+ ++__n_swaps;
+ break; // found guard for downward moving __j, now use unguarded partition
}
- // sort smaller range with recursive call and larger with tail recursion elimination
- if (__i - __first < __last - __i)
- {
- _VSTD::__introsort<_Compare>(__first, __i, __comp, __depth);
+ }
+ }
+ // It is known that *__i < *__m
+ ++__i;
+ // j points beyond range to be tested, *__m is known to be <= *__lm1
+ // if not yet partitioned...
+ if (__i < __j) {
+ // known that *(__i - 1) < *__m
+ // known that __i <= __m
+ while (true) {
+ // __m still guards upward moving __i
+ while (__comp(*__i, *__m))
+ ++__i;
+ // It is now known that a guard exists for downward moving __j
+ while (!__comp(*--__j, *__m))
+ ;
+ if (__i > __j)
+ break;
+ _Ops::iter_swap(__i, __j);
+ ++__n_swaps;
+ // It is known that __m != __j
+ // If __m just moved, follow it
+ if (__m == __i)
+ __m = __j;
+ ++__i;
+ }
+ }
+ // [__first, __i) < *__m and *__m <= [__i, __last)
+ if (__i != __m && __comp(*__m, *__i)) {
+ _Ops::iter_swap(__i, __m);
+ ++__n_swaps;
+ }
+ // [__first, __i) < *__i and *__i <= [__i+1, __last)
+ // If we were given a perfect partition, see if insertion sort is quick...
+ if (__n_swaps == 0) {
+ using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
+ _WrappedComp __wrapped_comp(__comp);
+ bool __fs = std::__insertion_sort_incomplete<_WrappedComp>(__first, __i, __wrapped_comp);
+ if (std::__insertion_sort_incomplete<_WrappedComp>(__i + difference_type(1), __last, __wrapped_comp)) {
+ if (__fs)
+ return;
+ __last = __i;
+ continue;
+ } else {
+ if (__fs) {
__first = ++__i;
+ continue;
}
- else
- {
- _VSTD::__introsort<_Compare>(__i + difference_type(1), __last, __comp, __depth);
- __last = __i;
- }
+ }
}
+ // sort smaller range with recursive call and larger with tail recursion elimination
+ if (__i - __first < __last - __i) {
+ std::__introsort<_AlgPolicy, _Compare>(__first, __i, __comp, __depth);
+ __first = ++__i;
+ } else {
+ std::__introsort<_AlgPolicy, _Compare>(__i + difference_type(1), __last, __comp, __depth);
+ __last = __i;
+ }
+ }
}
template <typename _Number>
inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
+ if (__n == 0)
+ return 0;
+ if (sizeof(__n) <= sizeof(unsigned))
+ return sizeof(unsigned) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned>(__n));
+ if (sizeof(__n) <= sizeof(unsigned long))
+ return sizeof(unsigned long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long>(__n));
+ if (sizeof(__n) <= sizeof(unsigned long long))
+ return sizeof(unsigned long long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long long>(__n));
+
_Number __log2 = 0;
while (__n > 1) {
__log2++;
@@ -475,80 +615,89 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
return __log2;
}
-template <class _Compare, class _RandomAccessIterator>
-void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+template <class _WrappedComp, class _RandomAccessIterator>
+void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
difference_type __depth_limit = 2 * __log2i(__last - __first);
- _VSTD::__introsort<_Compare>(__first, __last, __comp, __depth_limit);
+
+ using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
+ using _AlgPolicy = typename _Unwrap::_AlgPolicy;
+ using _Compare = typename _Unwrap::_Comp;
+ _Compare __comp = _Unwrap::__get_comp(__wrapped_comp);
+ std::__introsort<_AlgPolicy, _Compare>(__first, __last, __comp, __depth_limit);
}
template <class _Compare, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-__sort(_Tp** __first, _Tp** __last, __less<_Tp*>&)
-{
- __less<uintptr_t> __comp;
- _VSTD::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp);
+inline _LIBCPP_INLINE_VISIBILITY void __sort(_Tp** __first, _Tp** __last, __less<_Tp*>&) {
+ __less<uintptr_t> __comp;
+ std::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp);
}
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&))
+extern template _LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
+extern template _LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
#endif
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
-
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&))
+extern template _LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
+extern template _LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
+
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
#endif
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
-
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&))
-
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last);
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
+extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
+
+extern template _LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
+
+template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
+ std::__debug_randomize_range<_AlgPolicy>(__first, __last);
+
+ using _Comp_ref = typename __comp_ref_type<_Comp>::type;
if (__libcpp_is_constant_evaluated()) {
- _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp));
+ std::__partial_sort<_AlgPolicy>(__first, __last, __last, __comp);
+
} else {
- _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp));
+ using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Comp_ref>::type;
+ _Comp_ref __comp_ref(__comp);
+ _WrappedComp __wrapped_comp(__comp_ref);
+ std::__sort<_WrappedComp>(std::__unwrap_iter(__first), std::__unwrap_iter(__last), __wrapped_comp);
}
}
+template <class _RandomAccessIterator, class _Comp>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
+ std::__sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
+}
+
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
+ std::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/sort_heap.h
@@ -11,41 +11,44 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/pop_heap.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <__utility/move.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 void
-__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
- _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n);
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
+ using _CompRef = typename __comp_ref_type<_Compare>::type;
+ _CompRef __comp_ref = __comp;
+
+ using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
+ for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
+ std::__pop_heap<_AlgPolicy>(__first, __last, __comp_ref, __n);
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp);
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
+ static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
+
+ std::__sort_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
}
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::sort_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
+ std::sort_heap(std::move(__first), std::move(__last),
+ __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/stable_partition.h
@@ -9,23 +9,28 @@
#ifndef _LIBCPP___ALGORITHM_STABLE_PARTITION_H
#define _LIBCPP___ALGORITHM_STABLE_PARTITION_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/rotate.h>
#include <__config>
+#include <__iterator/advance.h>
+#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
#include <memory>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
+template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
_ForwardIterator
-__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
+__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
_Distance __len, _Pair __p, forward_iterator_tag __fit)
{
+ using _Ops = _IterOps<_AlgPolicy>;
+
// *__first is known to be false
// __len >= 1
if (__len == 1)
@@ -35,7 +40,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
_ForwardIterator __m = __first;
if (__pred(*++__m))
{
- swap(*__first, *__m);
+ _Ops::iter_swap(__first, __m);
return __m;
}
return __first;
@@ -48,7 +53,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
// Move the falses into the temporary buffer, and the trues to the front of the line
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
- ::new ((void*)__t) value_type(_VSTD::move(*__first));
+ ::new ((void*)__t) value_type(_Ops::__iter_move(__first));
__d.template __incr<value_type>();
++__t;
_ForwardIterator __i = __first;
@@ -56,12 +61,12 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
{
if (__pred(*__i))
{
- *__first = _VSTD::move(*__i);
+ *__first = _Ops::__iter_move(__i);
++__first;
}
else
{
- ::new ((void*)__t) value_type(_VSTD::move(*__i));
+ ::new ((void*)__t) value_type(_Ops::__iter_move(__i));
__d.template __incr<value_type>();
++__t;
}
@@ -70,7 +75,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
// Move falses back into range, but don't mess up __first which points to first false
__i = __first;
for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
- *__i = _VSTD::move(*__t2);
+ *__i = _Ops::__iter_move(__t2);
// __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
return __first;
}
@@ -78,11 +83,12 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
// __len >= 3
_ForwardIterator __m = __first;
_Distance __len2 = __len / 2; // __len2 >= 2
- _VSTD::advance(__m, __len2);
+ _Ops::advance(__m, __len2);
// recurse on [__first, __m), *__first know to be false
// F?????????????????
// f m l
- _ForwardIterator __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m, __pred, __len2, __p, __fit);
+ _ForwardIterator __first_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
+ __first, __m, __pred, __len2, __p, __fit);
// TTTFFFFF??????????
// f ff m l
// recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
@@ -97,18 +103,19 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
}
// TTTFFFFFTTTF??????
// f ff m m1 l
- __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __fit);
+ __second_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
+ __m1, __last, __pred, __len_half, __p, __fit);
__second_half_done:
// TTTFFFFFTTTTTFFFFF
// f ff m sf l
- return _VSTD::rotate(__first_false, __m, __second_false);
+ return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __fit);
// TTTTTTTTFFFFFFFFFF
// |
}
-template <class _Predicate, class _ForwardIterator>
+template <class _AlgPolicy, class _Predicate, class _ForwardIterator>
_ForwardIterator
-__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
+__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
forward_iterator_tag)
{
const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment
@@ -125,28 +132,34 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
// *__first is known to be false
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
- difference_type __len = _VSTD::distance(__first, __last);
+ difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last);
pair<value_type*, ptrdiff_t> __p(0, 0);
unique_ptr<value_type, __return_temporary_buffer> __h;
if (__len >= __alloc_limit)
{
+// TODO: Remove the use of std::get_temporary_buffer
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
__p = _VSTD::get_temporary_buffer<value_type>(__len);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
__h.reset(__p.first);
}
- return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, forward_iterator_tag());
+ return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
+ std::move(__first), std::move(__last), __pred, __len, __p, forward_iterator_tag());
}
-template <class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>
+template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>
_BidirectionalIterator
-__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+__stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
_Distance __len, _Pair __p, bidirectional_iterator_tag __bit)
{
+ using _Ops = _IterOps<_AlgPolicy>;
+
// *__first is known to be false
// *__last is known to be true
// __len >= 2
if (__len == 2)
{
- swap(*__first, *__last);
+ _Ops::iter_swap(__first, __last);
return __last;
}
if (__len == 3)
@@ -154,12 +167,12 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
_BidirectionalIterator __m = __first;
if (__pred(*++__m))
{
- swap(*__first, *__m);
- swap(*__m, *__last);
+ _Ops::iter_swap(__first, __m);
+ _Ops::iter_swap(__m, __last);
return __last;
}
- swap(*__m, *__last);
- swap(*__first, *__m);
+ _Ops::iter_swap(__m, __last);
+ _Ops::iter_swap(__first, __m);
return __m;
}
if (__len <= __p.second)
@@ -170,7 +183,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
// Move the falses into the temporary buffer, and the trues to the front of the line
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
- ::new ((void*)__t) value_type(_VSTD::move(*__first));
+ ::new ((void*)__t) value_type(_Ops::__iter_move(__first));
__d.template __incr<value_type>();
++__t;
_BidirectionalIterator __i = __first;
@@ -178,23 +191,23 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
{
if (__pred(*__i))
{
- *__first = _VSTD::move(*__i);
+ *__first = _Ops::__iter_move(__i);
++__first;
}
else
{
- ::new ((void*)__t) value_type(_VSTD::move(*__i));
+ ::new ((void*)__t) value_type(_Ops::__iter_move(__i));
__d.template __incr<value_type>();
++__t;
}
}
// move *__last, known to be true
- *__first = _VSTD::move(*__i);
+ *__first = _Ops::__iter_move(__i);
__i = ++__first;
// All trues now at start of range, all falses in buffer
// Move falses back into range, but don't mess up __first which points to first false
for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
- *__i = _VSTD::move(*__t2);
+ *__i = _Ops::__iter_move(__t2);
// __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
return __first;
}
@@ -202,7 +215,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
// __len >= 4
_BidirectionalIterator __m = __first;
_Distance __len2 = __len / 2; // __len2 >= 2
- _VSTD::advance(__m, __len2);
+ _Ops::advance(__m, __len2);
// recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false
// F????????????????T
// f m l
@@ -217,7 +230,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
}
// F???TFFF?????????T
// f m1 m l
- __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m1, __pred, __len_half, __p, __bit);
+ __first_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
+ __first, __m1, __pred, __len_half, __p, __bit);
__first_half_done:
// TTTFFFFF?????????T
// f ff m l
@@ -234,18 +248,19 @@ __first_half_done:
}
// TTTFFFFFTTTF?????T
// f ff m m1 l
- __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __bit);
+ __second_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
+ __m1, __last, __pred, __len_half, __p, __bit);
__second_half_done:
// TTTFFFFFTTTTTFFFFF
// f ff m sf l
- return _VSTD::rotate(__first_false, __m, __second_false);
+ return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __bit);
// TTTTTTTTFFFFFFFFFF
// |
}
-template <class _Predicate, class _BidirectionalIterator>
+template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator>
_BidirectionalIterator
-__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+__stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
bidirectional_iterator_tag)
{
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
@@ -271,15 +286,27 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
// *__first is known to be false
// *__last is known to be true
// __len >= 2
- difference_type __len = _VSTD::distance(__first, __last) + 1;
+ difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last) + 1;
pair<value_type*, ptrdiff_t> __p(0, 0);
unique_ptr<value_type, __return_temporary_buffer> __h;
if (__len >= __alloc_limit)
{
+// TODO: Remove the use of std::get_temporary_buffer
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
__p = _VSTD::get_temporary_buffer<value_type>(__len);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
__h.reset(__p.first);
}
- return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, bidirectional_iterator_tag());
+ return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
+ std::move(__first), std::move(__last), __pred, __len, __p, bidirectional_iterator_tag());
+}
+
+template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _IterCategory>
+_LIBCPP_HIDE_FROM_ABI
+_ForwardIterator __stable_partition(
+ _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) {
+ return std::__stable_partition_impl<_AlgPolicy, __uncvref_t<_Predicate>&>(
+ std::move(__first), std::move(__last), __pred, __iter_category);
}
template <class _ForwardIterator, class _Predicate>
@@ -287,7 +314,9 @@ inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
- return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+ using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category;
+ return std::__stable_partition<_ClassicAlgPolicy, _Predicate&>(
+ std::move(__first), std::move(__last), __pred, _IterCategory());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/stable_sort.h
@@ -12,25 +12,28 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/inplace_merge.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/sort.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
+#include <__utility/move.h>
#include <memory>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _InputIterator1, class _InputIterator2>
+template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2>
void
__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
{
+ using _Ops = _IterOps<_AlgPolicy>;
+
typedef typename iterator_traits<_InputIterator1>::value_type value_type;
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h(__result, __d);
@@ -39,111 +42,115 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
if (__first1 == __last1)
{
for (; __first2 != __last2; ++__first2, (void) ++__result, __d.template __incr<value_type>())
- ::new ((void*)__result) value_type(_VSTD::move(*__first2));
+ ::new ((void*)__result) value_type(_Ops::__iter_move(__first2));
__h.release();
return;
}
if (__first2 == __last2)
{
for (; __first1 != __last1; ++__first1, (void) ++__result, __d.template __incr<value_type>())
- ::new ((void*)__result) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__result) value_type(_Ops::__iter_move(__first1));
__h.release();
return;
}
if (__comp(*__first2, *__first1))
{
- ::new ((void*)__result) value_type(_VSTD::move(*__first2));
+ ::new ((void*)__result) value_type(_Ops::__iter_move(__first2));
__d.template __incr<value_type>();
++__first2;
}
else
{
- ::new ((void*)__result) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__result) value_type(_Ops::__iter_move(__first1));
__d.template __incr<value_type>();
++__first1;
}
}
}
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
void
__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
+ using _Ops = _IterOps<_AlgPolicy>;
+
for (; __first1 != __last1; ++__result)
{
if (__first2 == __last2)
{
for (; __first1 != __last1; ++__first1, (void) ++__result)
- *__result = _VSTD::move(*__first1);
+ *__result = _Ops::__iter_move(__first1);
return;
}
if (__comp(*__first2, *__first1))
{
- *__result = _VSTD::move(*__first2);
+ *__result = _Ops::__iter_move(__first2);
++__first2;
}
else
{
- *__result = _VSTD::move(*__first1);
+ *__result = _Ops::__iter_move(__first1);
++__first1;
}
}
for (; __first2 != __last2; ++__first2, (void) ++__result)
- *__result = _VSTD::move(*__first2);
+ *__result = _Ops::__iter_move(__first2);
}
-template <class _Compare, class _RandomAccessIterator>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
void
__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size);
-template <class _Compare, class _RandomAccessIterator>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
void
__stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
typename iterator_traits<_RandomAccessIterator>::value_type* __first2)
{
+ using _Ops = _IterOps<_AlgPolicy>;
+
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
switch (__len)
{
case 0:
return;
case 1:
- ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));
return;
case 2:
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
if (__comp(*--__last1, *__first1))
{
- ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
+ ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1));
__d.template __incr<value_type>();
++__first2;
- ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));
}
else
{
- ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));
__d.template __incr<value_type>();
++__first2;
- ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
+ ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1));
}
__h2.release();
return;
}
if (__len <= 8)
{
- _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);
+ std::__insertion_sort_move<_AlgPolicy, _Compare>(__first1, __last1, __first2, __comp);
return;
}
typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
_RandomAccessIterator __m = __first1 + __l2;
- _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);
- _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
- _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);
+ std::__stable_sort<_AlgPolicy, _Compare>(__first1, __m, __comp, __l2, __first2, __l2);
+ std::__stable_sort<_AlgPolicy, _Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
+ std::__merge_move_construct<_AlgPolicy, _Compare>(__first1, __m, __m, __last1, __first2, __comp);
}
template <class _Tp>
@@ -152,7 +159,7 @@ struct __stable_sort_switch
static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value;
};
-template <class _Compare, class _RandomAccessIterator>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
void
__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
@@ -167,12 +174,12 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
return;
case 2:
if (__comp(*--__last, *__first))
- swap(*__first, *__last);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __last);
return;
}
if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))
{
- _VSTD::__insertion_sort<_Compare>(__first, __last, __comp);
+ std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp);
return;
}
typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
@@ -181,11 +188,12 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
{
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
- _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
+ std::__stable_sort_move<_AlgPolicy, _Compare>(__first, __m, __comp, __l2, __buff);
__d.__set(__l2, (value_type*)nullptr);
- _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
+ std::__stable_sort_move<_AlgPolicy, _Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
__d.__set(__len, (value_type*)nullptr);
- _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
+ std::__merge_move_assign<_AlgPolicy, _Compare>(
+ __buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),
// move_iterator<value_type*>(__buff + __l2),
// move_iterator<_RandomAccessIterator>(__buff + __l2),
@@ -193,36 +201,42 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
// __first, __comp);
return;
}
- _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
- _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
- _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
+ std::__stable_sort<_AlgPolicy, _Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
+ std::__stable_sort<_AlgPolicy, _Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
+ std::__inplace_merge<_AlgPolicy>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
+}
+
+template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_HIDE_FROM_ABI
+void __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
+ using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
+ using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
+
+ difference_type __len = __last - __first;
+ pair<value_type*, ptrdiff_t> __buf(0, 0);
+ unique_ptr<value_type, __return_temporary_buffer> __h;
+ if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) {
+// TODO: Remove the use of std::get_temporary_buffer
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ __buf = std::get_temporary_buffer<value_type>(__len);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ __h.reset(__buf.first);
+ }
+
+ using _Comp_ref = typename __comp_ref_type<_Compare>::type;
+ std::__stable_sort<_AlgPolicy, _Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- difference_type __len = __last - __first;
- pair<value_type*, ptrdiff_t> __buf(0, 0);
- unique_ptr<value_type, __return_temporary_buffer> __h;
- if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value))
- {
- __buf = _VSTD::get_temporary_buffer<value_type>(__len);
- __h.reset(__buf.first);
- }
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
+inline _LIBCPP_HIDE_FROM_ABI
+void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ std::__stable_sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
}
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+inline _LIBCPP_HIDE_FROM_ABI
+void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
+ std::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/swap_ranges.h
@@ -11,10 +11,9 @@
#include <__config>
#include <__utility/swap.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/transform.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__algorithm/unique.h
@@ -11,44 +11,48 @@
#include <__algorithm/adjacent_find.h>
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
// unique
+template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 std::pair<_Iter, _Iter>
+__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
+ __first = std::__adjacent_find(__first, __last, __pred);
+ if (__first != __last) {
+ // ... a a ? ...
+ // f i
+ _Iter __i = __first;
+ for (++__i; ++__i != __last;)
+ if (!__pred(*__first, *__i))
+ *++__first = _IterOps<_AlgPolicy>::__iter_move(__i);
+ ++__first;
+ return std::pair<_Iter, _Iter>(std::move(__first), std::move(__i));
+ }
+ return std::pair<_Iter, _Iter>(__first, __first);
+}
+
template <class _ForwardIterator, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
-{
- __first = _VSTD::adjacent_find<_ForwardIterator, _BinaryPredicate&>(__first, __last, __pred);
- if (__first != __last)
- {
- // ... a a ? ...
- // f i
- _ForwardIterator __i = __first;
- for (++__i; ++__i != __last;)
- if (!__pred(*__first, *__i))
- *++__first = _VSTD::move(*__i);
- ++__first;
- }
- return __first;
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
+ return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-unique(_ForwardIterator __first, _ForwardIterator __last)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::unique(__first, __last, __equal_to<__v>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last) {
+ typedef typename iterator_traits<_ForwardIterator>::value_type __v;
+ return std::unique(__first, __last, __equal_to<__v>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unique_copy.h
@@ -10,98 +10,114 @@
#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <utility>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/is_same.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BinaryPredicate, class _InputIterator, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
- input_iterator_tag, output_iterator_tag)
-{
- if (__first != __last)
- {
- typename iterator_traits<_InputIterator>::value_type __t(*__first);
+namespace __unique_copy_tags {
+
+struct __reread_from_input_tag {};
+struct __reread_from_output_tag {};
+struct __read_from_tmp_value_tag {};
+
+} // namespace __unique_copy_tags
+
+template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _OutputIterator>
+__unique_copy(_InputIterator __first,
+ _Sent __last,
+ _OutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__read_from_tmp_value_tag) {
+ if (__first != __last) {
+ typename _IterOps<_AlgPolicy>::template __value_type<_InputIterator> __t(*__first);
+ *__result = __t;
+ ++__result;
+ while (++__first != __last) {
+ if (!__pred(__t, *__first)) {
+ __t = *__first;
*__result = __t;
++__result;
- while (++__first != __last)
- {
- if (!__pred(__t, *__first))
- {
- __t = *__first;
- *__result = __t;
- ++__result;
- }
- }
+ }
}
- return __result;
+ }
+ return pair<_InputIterator, _OutputIterator>(std::move(__first), std::move(__result));
}
-template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
- forward_iterator_tag, output_iterator_tag)
-{
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- *__result = *__i;
+template <class _AlgPolicy, class _BinaryPredicate, class _ForwardIterator, class _Sent, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_ForwardIterator, _OutputIterator>
+__unique_copy(_ForwardIterator __first,
+ _Sent __last,
+ _OutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__reread_from_input_tag) {
+ if (__first != __last) {
+ _ForwardIterator __i = __first;
+ *__result = *__i;
+ ++__result;
+ while (++__first != __last) {
+ if (!__pred(*__i, *__first)) {
+ *__result = *__first;
++__result;
- while (++__first != __last)
- {
- if (!__pred(*__i, *__first))
- {
- *__result = *__first;
- ++__result;
- __i = __first;
- }
- }
+ __i = __first;
+ }
}
- return __result;
+ }
+ return pair<_ForwardIterator, _OutputIterator>(std::move(__first), std::move(__result));
}
-template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred,
- input_iterator_tag, forward_iterator_tag)
-{
- if (__first != __last)
- {
- *__result = *__first;
- while (++__first != __last)
- if (!__pred(*__result, *__first))
- *++__result = *__first;
- ++__result;
- }
- return __result;
+template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _InputAndOutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _InputAndOutputIterator>
+__unique_copy(_InputIterator __first,
+ _Sent __last,
+ _InputAndOutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__reread_from_output_tag) {
+ if (__first != __last) {
+ *__result = *__first;
+ while (++__first != __last)
+ if (!__pred(*__result, *__first))
+ *++__result = *__first;
+ ++__result;
+ }
+ return pair<_InputIterator, _InputAndOutputIterator>(std::move(__first), std::move(__result));
}
template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred)
-{
- return _VSTD::__unique_copy<_BinaryPredicate&>(__first, __last, __result, __pred,
- typename iterator_traits<_InputIterator>::iterator_category(),
- typename iterator_traits<_OutputIterator>::iterator_category());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) {
+ using __algo_tag = typename conditional<
+ is_base_of<forward_iterator_tag, typename iterator_traits<_InputIterator>::iterator_category>::value,
+ __unique_copy_tags::__reread_from_input_tag,
+ typename conditional<
+ is_base_of<forward_iterator_tag, typename iterator_traits<_OutputIterator>::iterator_category>::value &&
+ is_same< typename iterator_traits<_InputIterator>::value_type,
+ typename iterator_traits<_OutputIterator>::value_type>::value,
+ __unique_copy_tags::__reread_from_output_tag,
+ __unique_copy_tags::__read_from_tmp_value_tag>::type >::type;
+ return std::__unique_copy<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag())
+ .second;
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- typedef typename iterator_traits<_InputIterator>::value_type __v;
- return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ typedef typename iterator_traits<_InputIterator>::value_type __v;
+ return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to<__v>());
}
-
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H
lib/libcxx/include/__algorithm/unwrap_iter.h
@@ -10,73 +10,61 @@
#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H
#include <__config>
+#include <__iterator/iterator_traits.h>
#include <__memory/pointer_traits.h>
-#include <iterator>
+#include <__utility/move.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-// The job of __unwrap_iter is to lower contiguous iterators (such as
-// vector<T>::iterator) into pointers, to reduce the number of template
-// instantiations and to enable pointer-based optimizations e.g. in std::copy.
-// For iterators that are not contiguous, it must be a no-op.
+// TODO: Change the name of __unwrap_iter_impl to something more appropriate
+// The job of __unwrap_iter is to remove iterator wrappers (like reverse_iterator or __wrap_iter),
+// to reduce the number of template instantiations and to enable pointer-based optimizations e.g. in std::copy.
// In debug mode, we don't do this.
//
-// __unwrap_iter is non-constexpr for user-defined iterators whose
-// `to_address` and/or `operator->` is non-constexpr. This is okay; but we
-// try to avoid doing __unwrap_iter in constant-evaluated contexts anyway.
-//
// Some algorithms (e.g. std::copy, but not std::sort) need to convert an
-// "unwrapped" result back into a contiguous iterator. Since contiguous iterators
-// are random-access, we can do this portably using iterator arithmetic; this
-// is the job of __rewrap_iter.
+// "unwrapped" result back into the original iterator type. Doing that is the job of __rewrap_iter.
+// Default case - we can't unwrap anything
template <class _Iter, bool = __is_cpp17_contiguous_iterator<_Iter>::value>
struct __unwrap_iter_impl {
- static _LIBCPP_CONSTEXPR _Iter
- __apply(_Iter __i) _NOEXCEPT {
- return __i;
- }
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter, _Iter __iter) { return __iter; }
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __unwrap(_Iter __i) _NOEXCEPT { return __i; }
};
-#if _LIBCPP_DEBUG_LEVEL < 2
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
+// It's a contiguous iterator, so we can use a raw pointer instead
template <class _Iter>
struct __unwrap_iter_impl<_Iter, true> {
- static _LIBCPP_CONSTEXPR decltype(_VSTD::__to_address(declval<_Iter>()))
- __apply(_Iter __i) _NOEXCEPT {
- return _VSTD::__to_address(__i);
- }
-};
+ using _ToAddressT = decltype(std::__to_address(std::declval<_Iter>()));
-#endif // _LIBCPP_DEBUG_LEVEL < 2
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter __orig_iter, _ToAddressT __unwrapped_iter) {
+ return __orig_iter + (__unwrapped_iter - std::__to_address(__orig_iter));
+ }
-template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> >
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-decltype(_Impl::__apply(declval<_Iter>()))
-__unwrap_iter(_Iter __i) _NOEXCEPT
-{
- return _Impl::__apply(__i);
-}
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToAddressT __unwrap(_Iter __i) _NOEXCEPT {
+ return std::__to_address(__i);
+ }
+};
+
+#endif // !_LIBCPP_ENABLE_DEBUG_MODE
-template<class _OrigIter>
-_LIBCPP_HIDE_FROM_ABI
-_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
-{
- return __result;
+template<class _Iter,
+ class _Impl = __unwrap_iter_impl<_Iter>,
+ __enable_if_t<is_copy_constructible<_Iter>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+decltype(_Impl::__unwrap(std::declval<_Iter>())) __unwrap_iter(_Iter __i) _NOEXCEPT {
+ return _Impl::__unwrap(__i);
}
-template<class _OrigIter, class _UnwrappedIter>
-_LIBCPP_HIDE_FROM_ABI
-_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result)
-{
- // Precondition: __result is reachable from __first
- // Precondition: _OrigIter is a contiguous iterator
- return __first + (__result - _VSTD::__unwrap_iter(__first));
+template <class _OrigIter, class _Iter, class _Impl = __unwrap_iter_impl<_OrigIter> >
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _OrigIter __rewrap_iter(_OrigIter __orig_iter, _Iter __iter) _NOEXCEPT {
+ return _Impl::__rewrap(std::move(__orig_iter), std::move(__iter));
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unwrap_range.h
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
+#define _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
+
+#include <__algorithm/unwrap_iter.h>
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/next.h>
+#include <__utility/declval.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __unwrap_range and __rewrap_range are used to unwrap ranges which may have different iterator and sentinel types.
+// __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have
+// the same type. __unwrap_range tries to get two iterators and then forward to __unwrap_iter.
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <class _Iter, class _Sent>
+struct __unwrap_range_impl {
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent)
+ requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
+ {
+ auto __last = ranges::next(__first, __sent);
+ return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __last) {
+ return pair{std::move(__first), std::move(__last)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter)
+ requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
+ {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter)
+ requires (!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>))
+ {
+ return __iter;
+ }
+};
+
+template <class _Iter>
+struct __unwrap_range_impl<_Iter, _Iter> {
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Iter __last) {
+ return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter) {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+ }
+};
+
+template <class _Iter, class _Sent>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) {
+ return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last));
+}
+
+template <
+ class _Sent,
+ class _Iter,
+ class _Unwrapped = decltype(std::__unwrap_range(std::declval<_Iter>(), std::declval<_Sent>()))>
+_LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
+ return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter));
+}
+#else // _LIBCPP_STD_VER > 17
+template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair<_Unwrapped, _Unwrapped> __unwrap_range(_Iter __first, _Iter __last) {
+ return std::make_pair(std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last)));
+}
+
+template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+}
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
lib/libcxx/include/__algorithm/upper_bound.h
@@ -11,54 +11,56 @@
#include <__algorithm/comp.h>
#include <__algorithm/half_positive.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
-#include <iterator>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/advance.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _ForwardIterator, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- difference_type __len = _VSTD::distance(__first, __last);
- while (__len != 0)
- {
- difference_type __l2 = _VSTD::__half_positive(__len);
- _ForwardIterator __m = __first;
- _VSTD::advance(__m, __l2);
- if (__comp(__value_, *__m))
- __len = __l2;
- else
- {
- __first = ++__m;
- __len -= __l2 + 1;
- }
+template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter
+__upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
+ auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
+ while (__len != 0) {
+ auto __half_len = std::__half_positive(__len);
+ auto __mid = _IterOps<_AlgPolicy>::next(__first, __half_len);
+ if (std::__invoke(__comp, __value, std::__invoke(__proj, *__mid)))
+ __len = __half_len;
+ else {
+ __first = ++__mid;
+ __len -= __half_len + 1;
}
- return __first;
+ }
+ return __first;
}
template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- return _VSTD::__upper_bound<_Compare&>(__first, __last, __value_, __comp);
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
+ static_assert(is_copy_constructible<_ForwardIterator>::value,
+ "Iterator has to be copy constructible");
+ return std::__upper_bound<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), __value, std::move(__comp), std::__identity());
}
template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- return _VSTD::upper_bound(__first, __last, __value_,
- __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
+ return std::upper_bound(
+ std::move(__first),
+ std::move(__last),
+ __value,
+ __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__bit/bit_cast.h
@@ -14,21 +14,19 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-template<class _ToType, class _FromType, class = enable_if_t<
- sizeof(_ToType) == sizeof(_FromType) &&
- is_trivially_copyable_v<_ToType> &&
- is_trivially_copyable_v<_FromType>
->>
-_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
-constexpr _ToType bit_cast(_FromType const& __from) noexcept {
- return __builtin_bit_cast(_ToType, __from);
+template <class _ToType, class _FromType>
+ requires(sizeof(_ToType) == sizeof(_FromType) &&
+ is_trivially_copyable_v<_ToType> &&
+ is_trivially_copyable_v<_FromType>)
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _ToType bit_cast(const _FromType& __from) noexcept {
+ return __builtin_bit_cast(_ToType, __from);
}
#endif // _LIBCPP_STD_VER > 17
lib/libcxx/include/__bit/byteswap.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 20
template <integral _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {
@@ -48,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {
}
}
-#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 20
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__charconv/chars_format.h
@@ -14,7 +14,7 @@
#include <__utility/to_underlying.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__charconv/from_chars_result.h
@@ -14,7 +14,7 @@
#include <__errc>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__charconv/tables.h
@@ -0,0 +1,180 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHARCONV_TABLES
+#define _LIBCPP___CHARCONV_TABLES
+
+#include <__config>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+namespace __itoa {
+
+/// Contains the charconv helper tables.
+///
+/// In C++17 these could be inline constexpr variable, but libc++ supports
+/// charconv for integrals in C++11 mode.
+template <class = void>
+struct __table {
+ static const char __base_2_lut[64];
+ static const char __base_8_lut[128];
+ static const char __base_16_lut[512];
+
+ static const uint32_t __pow10_32[10];
+ static const uint64_t __pow10_64[20];
+# ifndef _LIBCPP_HAS_NO_INT128
+ // TODO FMT Reduce the number of entries in this table.
+ static const __uint128_t __pow10_128[40];
+ static const int __pow10_128_offset = 0;
+# endif
+ static const char __digits_base_10[200];
+};
+
+template <class _Tp>
+const char __table<_Tp>::__base_2_lut[64] = {
+ '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',
+ '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',
+ '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};
+
+template <class _Tp>
+const char __table<_Tp>::__base_8_lut[128] = {
+ '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',
+ '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',
+ '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',
+ '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '5', '0', '5', '1', '5', '2', '5', '3',
+ '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',
+ '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};
+
+template <class _Tp>
+const char __table<_Tp>::__base_16_lut[512] = {
+ '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',
+ 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',
+ '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',
+ '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '2', 'a', '2', 'b', '2', 'c', '2', 'd',
+ '2', 'e', '2', 'f', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3',
+ '9', '3', 'a', '3', 'b', '3', 'c', '3', 'd', '3', 'e', '3', 'f', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4',
+ '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '4', 'a', '4', 'b', '4', 'c', '4', 'd', '4', 'e', '4', 'f', '5',
+ '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '5', 'a', '5', 'b',
+ '5', 'c', '5', 'd', '5', 'e', '5', 'f', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6',
+ '7', '6', '8', '6', '9', '6', 'a', '6', 'b', '6', 'c', '6', 'd', '6', 'e', '6', 'f', '7', '0', '7', '1', '7', '2',
+ '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '7', 'a', '7', 'b', '7', 'c', '7', 'd', '7',
+ 'e', '7', 'f', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
+ '8', 'a', '8', 'b', '8', 'c', '8', 'd', '8', 'e', '8', 'f', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9',
+ '5', '9', '6', '9', '7', '9', '8', '9', '9', '9', 'a', '9', 'b', '9', 'c', '9', 'd', '9', 'e', '9', 'f', 'a', '0',
+ 'a', '1', 'a', '2', 'a', '3', 'a', '4', 'a', '5', 'a', '6', 'a', '7', 'a', '8', 'a', '9', 'a', 'a', 'a', 'b', 'a',
+ 'c', 'a', 'd', 'a', 'e', 'a', 'f', 'b', '0', 'b', '1', 'b', '2', 'b', '3', 'b', '4', 'b', '5', 'b', '6', 'b', '7',
+ 'b', '8', 'b', '9', 'b', 'a', 'b', 'b', 'b', 'c', 'b', 'd', 'b', 'e', 'b', 'f', 'c', '0', 'c', '1', 'c', '2', 'c',
+ '3', 'c', '4', 'c', '5', 'c', '6', 'c', '7', 'c', '8', 'c', '9', 'c', 'a', 'c', 'b', 'c', 'c', 'c', 'd', 'c', 'e',
+ 'c', 'f', 'd', '0', 'd', '1', 'd', '2', 'd', '3', 'd', '4', 'd', '5', 'd', '6', 'd', '7', 'd', '8', 'd', '9', 'd',
+ 'a', 'd', 'b', 'd', 'c', 'd', 'd', 'd', 'e', 'd', 'f', 'e', '0', 'e', '1', 'e', '2', 'e', '3', 'e', '4', 'e', '5',
+ 'e', '6', 'e', '7', 'e', '8', 'e', '9', 'e', 'a', 'e', 'b', 'e', 'c', 'e', 'd', 'e', 'e', 'e', 'f', 'f', '0', 'f',
+ '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',
+ 'f', 'd', 'f', 'e', 'f', 'f'};
+
+template <class _Tp>
+const uint32_t __table<_Tp>::__pow10_32[10] = {
+ UINT32_C(0), UINT32_C(10), UINT32_C(100), UINT32_C(1000), UINT32_C(10000),
+ UINT32_C(100000), UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), UINT32_C(1000000000)};
+
+template <class _Tp>
+const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),
+ UINT64_C(10),
+ UINT64_C(100),
+ UINT64_C(1000),
+ UINT64_C(10000),
+ UINT64_C(100000),
+ UINT64_C(1000000),
+ UINT64_C(10000000),
+ UINT64_C(100000000),
+ UINT64_C(1000000000),
+ UINT64_C(10000000000),
+ UINT64_C(100000000000),
+ UINT64_C(1000000000000),
+ UINT64_C(10000000000000),
+ UINT64_C(100000000000000),
+ UINT64_C(1000000000000000),
+ UINT64_C(10000000000000000),
+ UINT64_C(100000000000000000),
+ UINT64_C(1000000000000000000),
+ UINT64_C(10000000000000000000)};
+
+# ifndef _LIBCPP_HAS_NO_INT128
+template <class _Tp>
+const __uint128_t __table<_Tp>::__pow10_128[40] = {
+ UINT64_C(0),
+ UINT64_C(10),
+ UINT64_C(100),
+ UINT64_C(1000),
+ UINT64_C(10000),
+ UINT64_C(100000),
+ UINT64_C(1000000),
+ UINT64_C(10000000),
+ UINT64_C(100000000),
+ UINT64_C(1000000000),
+ UINT64_C(10000000000),
+ UINT64_C(100000000000),
+ UINT64_C(1000000000000),
+ UINT64_C(10000000000000),
+ UINT64_C(100000000000000),
+ UINT64_C(1000000000000000),
+ UINT64_C(10000000000000000),
+ UINT64_C(100000000000000000),
+ UINT64_C(1000000000000000000),
+ UINT64_C(10000000000000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000000),
+ __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000),
+ (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};
+# endif
+
+template <class _Tp>
+const char __table<_Tp>::__digits_base_10[200] = {
+ // clang-format off
+ '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
+ '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
+ '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
+ '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',
+ '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',
+ '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
+ '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',
+ '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',
+ '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
+ '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'};
+// clang-format on
+
+} // namespace __itoa
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHARCONV_TABLES
lib/libcxx/include/__charconv/to_chars_base_10.h
@@ -0,0 +1,185 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H
+#define _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H
+
+#include <__algorithm/copy_n.h>
+#include <__charconv/tables.h>
+#include <__config>
+#include <cstdint>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+namespace __itoa {
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept {
+ *__first = '0' + static_cast<char>(__value);
+ return __first + 1;
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {
+ return std::copy_n(&__table<>::__digits_base_10[__value * 2], 2, __first);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept {
+ return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept {
+ return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept {
+ return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept {
+ return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept {
+ return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept {
+ return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept {
+ return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept {
+ return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),
+ static_cast<uint32_t>(__value % 100000000));
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value) noexcept {
+ if (__value < 1000000) {
+ if (__value < 10000) {
+ if (__value < 100) {
+ // 0 <= __value < 100
+ if (__value < 10)
+ return __itoa::__append1(__first, __value);
+ return __itoa::__append2(__first, __value);
+ }
+ // 100 <= __value < 10'000
+ if (__value < 1000)
+ return __itoa::__append3(__first, __value);
+ return __itoa::__append4(__first, __value);
+ }
+
+ // 10'000 <= __value < 1'000'000
+ if (__value < 100000)
+ return __itoa::__append5(__first, __value);
+ return __itoa::__append6(__first, __value);
+ }
+
+ // __value => 1'000'000
+ if (__value < 100000000) {
+ // 1'000'000 <= __value < 100'000'000
+ if (__value < 10000000)
+ return __itoa::__append7(__first, __value);
+ return __itoa::__append8(__first, __value);
+ }
+
+ // 100'000'000 <= __value < max
+ if (__value < 1000000000)
+ return __itoa::__append9(__first, __value);
+ return __itoa::__append10(__first, __value);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __value) noexcept {
+ if (__value <= UINT32_MAX)
+ return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value));
+
+ // Numbers in the range UINT32_MAX <= val < 10'000'000'000 always contain 10
+ // digits and are outputted after this if statement.
+ if (__value >= 10000000000) {
+ // This function properly deterimines the first non-zero leading digit.
+ __buffer = __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value / 10000000000));
+ __value %= 10000000000;
+ }
+ return __itoa::__append10(__buffer, __value);
+}
+
+# ifndef _LIBCPP_HAS_NO_INT128
+/// \returns 10^\a exp
+///
+/// \pre \a exp [19, 39]
+///
+/// \note The lookup table contains a partial set of exponents limiting the
+/// range that can be used. However the range is sufficient for
+/// \ref __base_10_u128.
+_LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
+ _LIBCPP_ASSERT(__exp >= __table<>::__pow10_128_offset, "Index out of bounds");
+ return __table<>::__pow10_128[__exp - __table<>::__pow10_128_offset];
+}
+
+_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __value) noexcept {
+ _LIBCPP_ASSERT(
+ __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
+
+ // Unlike the 64 to 32 bit case the 128 bit case the "upper half" can't be
+ // stored in the "lower half". Instead we first need to handle the top most
+ // digits separately.
+ //
+ // Maximum unsigned values
+ // 64 bit 18'446'744'073'709'551'615 (20 digits)
+ // 128 bit 340'282'366'920'938'463'463'374'607'431'768'211'455 (39 digits)
+ // step 1 ^ ([0-1] digits)
+ // step 2 ^^^^^^^^^^^^^^^^^^^^^^^^^ ([0-19] digits)
+ // step 3 ^^^^^^^^^^^^^^^^^^^^^^^^^ (19 digits)
+ if (__value >= __itoa::__pow_10(38)) {
+ // step 1
+ __buffer = __itoa::__append1(__buffer, static_cast<uint32_t>(__value / __itoa::__pow_10(38)));
+ __value %= __itoa::__pow_10(38);
+
+ // step 2 always 19 digits.
+ // They are handled here since leading zeros need to be appended to the buffer,
+ __buffer = __itoa::__append9(__buffer, static_cast<uint32_t>(__value / __itoa::__pow_10(29)));
+ __value %= __itoa::__pow_10(29);
+ __buffer = __itoa::__append10(__buffer, static_cast<uint64_t>(__value / __itoa::__pow_10(19)));
+ __value %= __itoa::__pow_10(19);
+ }
+ else {
+ // step 2
+ // This version needs to determine the position of the leading non-zero digit.
+ __buffer = __base_10_u64(__buffer, static_cast<uint64_t>(__value / __itoa::__pow_10(19)));
+ __value %= __itoa::__pow_10(19);
+ }
+
+ // Step 3
+ __buffer = __itoa::__append9(__buffer, static_cast<uint32_t>(__value / 10000000000));
+ __buffer = __itoa::__append10(__buffer, static_cast<uint64_t>(__value % 10000000000));
+
+ return __buffer;
+}
+# endif
+} // namespace __itoa
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H
lib/libcxx/include/__charconv/to_chars_result.h
@@ -14,7 +14,7 @@
#include <__errc>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__chrono/calendar.h
@@ -11,20 +11,13 @@
#define _LIBCPP___CHRONO_CALENDAR_H
#include <__chrono/duration.h>
-#include <__chrono/system_clock.h>
#include <__chrono/time_point.h>
#include <__config>
-#include <limits>
-#include <ratio>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -38,1239 +31,14 @@ using local_time = time_point<local_t, Duration>;
using local_seconds = local_time<seconds>;
using local_days = local_time<days>;
-struct last_spec { explicit last_spec() = default; };
-
-class day {
-private:
- unsigned char __d;
-public:
- day() = default;
- explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
- inline constexpr day& operator++() noexcept { ++__d; return *this; }
- inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
- inline constexpr day& operator--() noexcept { --__d; return *this; }
- inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
- constexpr day& operator+=(const days& __dd) noexcept;
- constexpr day& operator-=(const days& __dd) noexcept;
- explicit inline constexpr operator unsigned() const noexcept { return __d; }
- inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
- };
-
-
-inline constexpr
-bool operator==(const day& __lhs, const day& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
-
-inline constexpr
-bool operator!=(const day& __lhs, const day& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const day& __lhs, const day& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
-
-inline constexpr
-bool operator> (const day& __lhs, const day& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const day& __lhs, const day& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const day& __lhs, const day& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-day operator+ (const day& __lhs, const days& __rhs) noexcept
-{ return day(static_cast<unsigned>(__lhs) + __rhs.count()); }
-
-inline constexpr
-day operator+ (const days& __lhs, const day& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-day operator- (const day& __lhs, const days& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr
-days operator-(const day& __lhs, const day& __rhs) noexcept
-{ return days(static_cast<int>(static_cast<unsigned>(__lhs)) -
- static_cast<int>(static_cast<unsigned>(__rhs))); }
-
-inline constexpr day& day::operator+=(const days& __dd) noexcept
-{ *this = *this + __dd; return *this; }
-
-inline constexpr day& day::operator-=(const days& __dd) noexcept
-{ *this = *this - __dd; return *this; }
-
-
-class month {
-private:
- unsigned char __m;
-public:
- month() = default;
- explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
- inline constexpr month& operator++() noexcept { ++__m; return *this; }
- inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
- inline constexpr month& operator--() noexcept { --__m; return *this; }
- inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
- constexpr month& operator+=(const months& __m1) noexcept;
- constexpr month& operator-=(const months& __m1) noexcept;
- explicit inline constexpr operator unsigned() const noexcept { return __m; }
- inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
-};
-
-
-inline constexpr
-bool operator==(const month& __lhs, const month& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
-
-inline constexpr
-bool operator!=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const month& __lhs, const month& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
-
-inline constexpr
-bool operator> (const month& __lhs, const month& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__rhs < __lhs); }
-
-inline constexpr
-bool operator>=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-month operator+ (const month& __lhs, const months& __rhs) noexcept
-{
- auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
- auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
- return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
-}
-
-inline constexpr
-month operator+ (const months& __lhs, const month& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-month operator- (const month& __lhs, const months& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr
-months operator-(const month& __lhs, const month& __rhs) noexcept
-{
- auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
- return months(__dm <= 11 ? __dm : __dm + 12);
-}
-
-inline constexpr month& month::operator+=(const months& __dm) noexcept
-{ *this = *this + __dm; return *this; }
-
-inline constexpr month& month::operator-=(const months& __dm) noexcept
-{ *this = *this - __dm; return *this; }
-
-
-class year {
-private:
- short __y;
-public:
- year() = default;
- explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
-
- inline constexpr year& operator++() noexcept { ++__y; return *this; }
- inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; }
- inline constexpr year& operator--() noexcept { --__y; return *this; }
- inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
- constexpr year& operator+=(const years& __dy) noexcept;
- constexpr year& operator-=(const years& __dy) noexcept;
- inline constexpr year operator+() const noexcept { return *this; }
- inline constexpr year operator-() const noexcept { return year{-__y}; }
-
- inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
- explicit inline constexpr operator int() const noexcept { return __y; }
- constexpr bool ok() const noexcept;
- static inline constexpr year min() noexcept { return year{-32767}; }
- static inline constexpr year max() noexcept { return year{ 32767}; }
-};
-
-
-inline constexpr
-bool operator==(const year& __lhs, const year& __rhs) noexcept
-{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
-
-inline constexpr
-bool operator!=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const year& __lhs, const year& __rhs) noexcept
-{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
-
-inline constexpr
-bool operator> (const year& __lhs, const year& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__rhs < __lhs); }
-
-inline constexpr
-bool operator>=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-year operator+ (const year& __lhs, const years& __rhs) noexcept
-{ return year(static_cast<int>(__lhs) + __rhs.count()); }
-
-inline constexpr
-year operator+ (const years& __lhs, const year& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year operator- (const year& __lhs, const years& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr
-years operator-(const year& __lhs, const year& __rhs) noexcept
-{ return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; }
-
-
-inline constexpr year& year::operator+=(const years& __dy) noexcept
-{ *this = *this + __dy; return *this; }
-
-inline constexpr year& year::operator-=(const years& __dy) noexcept
-{ *this = *this - __dy; return *this; }
-
-inline constexpr bool year::ok() const noexcept
-{ return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); }
-
-class weekday_indexed;
-class weekday_last;
-
-class weekday {
-private:
- unsigned char __wd;
- static constexpr unsigned char __weekday_from_days(int __days) noexcept;
-public:
- weekday() = default;
- inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
- inline constexpr weekday(const sys_days& __sysd) noexcept
- : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
- inline explicit constexpr weekday(const local_days& __locd) noexcept
- : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
-
- inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
- inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
- inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
- inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
- constexpr weekday& operator+=(const days& __dd) noexcept;
- constexpr weekday& operator-=(const days& __dd) noexcept;
- inline constexpr unsigned c_encoding() const noexcept { return __wd; }
- inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; }
- inline constexpr bool ok() const noexcept { return __wd <= 6; }
- constexpr weekday_indexed operator[](unsigned __index) const noexcept;
- constexpr weekday_last operator[](last_spec) const noexcept;
-};
-
-
-// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
-inline constexpr
-unsigned char weekday::__weekday_from_days(int __days) noexcept
-{
- return static_cast<unsigned char>(
- static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
- );
-}
-
-inline constexpr
-bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
-{ return __lhs.c_encoding() == __rhs.c_encoding(); }
-
-inline constexpr
-bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept
-{ return __lhs.c_encoding() < __rhs.c_encoding(); }
-
-inline constexpr
-bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
-{
- auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
- auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
- return weekday{static_cast<unsigned>(__mu - __yr * 7)};
-}
-
-constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
-{
- const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
- const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
- return days{__wdu - __wk * 7};
-}
-
-inline constexpr weekday& weekday::operator+=(const days& __dd) noexcept
-{ *this = *this + __dd; return *this; }
-
-inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept
-{ *this = *this - __dd; return *this; }
-
-
-class weekday_indexed {
-private:
- chrono::weekday __wd;
- unsigned char __idx;
-public:
- weekday_indexed() = default;
- inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
- : __wd{__wdval}, __idx(__idxval) {}
- inline constexpr chrono::weekday weekday() const noexcept { return __wd; }
- inline constexpr unsigned index() const noexcept { return __idx; }
- inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
-};
-
-inline constexpr
-bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
-{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); }
-
-inline constexpr
-bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-
-class weekday_last {
-private:
- chrono::weekday __wd;
-public:
- explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
- : __wd{__val} {}
- constexpr chrono::weekday weekday() const noexcept { return __wd; }
- constexpr bool ok() const noexcept { return __wd.ok(); }
-};
-
-inline constexpr
-bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
-{ return __lhs.weekday() == __rhs.weekday(); }
-
-inline constexpr
-bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
-
-inline constexpr
-weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
-
-
+struct last_spec { _LIBCPP_HIDE_FROM_ABI explicit last_spec() = default; };
inline constexpr last_spec last{};
-inline constexpr weekday Sunday{0};
-inline constexpr weekday Monday{1};
-inline constexpr weekday Tuesday{2};
-inline constexpr weekday Wednesday{3};
-inline constexpr weekday Thursday{4};
-inline constexpr weekday Friday{5};
-inline constexpr weekday Saturday{6};
-
-inline constexpr month January{1};
-inline constexpr month February{2};
-inline constexpr month March{3};
-inline constexpr month April{4};
-inline constexpr month May{5};
-inline constexpr month June{6};
-inline constexpr month July{7};
-inline constexpr month August{8};
-inline constexpr month September{9};
-inline constexpr month October{10};
-inline constexpr month November{11};
-inline constexpr month December{12};
-
-
-class month_day {
-private:
- chrono::month __m;
- chrono::day __d;
-public:
- month_day() = default;
- constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
- : __m{__mval}, __d{__dval} {}
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::day day() const noexcept { return __d; }
- constexpr bool ok() const noexcept;
-};
-
-inline constexpr
-bool month_day::ok() const noexcept
-{
- if (!__m.ok()) return false;
- const unsigned __dval = static_cast<unsigned>(__d);
- if (__dval < 1 || __dval > 31) return false;
- if (__dval <= 29) return true;
-// Now we've got either 30 or 31
- const unsigned __mval = static_cast<unsigned>(__m);
- if (__mval == 2) return false;
- if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
- return __dval == 30;
- return true;
-}
-
-inline constexpr
-bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
-
-inline constexpr
-bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-month_day operator/(const month& __lhs, const day& __rhs) noexcept
-{ return month_day{__lhs, __rhs}; }
-
-constexpr
-month_day operator/(const day& __lhs, const month& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr
-month_day operator/(const month& __lhs, int __rhs) noexcept
-{ return __lhs / day(__rhs); }
-
-constexpr
-month_day operator/(int __lhs, const day& __rhs) noexcept
-{ return month(__lhs) / __rhs; }
-
-constexpr
-month_day operator/(const day& __lhs, int __rhs) noexcept
-{ return month(__rhs) / __lhs; }
-
-
-inline constexpr
-bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
-{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
-
-inline constexpr
-bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-
-
-class month_day_last {
-private:
- chrono::month __m;
-public:
- explicit constexpr month_day_last(const chrono::month& __val) noexcept
- : __m{__val} {}
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr bool ok() const noexcept { return __m.ok(); }
-};
-
-inline constexpr
-bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return __lhs.month() == __rhs.month(); }
-
-inline constexpr
-bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-inline constexpr
-bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return __lhs.month() < __rhs.month(); }
-inline constexpr
-bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-month_day_last operator/(const month& __lhs, last_spec) noexcept
-{ return month_day_last{__lhs}; }
-
-inline constexpr
-month_day_last operator/(last_spec, const month& __rhs) noexcept
-{ return month_day_last{__rhs}; }
-
-inline constexpr
-month_day_last operator/(int __lhs, last_spec) noexcept
-{ return month_day_last{month(__lhs)}; }
-
-inline constexpr
-month_day_last operator/(last_spec, int __rhs) noexcept
-{ return month_day_last{month(__rhs)}; }
-
-
-class month_weekday {
-private:
- chrono::month __m;
- chrono::weekday_indexed __wdi;
-public:
- constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
- : __m{__mval}, __wdi{__wdival} {}
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
- inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
-};
-
-inline constexpr
-bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
-{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
-
-inline constexpr
-bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept
-{ return month_weekday{__lhs, __rhs}; }
-
-inline constexpr
-month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept
-{ return month_weekday{month(__lhs), __rhs}; }
-
-inline constexpr
-month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept
-{ return month_weekday{__rhs, __lhs}; }
-
-inline constexpr
-month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
-{ return month_weekday{month(__rhs), __lhs}; }
-
-
-class month_weekday_last {
- chrono::month __m;
- chrono::weekday_last __wdl;
- public:
- constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
- : __m{__mval}, __wdl{__wdlval} {}
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
- inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
-};
-
-inline constexpr
-bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
-{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
-
-inline constexpr
-bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-
-inline constexpr
-month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept
-{ return month_weekday_last{__lhs, __rhs}; }
-
-inline constexpr
-month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept
-{ return month_weekday_last{month(__lhs), __rhs}; }
-
-inline constexpr
-month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept
-{ return month_weekday_last{__rhs, __lhs}; }
-
-inline constexpr
-month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
-{ return month_weekday_last{month(__rhs), __lhs}; }
-
-
-class year_month {
- chrono::year __y;
- chrono::month __m;
-public:
- year_month() = default;
- constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
- : __y{__yval}, __m{__mval} {}
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
- inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
- inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
- inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
- inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
-};
-
-inline constexpr
-year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; }
-
-inline constexpr
-year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; }
-
-inline constexpr
-bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
-
-inline constexpr
-bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
-{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
-
-inline constexpr
-bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-constexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
-{
- int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
- const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12;
- __dmi = __dmi - __dy * 12 + 1;
- return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
-}
-
-constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
-{ return (__lhs.year() + __rhs) / __lhs.month(); }
-
-constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-constexpr months operator-(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }
-
-constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-class year_month_day_last;
-
-class year_month_day {
-private:
- chrono::year __y;
- chrono::month __m;
- chrono::day __d;
-public:
- year_month_day() = default;
- inline constexpr year_month_day(
- const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
- : __y{__yval}, __m{__mval}, __d{__dval} {}
- constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
- inline constexpr year_month_day(const sys_days& __sysd) noexcept
- : year_month_day(__from_days(__sysd.time_since_epoch())) {}
- inline explicit constexpr year_month_day(const local_days& __locd) noexcept
- : year_month_day(__from_days(__locd.time_since_epoch())) {}
-
- constexpr year_month_day& operator+=(const months& __dm) noexcept;
- constexpr year_month_day& operator-=(const months& __dm) noexcept;
- constexpr year_month_day& operator+=(const years& __dy) noexcept;
- constexpr year_month_day& operator-=(const years& __dy) noexcept;
-
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::day day() const noexcept { return __d; }
- inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
- inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
-
- constexpr bool ok() const noexcept;
-
- static constexpr year_month_day __from_days(days __d) noexcept;
- constexpr days __to_days() const noexcept;
-};
-
-
-// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
-inline constexpr
-year_month_day
-year_month_day::__from_days(days __d) noexcept
-{
- static_assert(numeric_limits<unsigned>::digits >= 18, "");
- static_assert(numeric_limits<int>::digits >= 20 , "");
- const int __z = __d.count() + 719468;
- const int __era = (__z >= 0 ? __z : __z - 146096) / 146097;
- const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096]
- const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399]
- const int __yr = static_cast<int>(__yoe) + __era * 400;
- const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365]
- const unsigned __mp = (5 * __doy + 2)/153; // [0, 11]
- const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31]
- const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12]
- return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
-}
-
-// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
-inline constexpr days year_month_day::__to_days() const noexcept
-{
- static_assert(numeric_limits<unsigned>::digits >= 18, "");
- static_assert(numeric_limits<int>::digits >= 20 , "");
-
- const int __yr = static_cast<int>(__y) - (__m <= February);
- const unsigned __mth = static_cast<unsigned>(__m);
- const unsigned __dy = static_cast<unsigned>(__d);
-
- const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
- const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
- const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365]
- const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096]
- return days{__era * 146097 + static_cast<int>(__doe) - 719468};
-}
-
-inline constexpr
-bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
-
-inline constexpr
-bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{
- if (__lhs.year() < __rhs.year()) return true;
- if (__lhs.year() > __rhs.year()) return false;
- if (__lhs.month() < __rhs.month()) return true;
- if (__lhs.month() > __rhs.month()) return false;
- return __lhs.day() < __rhs.day();
-}
-
-inline constexpr
-bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr
-year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
-{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
-
-inline constexpr
-year_month_day operator/(const year_month& __lhs, int __rhs) noexcept
-{ return __lhs / day(__rhs); }
-
-inline constexpr
-year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept
-{ return __lhs / __rhs.month() / __rhs.day(); }
-
-inline constexpr
-year_month_day operator/(int __lhs, const month_day& __rhs) noexcept
-{ return year(__lhs) / __rhs; }
-
-inline constexpr
-year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr
-year_month_day operator/(const month_day& __lhs, int __rhs) noexcept
-{ return year(__rhs) / __lhs; }
-
-
-inline constexpr
-year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept
-{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); }
-
-inline constexpr
-year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr
-year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept
-{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); }
-
-inline constexpr
-year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept
-{ return __lhs + -__rhs; }
-
-inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
-inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
-inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
-inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
-
-class year_month_day_last {
-private:
- chrono::year __y;
- chrono::month_day_last __mdl;
-public:
- constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
- : __y{__yval}, __mdl{__mdlval} {}
-
- constexpr year_month_day_last& operator+=(const months& __m) noexcept;
- constexpr year_month_day_last& operator-=(const months& __m) noexcept;
- constexpr year_month_day_last& operator+=(const years& __y) noexcept;
- constexpr year_month_day_last& operator-=(const years& __y) noexcept;
-
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
- inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
- constexpr chrono::day day() const noexcept;
- inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
- inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
- inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
-};
-
-inline constexpr
-chrono::day year_month_day_last::day() const noexcept
-{
- constexpr chrono::day __d[] =
- {
- chrono::day(31), chrono::day(28), chrono::day(31),
- chrono::day(30), chrono::day(31), chrono::day(30),
- chrono::day(31), chrono::day(31), chrono::day(30),
- chrono::day(31), chrono::day(30), chrono::day(31)
- };
- return (month() != February || !__y.is_leap()) && month().ok() ?
- __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
-}
-
-inline constexpr
-bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
-
-inline constexpr
-bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{
- if (__lhs.year() < __rhs.year()) return true;
- if (__lhs.year() > __rhs.year()) return false;
- return __lhs.month_day_last() < __rhs.month_day_last();
-}
-
-inline constexpr
-bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-inline constexpr
-bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-inline constexpr
-bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept
-{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; }
-
-inline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept
-{ return year_month_day_last{__lhs, __rhs}; }
-
-inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept
-{ return year_month_day_last{year{__lhs}, __rhs}; }
-
-inline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept
-{ return year{__rhs} / __lhs; }
-
-
-inline constexpr
-year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept
-{ return (__lhs.year() / __lhs.month() + __rhs) / last; }
-
-inline constexpr
-year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr
-year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept
-{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; }
-
-inline constexpr
-year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
-inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
-inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
-inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
-
-inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
- : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
-
-inline constexpr bool year_month_day::ok() const noexcept
-{
- if (!__y.ok() || !__m.ok()) return false;
- return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
-}
-
-class year_month_weekday {
- chrono::year __y;
- chrono::month __m;
- chrono::weekday_indexed __wdi;
-public:
- year_month_weekday() = default;
- constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
- const chrono::weekday_indexed& __wdival) noexcept
- : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
- constexpr year_month_weekday(const sys_days& __sysd) noexcept
- : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
- inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
- : year_month_weekday(__from_days(__locd.time_since_epoch())) {}
- constexpr year_month_weekday& operator+=(const months& m) noexcept;
- constexpr year_month_weekday& operator-=(const months& m) noexcept;
- constexpr year_month_weekday& operator+=(const years& y) noexcept;
- constexpr year_month_weekday& operator-=(const years& y) noexcept;
-
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
- inline constexpr unsigned index() const noexcept { return __wdi.index(); }
- inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
-
- inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
- inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
- inline constexpr bool ok() const noexcept
- {
- if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
- 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;
- constexpr days __to_days() const noexcept;
-};
-
-inline constexpr
-year_month_weekday year_month_weekday::__from_days(days __d) noexcept
-{
- const sys_days __sysd{__d};
- const chrono::weekday __wd = chrono::weekday(__sysd);
- const year_month_day __ymd = year_month_day(__sysd);
- return year_month_weekday{__ymd.year(), __ymd.month(),
- __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
-}
-
-inline constexpr
-days year_month_weekday::__to_days() const noexcept
-{
- const sys_days __sysd = sys_days(__y/__m/1);
- return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
- .time_since_epoch();
-}
-
-inline constexpr
-bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
-
-inline constexpr
-bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-inline constexpr
-year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept
-{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; }
-
-inline constexpr
-year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept
-{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; }
-
-inline constexpr
-year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept
-{ return year(__lhs) / __rhs; }
-
-inline constexpr
-year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr
-year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept
-{ return year(__rhs) / __lhs; }
-
-
-inline constexpr
-year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept
-{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); }
-
-inline constexpr
-year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr
-year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept
-{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; }
-
-inline constexpr
-year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-
-inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
-inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
-inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
-inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
-
-class year_month_weekday_last {
-private:
- chrono::year __y;
- chrono::month __m;
- chrono::weekday_last __wdl;
-public:
- constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
- const chrono::weekday_last& __wdlval) noexcept
- : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
- constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
- constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
- constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
- constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
-
- inline constexpr chrono::year year() const noexcept { return __y; }
- inline constexpr chrono::month month() const noexcept { return __m; }
- inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
- inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
- inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
- inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
- inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
-
- constexpr days __to_days() const noexcept;
-
-};
-
-inline constexpr
-days year_month_weekday_last::__to_days() const noexcept
-{
- const sys_days __last = sys_days{__y/__m/last};
- return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
-
-}
-
-inline constexpr
-bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
-{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
-
-inline constexpr
-bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-
-inline constexpr
-year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept
-{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; }
-
-inline constexpr
-year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept
-{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; }
-
-inline constexpr
-year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept
-{ return year(__lhs) / __rhs; }
-
-inline constexpr
-year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept
-{ return __rhs / __lhs; }
-
-inline constexpr
-year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
-{ return year(__rhs) / __lhs; }
-
-
-inline constexpr
-year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
-{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); }
-
-inline constexpr
-year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr
-year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
-{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; }
-
-inline constexpr
-year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept
-{ return __rhs + __lhs; }
-
-inline constexpr
-year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
-{ return __lhs + (-__rhs); }
-
-inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
-inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
-inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
-inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
-
-
-template <class _Duration>
-class hh_mm_ss
-{
-private:
- static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration");
- using __CommonType = common_type_t<_Duration, chrono::seconds>;
-
- static constexpr uint64_t __pow10(unsigned __exp)
- {
- uint64_t __ret = 1;
- for (unsigned __i = 0; __i < __exp; ++__i)
- __ret *= 10U;
- return __ret;
- }
-
- static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0)
- {
- if (__n >= 2 && __d != 0 && __w < 19)
- return 1 + __width(__n, __d % __n * 10, __w+1);
- return 0;
- }
-
-public:
- static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ?
- __width(__CommonType::period::den) : 6u;
- using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>;
-
- constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}
-
- constexpr explicit hh_mm_ss(_Duration __d) noexcept :
- __is_neg(__d < _Duration(0)),
- __h(duration_cast<chrono::hours> (abs(__d))),
- __m(duration_cast<chrono::minutes>(abs(__d) - hours())),
- __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())),
- __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds()))
- {}
-
- constexpr bool is_negative() const noexcept { return __is_neg; }
- constexpr chrono::hours hours() const noexcept { return __h; }
- constexpr chrono::minutes minutes() const noexcept { return __m; }
- constexpr chrono::seconds seconds() const noexcept { return __s; }
- constexpr precision subseconds() const noexcept { return __f; }
-
- constexpr precision to_duration() const noexcept
- {
- auto __dur = __h + __m + __s + __f;
- return __is_neg ? -__dur : __dur;
- }
-
- constexpr explicit operator precision() const noexcept { return to_duration(); }
-
-private:
- bool __is_neg;
- chrono::hours __h;
- chrono::minutes __m;
- chrono::seconds __s;
- precision __f;
-};
-
-constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
-constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); }
-
-constexpr hours make12(const hours& __h) noexcept
-{
- if (__h == hours( 0)) return hours(12);
- else if (__h <= hours(12)) return __h;
- else return __h - hours(12);
-}
-
-constexpr hours make24(const hours& __h, bool __is_pm) noexcept
-{
- if (__is_pm)
- return __h == hours(12) ? __h : __h + hours(12);
- else
- return __h == hours(12) ? hours(0) : __h;
-}
-
-} // namespace chrono
-
-inline namespace literals
-{
- inline namespace chrono_literals
- {
- constexpr chrono::day operator ""d(unsigned long long __d) noexcept
- {
- return chrono::day(static_cast<unsigned>(__d));
- }
-
- constexpr chrono::year operator ""y(unsigned long long __y) noexcept
- {
- return chrono::year(static_cast<int>(__y));
- }
-} // namespace chrono_literals
-} // namespace literals
-
-namespace chrono { // hoist the literals into namespace std::chrono
- using namespace literals::chrono_literals;
} // namespace chrono
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER > 17
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP___CHRONO_CALENDAR_H
lib/libcxx/include/__chrono/convert_to_timespec.h
@@ -14,7 +14,7 @@
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__chrono/day.h
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_DAY_H
+#define _LIBCPP___CHRONO_DAY_H
+
+#include <__chrono/duration.h>
+#include <__config>
+#include <compare>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class day {
+private:
+ unsigned char __d;
+public:
+ _LIBCPP_HIDE_FROM_ABI day() = default;
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept { --__d; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept;
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
+ };
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const day& __lhs, const day& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const day& __lhs, const day& __rhs) noexcept {
+ return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+day operator+ (const day& __lhs, const days& __rhs) noexcept
+{ return day(static_cast<unsigned>(__lhs) + __rhs.count()); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+day operator+ (const days& __lhs, const day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+day operator- (const day& __lhs, const days& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+days operator-(const day& __lhs, const day& __rhs) noexcept
+{ return days(static_cast<int>(static_cast<unsigned>(__lhs)) -
+ static_cast<int>(static_cast<unsigned>(__rhs))); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+day& day::operator+=(const days& __dd) noexcept
+{ *this = *this + __dd; return *this; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+day& day::operator-=(const days& __dd) noexcept
+{ *this = *this - __dd; return *this; }
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_DAY_H
lib/libcxx/include/__chrono/duration.h
@@ -16,7 +16,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -286,10 +286,10 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& __rhs) {__rep_ *= __rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& __rhs) {__rep_ /= __rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& __rhs) {__rep_ %= __rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& __rhs) {__rep_ %= __rhs.count(); return *this;}
// special values
lib/libcxx/include/__chrono/file_clock.h
@@ -18,7 +18,7 @@
#include <ratio>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifndef _LIBCPP_CXX03_LANG
lib/libcxx/include/__chrono/hh_mm_ss.h
@@ -0,0 +1,112 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_HH_MM_SS_H
+#define _LIBCPP___CHRONO_HH_MM_SS_H
+
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <ratio>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+template <class _Duration>
+class hh_mm_ss
+{
+private:
+ static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration");
+ using __CommonType = common_type_t<_Duration, chrono::seconds>;
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr uint64_t __pow10(unsigned __exp)
+ {
+ uint64_t __ret = 1;
+ for (unsigned __i = 0; __i < __exp; ++__i)
+ __ret *= 10U;
+ return __ret;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0)
+ {
+ if (__n >= 2 && __d != 0 && __w < 19)
+ return 1 + __width(__n, __d % __n * 10, __w+1);
+ return 0;
+ }
+
+public:
+ _LIBCPP_HIDE_FROM_ABI static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ?
+ __width(__CommonType::period::den) : 6u;
+ using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit hh_mm_ss(_Duration __d) noexcept :
+ __is_neg(__d < _Duration(0)),
+ __h(duration_cast<chrono::hours> (abs(__d))),
+ __m(duration_cast<chrono::minutes>(abs(__d) - hours())),
+ __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())),
+ __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds()))
+ {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg; }
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h; }
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s; }
+ _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept
+ {
+ auto __dur = __h + __m + __s + __f;
+ return __is_neg ? -__dur : __dur;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit operator precision() const noexcept { return to_duration(); }
+
+private:
+ bool __is_neg;
+ chrono::hours __h;
+ chrono::minutes __m;
+ chrono::seconds __s;
+ precision __f;
+};
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
+_LIBCPP_HIDE_FROM_ABI constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); }
+
+_LIBCPP_HIDE_FROM_ABI constexpr hours make12(const hours& __h) noexcept
+{
+ if (__h == hours( 0)) return hours(12);
+ else if (__h <= hours(12)) return __h;
+ else return __h - hours(12);
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr hours make24(const hours& __h, bool __is_pm) noexcept
+{
+ if (__is_pm)
+ return __h == hours(12) ? __h : __h + hours(12);
+ else
+ return __h == hours(12) ? hours(0) : __h;
+}
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_HH_MM_SS_H
lib/libcxx/include/__chrono/high_resolution_clock.h
@@ -15,7 +15,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__chrono/literals.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_LITERALS_H
+#define _LIBCPP___CHRONO_LITERALS_H
+
+#include <__chrono/day.h>
+#include <__chrono/year.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline namespace literals
+{
+ inline namespace chrono_literals
+ {
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::day operator ""d(unsigned long long __d) noexcept
+ {
+ return chrono::day(static_cast<unsigned>(__d));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::year operator ""y(unsigned long long __y) noexcept
+ {
+ return chrono::year(static_cast<int>(__y));
+ }
+} // namespace chrono_literals
+} // namespace literals
+
+namespace chrono { // hoist the literals into namespace std::chrono
+ using namespace literals::chrono_literals;
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_LITERALS_H
lib/libcxx/include/__chrono/month.h
@@ -0,0 +1,118 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_MONTH_H
+#define _LIBCPP___CHRONO_MONTH_H
+
+#include <__chrono/duration.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class month {
+private:
+ unsigned char __m;
+public:
+ _LIBCPP_HIDE_FROM_ABI month() = default;
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator--() noexcept { --__m; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr month& operator-=(const months& __m1) noexcept;
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
+};
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const month& __lhs, const month& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator< (const month& __lhs, const month& __rhs) noexcept
+{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator> (const month& __lhs, const month& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator<=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__rhs < __lhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator>=(const month& __lhs, const month& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month operator+ (const month& __lhs, const months& __rhs) noexcept
+{
+ auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
+ auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
+ return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month operator+ (const months& __lhs, const month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month operator- (const month& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+months operator-(const month& __lhs, const month& __rhs) noexcept
+{
+ auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
+ return months(__dm <= 11 ? __dm : __dm + 12);
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month& month::operator+=(const months& __dm) noexcept
+{ *this = *this + __dm; return *this; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month& month::operator-=(const months& __dm) noexcept
+{ *this = *this - __dm; return *this; }
+
+inline constexpr month January{1};
+inline constexpr month February{2};
+inline constexpr month March{3};
+inline constexpr month April{4};
+inline constexpr month May{5};
+inline constexpr month June{6};
+inline constexpr month July{7};
+inline constexpr month August{8};
+inline constexpr month September{9};
+inline constexpr month October{10};
+inline constexpr month November{11};
+inline constexpr month December{12};
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_MONTH_H
lib/libcxx/include/__chrono/month_weekday.h
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_MONTH_WEEKDAY_H
+#define _LIBCPP___CHRONO_MONTH_WEEKDAY_H
+
+#include <__chrono/month.h>
+#include <__chrono/weekday.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class month_weekday {
+private:
+ chrono::month __m;
+ chrono::weekday_indexed __wdi;
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
+ : __m{__mval}, __wdi{__wdival} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept
+{ return month_weekday{__lhs, __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept
+{ return month_weekday{month(__lhs), __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept
+{ return month_weekday{__rhs, __lhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
+{ return month_weekday{month(__rhs), __lhs}; }
+
+
+class month_weekday_last {
+ chrono::month __m;
+ chrono::weekday_last __wdl;
+ public:
+ _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
+ : __m{__mval}, __wdl{__wdlval} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept
+{ return month_weekday_last{__lhs, __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept
+{ return month_weekday_last{month(__lhs), __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept
+{ return month_weekday_last{__rhs, __lhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
+{ return month_weekday_last{month(__rhs), __lhs}; }
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_MONTH_WEEKDAY_H
lib/libcxx/include/__chrono/monthday.h
@@ -0,0 +1,160 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_MONTHDAY_H
+#define _LIBCPP___CHRONO_MONTHDAY_H
+
+#include <__chrono/calendar.h>
+#include <__chrono/day.h>
+#include <__chrono/month.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class month_day {
+private:
+ chrono::month __m;
+ chrono::day __d;
+public:
+ _LIBCPP_HIDE_FROM_ABI month_day() = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
+ : __m{__mval}, __d{__dval} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool month_day::ok() const noexcept
+{
+ if (!__m.ok()) return false;
+ const unsigned __dval = static_cast<unsigned>(__d);
+ if (__dval < 1 || __dval > 31) return false;
+ if (__dval <= 29) return true;
+// Now we've got either 30 or 31
+ const unsigned __mval = static_cast<unsigned>(__m);
+ if (__mval == 2) return false;
+ if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
+ return __dval == 30;
+ return true;
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_day operator/(const month& __lhs, const day& __rhs) noexcept
+{ return month_day{__lhs, __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+month_day operator/(const day& __lhs, const month& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_day operator/(const month& __lhs, int __rhs) noexcept
+{ return __lhs / day(__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+month_day operator/(int __lhs, const day& __rhs) noexcept
+{ return month(__lhs) / __rhs; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+month_day operator/(const day& __lhs, int __rhs) noexcept
+{ return month(__rhs) / __lhs; }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+
+
+class month_day_last {
+private:
+ chrono::month __m;
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit constexpr month_day_last(const chrono::month& __val) noexcept
+ : __m{__val} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok(); }
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __lhs.month() == __rhs.month(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __lhs.month() < __rhs.month(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_day_last operator/(const month& __lhs, last_spec) noexcept
+{ return month_day_last{__lhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_day_last operator/(last_spec, const month& __rhs) noexcept
+{ return month_day_last{__rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_day_last operator/(int __lhs, last_spec) noexcept
+{ return month_day_last{month(__lhs)}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+month_day_last operator/(last_spec, int __rhs) noexcept
+{ return month_day_last{month(__rhs)}; }
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_MONTHDAY_H
lib/libcxx/include/__chrono/steady_clock.h
@@ -15,7 +15,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__chrono/system_clock.h
@@ -16,7 +16,7 @@
#include <ctime>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__chrono/time_point.h
@@ -16,7 +16,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -47,12 +47,12 @@ public:
// conversions
template <class _Duration2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- time_point(const time_point<clock, _Duration2>& t,
+ time_point(const time_point<clock, _Duration2>& __t,
typename enable_if
<
is_convertible<_Duration2, duration>::value
>::type* = nullptr)
- : __d_(t.time_since_epoch()) {}
+ : __d_(__t.time_since_epoch()) {}
// observer
lib/libcxx/include/__chrono/weekday.h
@@ -0,0 +1,185 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_WEEKDAY_H
+#define _LIBCPP___CHRONO_WEEKDAY_H
+
+#include <__chrono/calendar.h>
+#include <__chrono/duration.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class weekday_indexed;
+class weekday_last;
+
+class weekday {
+private:
+ unsigned char __wd;
+ _LIBCPP_HIDE_FROM_ABI static constexpr unsigned char __weekday_from_days(int __days) noexcept;
+public:
+ _LIBCPP_HIDE_FROM_ABI weekday() = default;
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr weekday(const sys_days& __sysd) noexcept
+ : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(const local_days& __locd) noexcept
+ : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
+
+ _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator+=(const days& __dd) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator-=(const days& __dd) noexcept;
+ _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd <= 6; }
+ _LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept;
+};
+
+
+// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+unsigned char weekday::__weekday_from_days(int __days) noexcept
+{
+ return static_cast<unsigned char>(
+ static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
+ );
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __lhs.c_encoding() == __rhs.c_encoding(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __lhs.c_encoding() < __rhs.c_encoding(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
+{
+ auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
+ auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
+ return weekday{static_cast<unsigned>(__mu - __yr * 7)};
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
+{
+ const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
+ const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7;
+ return days{__wdu - __wk * 7};
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+weekday& weekday::operator+=(const days& __dd) noexcept
+{ *this = *this + __dd; return *this; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+weekday& weekday::operator-=(const days& __dd) noexcept
+{ *this = *this - __dd; return *this; }
+
+class weekday_indexed {
+private:
+ chrono::weekday __wd;
+ unsigned char __idx;
+public:
+ _LIBCPP_HIDE_FROM_ABI weekday_indexed() = default;
+ _LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
+ : __wd{__wdval}, __idx(__idxval) {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
+{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+class weekday_last {
+private:
+ chrono::weekday __wd;
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
+ : __wd{__val} {}
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd.ok(); }
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
+{ return __lhs.weekday() == __rhs.weekday(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
+
+
+inline constexpr weekday Sunday{0};
+inline constexpr weekday Monday{1};
+inline constexpr weekday Tuesday{2};
+inline constexpr weekday Wednesday{3};
+inline constexpr weekday Thursday{4};
+inline constexpr weekday Friday{5};
+inline constexpr weekday Saturday{6};
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_WEEKDAY_H
lib/libcxx/include/__chrono/year.h
@@ -0,0 +1,117 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_YEAR_H
+#define _LIBCPP___CHRONO_YEAR_H
+
+#include <__chrono/duration.h>
+#include <__config>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class year {
+private:
+ short __y;
+public:
+ _LIBCPP_HIDE_FROM_ABI year() = default;
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
+
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator++() noexcept { ++__y; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator--() noexcept { --__y; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
+ _LIBCPP_HIDE_FROM_ABI constexpr year& operator+=(const years& __dy) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year& operator-=(const years& __dy) noexcept;
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+() const noexcept { return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y}; }
+
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
+ _LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; }
+ _LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{ 32767}; }
+};
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const year& __lhs, const year& __rhs) noexcept
+{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator< (const year& __lhs, const year& __rhs) noexcept
+{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator> (const year& __lhs, const year& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator<=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__rhs < __lhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator>=(const year& __lhs, const year& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year operator+ (const year& __lhs, const years& __rhs) noexcept
+{ return year(static_cast<int>(__lhs) + __rhs.count()); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year operator+ (const years& __lhs, const year& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year operator- (const year& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+years operator-(const year& __lhs, const year& __rhs) noexcept
+{ return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year& year::operator+=(const years& __dy) noexcept
+{ *this = *this + __dy; return *this; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year& year::operator-=(const years& __dy) noexcept
+{ *this = *this - __dy; return *this; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {
+ static_assert(static_cast<int>(std::numeric_limits<decltype(__y)>::max()) == static_cast<int>(max()));
+ return static_cast<int>(min()) <= __y;
+}
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___CHRONO_YEAR_H
lib/libcxx/include/__chrono/year_month.h
@@ -0,0 +1,114 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_YEAR_MONTH_H
+#define _LIBCPP___CHRONO_YEAR_MONTH_H
+
+#include <__chrono/duration.h>
+#include <__chrono/month.h>
+#include <__chrono/year.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class year_month {
+ chrono::year __y;
+ chrono::month __m;
+public:
+ _LIBCPP_HIDE_FROM_ABI year_month() = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
+ : __y{__yval}, __m{__mval} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
+{
+ int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
+ const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12;
+ __dmi = __dmi - __dy * 12 + 1;
+ return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
+{ return (__lhs.year() + __rhs) / __lhs.month(); }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+months operator-(const year_month& __lhs, const year_month& __rhs) noexcept
+{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr
+year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_YEAR_MONTH_H
lib/libcxx/include/__chrono/year_month_day.h
@@ -0,0 +1,323 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_YEAR_MONTH_DAY_H
+#define _LIBCPP___CHRONO_YEAR_MONTH_DAY_H
+
+#include <__chrono/calendar.h>
+#include <__chrono/day.h>
+#include <__chrono/duration.h>
+#include <__chrono/month.h>
+#include <__chrono/monthday.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__chrono/year.h>
+#include <__chrono/year_month.h>
+#include <__config>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class year_month_day_last;
+
+class year_month_day {
+private:
+ chrono::year __y;
+ chrono::month __m;
+ chrono::day __d;
+public:
+ _LIBCPP_HIDE_FROM_ABI year_month_day() = default;
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(
+ const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
+ : __y{__yval}, __m{__mval}, __d{__dval} {}
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(const sys_days& __sysd) noexcept
+ : year_month_day(__from_days(__sysd.time_since_epoch())) {}
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_day(const local_days& __locd) noexcept
+ : year_month_day(__from_days(__locd.time_since_epoch())) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const months& __dm) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const months& __dm) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const years& __dy) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const years& __dy) noexcept;
+
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr year_month_day __from_days(days __d) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
+};
+
+
+// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day year_month_day::__from_days(days __d) noexcept
+{
+ static_assert(numeric_limits<unsigned>::digits >= 18, "");
+ static_assert(numeric_limits<int>::digits >= 20 , "");
+ const int __z = __d.count() + 719468;
+ const int __era = (__z >= 0 ? __z : __z - 146096) / 146097;
+ const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096]
+ const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399]
+ const int __yr = static_cast<int>(__yoe) + __era * 400;
+ const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365]
+ const unsigned __mp = (5 * __doy + 2)/153; // [0, 11]
+ const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31]
+ const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12]
+ return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
+}
+
+// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+days year_month_day::__to_days() const noexcept
+{
+ static_assert(numeric_limits<unsigned>::digits >= 18, "");
+ static_assert(numeric_limits<int>::digits >= 20 , "");
+
+ const int __yr = static_cast<int>(__y) - (__m <= February);
+ const unsigned __mth = static_cast<unsigned>(__m);
+ const unsigned __dy = static_cast<unsigned>(__d);
+
+ const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
+ const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
+ const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365]
+ const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096]
+ return days{__era * 146097 + static_cast<int>(__doe) - 719468};
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{
+ if (__lhs.year() < __rhs.year()) return true;
+ if (__lhs.year() > __rhs.year()) return false;
+ if (__lhs.month() < __rhs.month()) return true;
+ if (__lhs.month() > __rhs.month()) return false;
+ return __lhs.day() < __rhs.day();
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
+{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator/(const year_month& __lhs, int __rhs) noexcept
+{ return __lhs / day(__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept
+{ return __lhs / __rhs.month() / __rhs.day(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator/(int __lhs, const month_day& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator/(const month_day& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept
+{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept
+{ return __lhs + -__rhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+class year_month_day_last {
+private:
+ chrono::year __y;
+ chrono::month_day_last __mdl;
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
+ : __y{__yval}, __mdl{__mdlval} {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const months& __m) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const months& __m) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const years& __y) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const years& __y) noexcept;
+
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept;
+ _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+chrono::day year_month_day_last::day() const noexcept
+{
+ constexpr chrono::day __d[] =
+ {
+ chrono::day(31), chrono::day(28), chrono::day(31),
+ chrono::day(30), chrono::day(31), chrono::day(30),
+ chrono::day(31), chrono::day(31), chrono::day(30),
+ chrono::day(31), chrono::day(30), chrono::day(31)
+ };
+ return (month() != February || !__y.is_leap()) && month().ok() ?
+ __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{
+ if (__lhs.year() < __rhs.year()) return true;
+ if (__lhs.year() > __rhs.year()) return false;
+ return __lhs.month_day_last() < __rhs.month_day_last();
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__rhs < __lhs);}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept
+{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept
+{ return year_month_day_last{__lhs, __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept
+{ return year_month_day_last{year{__lhs}, __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
+operator/(const month_day_last& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept
+{ return year{__rhs} / __lhs; }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / last; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept
+{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
+ : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool year_month_day::ok() const noexcept
+{
+ if (!__y.ok() || !__m.ok()) return false;
+ return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
+}
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_YEAR_MONTH_DAY_H
lib/libcxx/include/__chrono/year_month_weekday.h
@@ -0,0 +1,255 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H
+#define _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H
+
+#include <__chrono/calendar.h>
+#include <__chrono/day.h>
+#include <__chrono/duration.h>
+#include <__chrono/month.h>
+#include <__chrono/month_weekday.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__chrono/weekday.h>
+#include <__chrono/year.h>
+#include <__chrono/year_month.h>
+#include <__chrono/year_month_day.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+class year_month_weekday {
+ chrono::year __y;
+ chrono::month __m;
+ chrono::weekday_indexed __wdi;
+public:
+ _LIBCPP_HIDE_FROM_ABI year_month_weekday() = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
+ const chrono::weekday_indexed& __wdival) noexcept
+ : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const sys_days& __sysd) noexcept
+ : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
+ : year_month_weekday(__from_days(__locd.time_since_epoch())) {}
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const months&) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const months&) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const years&) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const years&) noexcept;
+
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi.index(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
+
+ _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept
+ {
+ if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
+ 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());
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr year_month_weekday __from_days(days __d) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday year_month_weekday::__from_days(days __d) noexcept
+{
+ const sys_days __sysd{__d};
+ const chrono::weekday __wd = chrono::weekday(__sysd);
+ const year_month_day __ymd = year_month_day(__sysd);
+ return year_month_weekday{__ymd.year(), __ymd.month(),
+ __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+days year_month_weekday::__to_days() const noexcept
+{
+ const sys_days __sysd = sys_days(__y/__m/1);
+ return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
+ .time_since_epoch();
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept
+{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept
+{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept
+{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+class year_month_weekday_last {
+private:
+ chrono::year __y;
+ chrono::month __m;
+ chrono::weekday_last __wdl;
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
+ const chrono::weekday_last& __wdlval) noexcept
+ : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
+ _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
+
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
+
+};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+days year_month_weekday_last::__to_days() const noexcept
+{
+ const sys_days __last = sys_days{__y/__m/last};
+ return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
+
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept
+{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept
+{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept
+{ return year(__lhs) / __rhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept
+{ return __rhs / __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
+{ return year(__rhs) / __lhs; }
+
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
+{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
+{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept
+{ return __rhs + __lhs; }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr
+year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept
+{ return __lhs + (-__rhs); }
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
+_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
+
+} // namespace chrono
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H
lib/libcxx/include/__compare/common_comparison_category.h
@@ -14,7 +14,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__compare/compare_partial_order_fallback.h
@@ -17,12 +17,12 @@
#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [cmp.alg]
namespace __compare_partial_order_fallback {
@@ -66,7 +66,7 @@ inline namespace __cpo {
inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{};
} // namespace __cpo
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/compare_strong_order_fallback.h
@@ -17,12 +17,12 @@
#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [cmp.alg]
namespace __compare_strong_order_fallback {
@@ -63,7 +63,7 @@ inline namespace __cpo {
inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{};
} // namespace __cpo
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/compare_three_way.h
@@ -15,12 +15,12 @@
#include <__utility/forward.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
struct _LIBCPP_TEMPLATE_VIS compare_three_way
{
@@ -34,7 +34,7 @@ struct _LIBCPP_TEMPLATE_VIS compare_three_way
using is_transparent = void;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/compare_three_way_result.h
@@ -13,7 +13,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__compare/compare_weak_order_fallback.h
@@ -17,12 +17,12 @@
#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [cmp.alg]
namespace __compare_weak_order_fallback {
@@ -63,7 +63,7 @@ inline namespace __cpo {
inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{};
} // namespace __cpo
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/is_eq.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__compare/ordering.h
@@ -13,7 +13,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__compare/partial_order.h
@@ -18,12 +18,12 @@
#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [cmp.alg]
namespace __partial_order {
@@ -64,7 +64,7 @@ inline namespace __cpo {
inline constexpr auto partial_order = __partial_order::__fn{};
} // namespace __cpo
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/strong_order.h
@@ -21,7 +21,7 @@
#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [cmp.alg]
namespace __strong_order {
@@ -127,7 +127,7 @@ inline namespace __cpo {
inline constexpr auto strong_order = __strong_order::__fn{};
} // namespace __cpo
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/synth_three_way.h
@@ -16,12 +16,12 @@
#include <__utility/declval.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [expos.only.func]
@@ -42,9 +42,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
};
template <class _Tp, class _Up = _Tp>
-using __synth_three_way_result = decltype(__synth_three_way(declval<_Tp&>(), declval<_Up&>()));
+using __synth_three_way_result = decltype(std::__synth_three_way(declval<_Tp&>(), declval<_Up&>()));
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/three_way_comparable.h
@@ -19,12 +19,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template<class _Tp, class _Cat>
concept __compares_as =
@@ -51,7 +51,7 @@ concept three_way_comparable_with =
{ __u <=> __t } -> __compares_as<_Cat>;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/weak_order.h
@@ -19,12 +19,12 @@
#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [cmp.alg]
namespace __weak_order {
@@ -93,7 +93,7 @@ inline namespace __cpo {
inline constexpr auto weak_order = __weak_order::__fn{};
} // namespace __cpo
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/arithmetic.h
@@ -10,15 +10,17 @@
#define _LIBCPP___CONCEPTS_ARITHMETIC_H
#include <__config>
+#include <__type_traits/is_signed_integer.h>
+#include <__type_traits/is_unsigned_integer.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concepts.arithmetic], arithmetic concepts
@@ -41,7 +43,7 @@ concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;
template <class _Tp>
concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/assignable.h
@@ -16,12 +16,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.assignable]
@@ -33,7 +33,7 @@ concept assignable_from =
{ __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/boolean_testable.h
@@ -14,12 +14,12 @@
#include <__utility/forward.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concepts.booleantestable]
@@ -31,7 +31,7 @@ concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t)
{ !_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/class_or_enum.h
@@ -13,12 +13,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// Whether a type is a class type or enumeration type according to the Core wording.
@@ -26,10 +26,11 @@ template<class _Tp>
concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
// Work around Clang bug https://llvm.org/PR52970
+// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
template<class _Tp>
concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/common_reference_with.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.commonref]
@@ -30,7 +30,7 @@ concept common_reference_with =
convertible_to<_Tp, common_reference_t<_Tp, _Up>> &&
convertible_to<_Up, common_reference_t<_Tp, _Up>>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/common_with.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.common]
@@ -40,7 +40,7 @@ concept common_with =
add_lvalue_reference_t<const _Tp>,
add_lvalue_reference_t<const _Up>>>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/constructible.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.constructible]
template<class _Tp, class... _Args>
@@ -49,7 +49,7 @@ concept copy_constructible =
constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/convertible_to.h
@@ -14,12 +14,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.convertible]
@@ -30,7 +30,7 @@ concept convertible_to =
static_cast<_To>(declval<_From>());
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/copyable.h
@@ -15,12 +15,12 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concepts.object]
@@ -32,7 +32,7 @@ concept copyable =
assignable_from<_Tp&, const _Tp&> &&
assignable_from<_Tp&, const _Tp>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/derived_from.h
@@ -13,12 +13,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.derived]
@@ -27,7 +27,7 @@ concept derived_from =
is_base_of_v<_Bp, _Dp> &&
is_convertible_v<const volatile _Dp*, const volatile _Bp*>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/destructible.h
@@ -13,19 +13,19 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.destructible]
template<class _Tp>
concept destructible = is_nothrow_destructible_v<_Tp>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/different_from.h
@@ -14,17 +14,17 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template<class _Tp, class _Up>
concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/equality_comparable.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.equalitycomparable]
@@ -46,7 +46,7 @@ concept equality_comparable_with =
__make_const_lvalue_ref<_Up>>> &&
__weakly_equality_comparable_with<_Tp, _Up>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/invocable.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.invocable]
@@ -34,7 +34,7 @@ concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
template<class _Fn, class... _Args>
concept regular_invocable = invocable<_Fn, _Args...>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/movable.h
@@ -16,12 +16,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concepts.object]
@@ -32,7 +32,7 @@ concept movable =
assignable_from<_Tp&, _Tp> &&
swappable<_Tp>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/predicate.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.predicate]
@@ -28,7 +28,7 @@ template<class _Fn, class... _Args>
concept predicate =
regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/regular.h
@@ -14,19 +14,19 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.object]
template<class _Tp>
concept regular = semiregular<_Tp> && equality_comparable<_Tp>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/relation.h
@@ -13,12 +13,12 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.relation]
@@ -37,7 +37,7 @@ concept equivalence_relation = relation<_Rp, _Tp, _Up>;
template<class _Rp, class _Tp, class _Up>
concept strict_weak_order = relation<_Rp, _Tp, _Up>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/same_as.h
@@ -13,12 +13,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.same]
@@ -28,7 +28,7 @@ concept __same_as_impl = _IsSame<_Tp, _Up>::value;
template<class _Tp, class _Up>
concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/semiregular.h
@@ -14,19 +14,19 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.object]
template<class _Tp>
concept semiregular = copyable<_Tp> && default_initializable<_Tp>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/swappable.h
@@ -20,12 +20,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.swappable]
@@ -109,7 +109,7 @@ concept swappable_with =
ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t));
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/totally_ordered.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [concept.totallyordered]
@@ -50,7 +50,7 @@ concept totally_ordered_with =
__make_const_lvalue_ref<_Up>>> &&
__partially_ordered_with<_Tp, _Up>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__coroutine/coroutine_handle.h
@@ -9,15 +9,15 @@
#ifndef _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
#define _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__functional/hash.h>
#include <__memory/addressof.h>
#include <compare>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
lib/libcxx/include/__coroutine/coroutine_traits.h
@@ -13,7 +13,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
lib/libcxx/include/__coroutine/noop_coroutine_handle.h
@@ -13,7 +13,7 @@
#include <__coroutine/coroutine_handle.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
@@ -66,7 +66,7 @@ private:
friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept;
#if __has_builtin(__builtin_coro_noop)
- _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept {
+ _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept {
this->__handle_ = __builtin_coro_noop();
}
lib/libcxx/include/__coroutine/trivial_awaitables.h
@@ -13,7 +13,7 @@
#include <__coroutine/coroutine_handle.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
lib/libcxx/include/__debug_utils/randomize_range.h
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H
+#define _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H
+
+#include <__config>
+
+#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
+# include <__algorithm/shuffle.h>
+# include <__type_traits/is_constant_evaluated.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _AlgPolicy, class _Iterator, class _Sentinel>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __debug_randomize_range(_Iterator __first, _Sentinel __last) {
+#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
+# ifdef _LIBCPP_CXX03_LANG
+# error Support for unspecified stability is only for C++11 and higher
+# endif
+
+ if (!__libcpp_is_constant_evaluated())
+ std::__shuffle<_AlgPolicy>(__first, __last, __libcpp_debug_randomizer());
+#else
+ (void)__first;
+ (void)__last;
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H
lib/libcxx/include/__filesystem/copy_options.h
@@ -13,6 +13,10 @@
#include <__availability>
#include <__config>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -34,41 +38,41 @@ enum class _LIBCPP_ENUM_VIS copy_options : unsigned short {
};
_LIBCPP_INLINE_VISIBILITY
-inline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) {
- return static_cast<copy_options>(static_cast<unsigned short>(_LHS) &
- static_cast<unsigned short>(_RHS));
+inline constexpr copy_options operator&(copy_options __lhs, copy_options __rhs) {
+ return static_cast<copy_options>(static_cast<unsigned short>(__lhs) &
+ static_cast<unsigned short>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) {
- return static_cast<copy_options>(static_cast<unsigned short>(_LHS) |
- static_cast<unsigned short>(_RHS));
+inline constexpr copy_options operator|(copy_options __lhs, copy_options __rhs) {
+ return static_cast<copy_options>(static_cast<unsigned short>(__lhs) |
+ static_cast<unsigned short>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) {
- return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^
- static_cast<unsigned short>(_RHS));
+inline constexpr copy_options operator^(copy_options __lhs, copy_options __rhs) {
+ return static_cast<copy_options>(static_cast<unsigned short>(__lhs) ^
+ static_cast<unsigned short>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr copy_options operator~(copy_options _LHS) {
- return static_cast<copy_options>(~static_cast<unsigned short>(_LHS));
+inline constexpr copy_options operator~(copy_options __lhs) {
+ return static_cast<copy_options>(~static_cast<unsigned short>(__lhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) {
- return _LHS = _LHS & _RHS;
+inline copy_options& operator&=(copy_options& __lhs, copy_options __rhs) {
+ return __lhs = __lhs & __rhs;
}
_LIBCPP_INLINE_VISIBILITY
-inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) {
- return _LHS = _LHS | _RHS;
+inline copy_options& operator|=(copy_options& __lhs, copy_options __rhs) {
+ return __lhs = __lhs | __rhs;
}
_LIBCPP_INLINE_VISIBILITY
-inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) {
- return _LHS = _LHS ^ _RHS;
+inline copy_options& operator^=(copy_options& __lhs, copy_options __rhs) {
+ return __lhs = __lhs ^ __rhs;
}
_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__filesystem/directory_entry.h
@@ -11,6 +11,7 @@
#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
#include <__availability>
+#include <__chrono/time_point.h>
#include <__config>
#include <__errc>
#include <__filesystem/file_status.h>
@@ -20,12 +21,16 @@
#include <__filesystem/operations.h>
#include <__filesystem/path.h>
#include <__filesystem/perms.h>
-#include <chrono>
+#include <__utility/unreachable.h>
#include <cstdint>
#include <cstdlib>
#include <iosfwd>
#include <system_error>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
@@ -358,7 +363,7 @@ private:
__ec->clear();
return __data_.__type_;
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY
@@ -379,7 +384,7 @@ private:
return __data_.__type_;
}
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY
@@ -394,7 +399,7 @@ private:
case _RefreshSymlink:
return file_status(__get_ft(__ec), __data_.__non_sym_perms_);
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY
@@ -410,7 +415,7 @@ private:
case _RefreshSymlinkUnresolved:
return file_status(__get_sym_ft(__ec), __data_.__sym_perms_);
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY
@@ -435,7 +440,7 @@ private:
return __data_.__size_;
}
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY
@@ -454,7 +459,7 @@ private:
return __data_.__nlink_;
}
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY
@@ -477,7 +482,7 @@ private:
return __data_.__write_time_;
}
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
private:
lib/libcxx/include/__filesystem/directory_iterator.h
@@ -10,9 +10,9 @@
#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
+#include <__assert>
#include <__availability>
#include <__config>
-#include <__debug>
#include <__filesystem/directory_entry.h>
#include <__filesystem/directory_options.h>
#include <__filesystem/path.h>
@@ -23,6 +23,10 @@
#include <cstddef>
#include <system_error>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -40,25 +44,31 @@ public:
public:
//ctor & dtor
+ _LIBCPP_HIDE_FROM_ABI
directory_iterator() noexcept {}
+ _LIBCPP_HIDE_FROM_ABI
explicit directory_iterator(const path& __p)
: directory_iterator(__p, nullptr) {}
+ _LIBCPP_HIDE_FROM_ABI
directory_iterator(const path& __p, directory_options __opts)
: directory_iterator(__p, nullptr, __opts) {}
+ _LIBCPP_HIDE_FROM_ABI
directory_iterator(const path& __p, error_code& __ec)
: directory_iterator(__p, &__ec) {}
+ _LIBCPP_HIDE_FROM_ABI
directory_iterator(const path& __p, directory_options __opts,
error_code& __ec)
: directory_iterator(__p, &__ec, __opts) {}
- directory_iterator(const directory_iterator&) = default;
- directory_iterator(directory_iterator&&) = default;
- directory_iterator& operator=(const directory_iterator&) = default;
+ _LIBCPP_HIDE_FROM_ABI directory_iterator(const directory_iterator&) = default;
+ _LIBCPP_HIDE_FROM_ABI directory_iterator(directory_iterator&&) = default;
+ _LIBCPP_HIDE_FROM_ABI directory_iterator& operator=(const directory_iterator&) = default;
+ _LIBCPP_HIDE_FROM_ABI
directory_iterator& operator=(directory_iterator&& __o) noexcept {
// non-default implementation provided to support self-move assign.
if (this != &__o) {
@@ -67,27 +77,32 @@ public:
return *this;
}
- ~directory_iterator() = default;
+ _LIBCPP_HIDE_FROM_ABI ~directory_iterator() = default;
+ _LIBCPP_HIDE_FROM_ABI
const directory_entry& operator*() const {
_LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced");
return __dereference();
}
+ _LIBCPP_HIDE_FROM_ABI
const directory_entry* operator->() const { return &**this; }
+ _LIBCPP_HIDE_FROM_ABI
directory_iterator& operator++() { return __increment(); }
+ _LIBCPP_HIDE_FROM_ABI
__dir_element_proxy operator++(int) {
__dir_element_proxy __p(**this);
__increment();
return __p;
}
+ _LIBCPP_HIDE_FROM_ABI
directory_iterator& increment(error_code& __ec) { return __increment(&__ec); }
private:
- inline _LIBCPP_INLINE_VISIBILITY friend bool
+ inline _LIBCPP_HIDE_FROM_ABI friend bool
operator==(const directory_iterator& __lhs,
const directory_iterator& __rhs) noexcept;
@@ -106,25 +121,25 @@ private:
shared_ptr<__dir_stream> __imp_;
};
-inline _LIBCPP_INLINE_VISIBILITY bool
+inline _LIBCPP_HIDE_FROM_ABI bool
operator==(const directory_iterator& __lhs,
const directory_iterator& __rhs) noexcept {
return __lhs.__imp_ == __rhs.__imp_;
}
-inline _LIBCPP_INLINE_VISIBILITY bool
+inline _LIBCPP_HIDE_FROM_ABI bool
operator!=(const directory_iterator& __lhs,
const directory_iterator& __rhs) noexcept {
return !(__lhs == __rhs);
}
// enable directory_iterator range-based for statements
-inline _LIBCPP_INLINE_VISIBILITY directory_iterator
+inline _LIBCPP_HIDE_FROM_ABI directory_iterator
begin(directory_iterator __iter) noexcept {
return __iter;
}
-inline _LIBCPP_INLINE_VISIBILITY directory_iterator
+inline _LIBCPP_HIDE_FROM_ABI directory_iterator
end(directory_iterator) noexcept {
return directory_iterator();
}
@@ -133,7 +148,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP
_LIBCPP_END_NAMESPACE_FILESYSTEM
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <>
_LIBCPP_AVAILABILITY_FILESYSTEM
@@ -143,7 +158,7 @@ template <>
_LIBCPP_AVAILABILITY_FILESYSTEM
inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP_CXX03_LANG
lib/libcxx/include/__filesystem/directory_options.h
@@ -13,6 +13,10 @@
#include <__availability>
#include <__config>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -26,47 +30,47 @@ enum class _LIBCPP_ENUM_VIS directory_options : unsigned char {
};
_LIBCPP_INLINE_VISIBILITY
-inline constexpr directory_options operator&(directory_options _LHS,
- directory_options _RHS) {
- return static_cast<directory_options>(static_cast<unsigned char>(_LHS) &
- static_cast<unsigned char>(_RHS));
+inline constexpr directory_options operator&(directory_options __lhs,
+ directory_options __rhs) {
+ return static_cast<directory_options>(static_cast<unsigned char>(__lhs) &
+ static_cast<unsigned char>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr directory_options operator|(directory_options _LHS,
- directory_options _RHS) {
- return static_cast<directory_options>(static_cast<unsigned char>(_LHS) |
- static_cast<unsigned char>(_RHS));
+inline constexpr directory_options operator|(directory_options __lhs,
+ directory_options __rhs) {
+ return static_cast<directory_options>(static_cast<unsigned char>(__lhs) |
+ static_cast<unsigned char>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr directory_options operator^(directory_options _LHS,
- directory_options _RHS) {
- return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^
- static_cast<unsigned char>(_RHS));
+inline constexpr directory_options operator^(directory_options __lhs,
+ directory_options __rhs) {
+ return static_cast<directory_options>(static_cast<unsigned char>(__lhs) ^
+ static_cast<unsigned char>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr directory_options operator~(directory_options _LHS) {
- return static_cast<directory_options>(~static_cast<unsigned char>(_LHS));
+inline constexpr directory_options operator~(directory_options __lhs) {
+ return static_cast<directory_options>(~static_cast<unsigned char>(__lhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline directory_options& operator&=(directory_options& _LHS,
- directory_options _RHS) {
- return _LHS = _LHS & _RHS;
+inline directory_options& operator&=(directory_options& __lhs,
+ directory_options __rhs) {
+ return __lhs = __lhs & __rhs;
}
_LIBCPP_INLINE_VISIBILITY
-inline directory_options& operator|=(directory_options& _LHS,
- directory_options _RHS) {
- return _LHS = _LHS | _RHS;
+inline directory_options& operator|=(directory_options& __lhs,
+ directory_options __rhs) {
+ return __lhs = __lhs | __rhs;
}
_LIBCPP_INLINE_VISIBILITY
-inline directory_options& operator^=(directory_options& _LHS,
- directory_options _RHS) {
- return _LHS = _LHS ^ _RHS;
+inline directory_options& operator^=(directory_options& __lhs,
+ directory_options __rhs) {
+ return __lhs = __lhs ^ __rhs;
}
_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__filesystem/file_status.h
@@ -15,6 +15,10 @@
#include <__filesystem/file_type.h>
#include <__filesystem/perms.h>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/file_time_type.h
@@ -11,8 +11,13 @@
#define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
#include <__availability>
+#include <__chrono/file_clock.h>
+#include <__chrono/time_point.h>
#include <__config>
-#include <chrono>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
#ifndef _LIBCPP_CXX03_LANG
lib/libcxx/include/__filesystem/file_type.h
@@ -13,6 +13,10 @@
#include <__availability>
#include <__config>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/filesystem_error.h
@@ -19,6 +19,10 @@
#include <system_error>
#include <type_traits>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/operations.h
@@ -11,6 +11,7 @@
#define _LIBCPP___FILESYSTEM_OPERATIONS_H
#include <__availability>
+#include <__chrono/time_point.h>
#include <__config>
#include <__filesystem/copy_options.h>
#include <__filesystem/file_status.h>
@@ -20,10 +21,13 @@
#include <__filesystem/perm_options.h>
#include <__filesystem/perms.h>
#include <__filesystem/space_info.h>
-#include <chrono>
#include <cstdint>
#include <system_error>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -35,10 +39,10 @@ _LIBCPP_FUNC_VIS path __canonical(const path&, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS bool __copy_file(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS void __copy(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr);
-_LIBCPP_FUNC_VIS bool __create_directories(const path& p, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS bool __create_directories(const path&, error_code* = nullptr);
_LIBCPP_FUNC_VIS void __create_directory_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);
-_LIBCPP_FUNC_VIS bool __create_directory(const path& p, error_code* ec = nullptr);
-_LIBCPP_FUNC_VIS bool __create_directory(const path& p, const path& attributes, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS bool __create_directory(const path&, error_code* = nullptr);
+_LIBCPP_FUNC_VIS bool __create_directory(const path&, const path& __attributes, error_code* = nullptr);
_LIBCPP_FUNC_VIS void __create_hard_link(const path& __to, const path& __new_hard_link, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS void __create_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS path __current_path(error_code* __ec = nullptr);
@@ -48,51 +52,51 @@ _LIBCPP_FUNC_VIS file_status __status(const path&, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS uintmax_t __file_size(const path&, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS file_status __symlink_status(const path&, error_code* __ec = nullptr);
-_LIBCPP_FUNC_VIS file_time_type __last_write_time(const path& p, error_code* ec = nullptr);
-_LIBCPP_FUNC_VIS void __last_write_time(const path& p, file_time_type new_time, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS file_time_type __last_write_time(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS void __last_write_time(const path&, file_time_type __new_time, error_code* __ec = nullptr);
_LIBCPP_FUNC_VIS path __weakly_canonical(path const& __p, error_code* __ec = nullptr);
-_LIBCPP_FUNC_VIS path __read_symlink(const path& p, error_code* ec = nullptr);
-_LIBCPP_FUNC_VIS uintmax_t __remove_all(const path& p, error_code* ec = nullptr);
-_LIBCPP_FUNC_VIS bool __remove(const path& p, error_code* ec = nullptr);
-_LIBCPP_FUNC_VIS void __rename(const path& from, const path& to, error_code* ec = nullptr);
-_LIBCPP_FUNC_VIS void __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr);
+_LIBCPP_FUNC_VIS path __read_symlink(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS uintmax_t __remove_all(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS bool __remove(const path&, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS void __rename(const path& __from, const path& __to, error_code* __ec = nullptr);
+_LIBCPP_FUNC_VIS void __resize_file(const path&, uintmax_t __size, error_code* = nullptr);
_LIBCPP_FUNC_VIS path __temp_directory_path(error_code* __ec = nullptr);
-inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) { return __absolute(__p); }
-inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) { return __canonical(__p); }
-inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); }
-inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); }
-inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { return __copy_file(__from, __to, __opt, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); }
-inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept { __copy_symlink(__from, __to, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); }
-inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); }
-inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) { return __create_directories(__p); }
-inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __target, const path& __link) { __create_directory_symlink(__target, __link); }
-inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { __create_directory_symlink(__target, __link, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) { return __create_directory(__p); }
-inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); }
-inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __target, const path& __link) { __create_hard_link(__target, __link); }
-inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept { __create_hard_link(__target, __link, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __target, const path& __link) { __create_symlink(__target, __link); }
-inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { return __create_symlink(__target, __link, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY path current_path() { return __current_path(); }
-inline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) { return __current_path(&__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) { __current_path(__p); }
-inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); }
-inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; }
-inline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; }
-inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) { return exists(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); }
+inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p) { return __canonical(__p); }
+inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); }
+inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); }
+inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { return __copy_file(__from, __to, __opt, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); }
+inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept { __copy_symlink(__from, __to, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); }
+inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); }
+inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p) { return __create_directories(__p); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link) { __create_directory_symlink(__target, __link); }
+inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { __create_directory_symlink(__target, __link, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p) { return __create_directory(__p); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); }
+inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link) { __create_hard_link(__target, __link); }
+inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept { __create_hard_link(__target, __link, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link) { __create_symlink(__target, __link); }
+inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { return __create_symlink(__target, __link, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path current_path() { return __current_path(); }
+inline _LIBCPP_HIDE_FROM_ABI path current_path(error_code& __ec) { return __current_path(&__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p) { __current_path(__p); }
+inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); }
+inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; }
+inline _LIBCPP_HIDE_FROM_ABI bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; }
+inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p) { return exists(__status(__p)); }
inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) noexcept {
auto __s = __status(__p, &__ec);
@@ -101,45 +105,45 @@ inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec)
return exists(__s);
}
-inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) { return __file_size(__p); }
-inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); }
-inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; }
-inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) { return is_block_file(__status(__p)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; }
-inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) { return is_character_file(__status(__p)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; }
-inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) { return is_directory(__status(__p)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p, error_code& __ec) noexcept { return is_directory(__status(__p, &__ec)); }
-_LIBCPP_FUNC_VIS bool __fs_is_empty(const path& p, error_code* ec = nullptr);
-inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) { return __fs_is_empty(__p); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; }
-inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) { return is_fifo(__status(__p)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; }
-inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; }
-inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) { return is_other(__status(__p)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; }
-inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) { return is_socket(__status(__p)); }
-inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); }
-inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p) { return __last_write_time(__p); }
-inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); }
-inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { __last_write_time(__p, __t, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p) { return __file_size(__p); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p) { return is_block_file(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p) { return is_character_file(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_directory(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept { return is_directory(__status(__p, &__ec)); }
+_LIBCPP_FUNC_VIS bool __fs_is_empty(const path& __p, error_code* __ec = nullptr);
+inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p) { return is_fifo(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p) { return is_other(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; }
+inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p) { return is_socket(__status(__p)); }
+inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); }
+inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p) { return __last_write_time(__p); }
+inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); }
+inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { __last_write_time(__p, __t, &__ec); }
_LIBCPP_FUNC_VIS void __permissions(const path&, perms, perm_options, error_code* = nullptr);
-inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); }
-inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); }
+inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); }
inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base, error_code& __ec) {
path __tmp = __weakly_canonical(__p, &__ec);
@@ -151,10 +155,10 @@ inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __b
return __tmp.lexically_proximate(__tmp_base);
}
-inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); }
-inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); }
-inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) { return __read_symlink(__p); }
-inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); }
+inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); }
+inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p) { return __read_symlink(__p); }
+inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); }
inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base, error_code& __ec) {
path __tmp = __weakly_canonical(__p, &__ec);
@@ -166,27 +170,27 @@ inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __ba
return __tmp.lexically_relative(__tmpbase);
}
-inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); }
-inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); }
-inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) { return __remove_all(__p); }
-inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) { return __remove(__p); }
-inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to) { return __rename(__from, __to); }
-inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); }
-inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { return __resize_file(__p, __ns, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); }
+inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p) { return __remove_all(__p); }
+inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p) { return __remove(__p); }
+inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to) { return __rename(__from, __to); }
+inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); }
+inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { return __resize_file(__p, __ns, &__ec); }
_LIBCPP_FUNC_VIS space_info __space(const path&, error_code* __ec = nullptr);
-inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) { return __space(__p); }
-inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) { return __status(__p); }
-inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) { return __symlink_status(__p); }
-inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); }
-inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() { return __temp_directory_path(); }
-inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); }
-inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) { return __weakly_canonical(__p); }
-inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); }
+inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p) { return __status(__p); }
+inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p) { return __symlink_status(__p); }
+inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path() { return __temp_directory_path(); }
+inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); }
+inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p) { return __weakly_canonical(__p); }
+inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); }
_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__filesystem/path.h
@@ -10,6 +10,8 @@
#ifndef _LIBCPP___FILESYSTEM_PATH_H
#define _LIBCPP___FILESYSTEM_PATH_H
+#include <__algorithm/replace.h>
+#include <__algorithm/replace_copy.h>
#include <__availability>
#include <__config>
#include <__iterator/back_insert_iterator.h>
@@ -24,6 +26,10 @@
# include <locale>
#endif
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -65,6 +71,7 @@ struct __can_convert_char<char32_t> {
};
template <class _ECharT>
+_LIBCPP_HIDE_FROM_ABI
typename enable_if<__can_convert_char<_ECharT>::value, bool>::type
__is_separator(_ECharT __e) {
#if defined(_LIBCPP_WIN32API)
@@ -95,10 +102,16 @@ struct __is_pathable_string<
: public __can_convert_char<_ECharT> {
using _Str = basic_string<_ECharT, _Traits, _Alloc>;
using _Base = __can_convert_char<_ECharT>;
+
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
+
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT const* __range_end(_Str const& __s) {
return __s.data() + __s.length();
}
+
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT __first_or_null(_Str const& __s) {
return __s.empty() ? _ECharT{} : __s[0];
}
@@ -111,10 +124,16 @@ struct __is_pathable_string<
: public __can_convert_char<_ECharT> {
using _Str = basic_string_view<_ECharT, _Traits>;
using _Base = __can_convert_char<_ECharT>;
+
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
+
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT const* __range_end(_Str const& __s) {
return __s.data() + __s.length();
}
+
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT __first_or_null(_Str const& __s) {
return __s.empty() ? _ECharT{} : __s[0];
}
@@ -132,7 +151,10 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
: __can_convert_char<typename remove_const<_ECharT>::type> {
using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
+
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT const* __range_end(const _ECharT* __b) {
using _Iter = const _ECharT*;
const _ECharT __sentinel = _ECharT{};
@@ -142,6 +164,7 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
return __e;
}
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }
};
@@ -158,9 +181,13 @@ struct __is_pathable_iter<
using _ECharT = typename iterator_traits<_Iter>::value_type;
using _Base = __can_convert_char<_ECharT>;
+ _LIBCPP_HIDE_FROM_ABI
static _Iter __range_begin(_Iter __b) { return __b; }
+
+ _LIBCPP_HIDE_FROM_ABI
static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; }
+ _LIBCPP_HIDE_FROM_ABI
static _ECharT __first_or_null(_Iter __b) { return *__b; }
};
@@ -210,6 +237,7 @@ struct _PathCVT {
typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener;
#endif
+ _LIBCPP_HIDE_FROM_ABI
static void __append_range(__path_string& __dest, _ECharT const* __b,
_ECharT const* __e) {
#if defined(_LIBCPP_WIN32API)
@@ -222,6 +250,7 @@ struct _PathCVT {
}
template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI
static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
if (__b == __e)
@@ -239,6 +268,7 @@ struct _PathCVT {
}
template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI
static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
const _ECharT __sentinel = _ECharT{};
@@ -259,6 +289,7 @@ struct _PathCVT {
}
template <class _Source>
+ _LIBCPP_HIDE_FROM_ABI
static void __append_source(__path_string& __dest, _Source const& __s) {
using _Traits = __is_pathable<_Source>;
__append_range(__dest, _Traits::__range_begin(__s),
@@ -271,6 +302,7 @@ template <>
struct _PathCVT<__path_value> {
template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI
static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
__append_range(__path_string& __dest, _Iter __b, _Iter __e) {
for (; __b != __e; ++__b)
@@ -278,12 +310,14 @@ struct _PathCVT<__path_value> {
}
template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI
static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
__append_range(__path_string& __dest, _Iter __b, _Iter __e) {
__dest.append(__b, __e);
}
template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI
static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
const char __sentinel = char{};
for (; *__b != __sentinel; ++__b)
@@ -291,6 +325,7 @@ struct _PathCVT<__path_value> {
}
template <class _Source>
+ _LIBCPP_HIDE_FROM_ABI
static void __append_source(__path_string& __dest, _Source const& __s) {
using _Traits = __is_pathable<_Source>;
__append_range(__dest, _Traits::__range_begin(__s),
@@ -302,6 +337,7 @@ struct _PathCVT<__path_value> {
template <>
struct _PathCVT<char> {
+ _LIBCPP_HIDE_FROM_ABI
static void
__append_string(__path_string& __dest, const basic_string<char> &__str) {
size_t __size = __char_to_wide(__str, nullptr, 0);
@@ -311,6 +347,7 @@ struct _PathCVT<char> {
}
template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI
static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type
__append_range(__path_string& __dest, _Iter __b, _Iter __e) {
basic_string<char> __tmp(__b, __e);
@@ -318,6 +355,7 @@ struct _PathCVT<char> {
}
template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI
static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
__append_range(__path_string& __dest, _Iter __b, _Iter __e) {
basic_string<char> __tmp(__b, __e);
@@ -325,6 +363,7 @@ struct _PathCVT<char> {
}
template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI
static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
const char __sentinel = char{};
basic_string<char> __tmp;
@@ -334,6 +373,7 @@ struct _PathCVT<char> {
}
template <class _Source>
+ _LIBCPP_HIDE_FROM_ABI
static void __append_source(__path_string& __dest, _Source const& __s) {
using _Traits = __is_pathable<_Source>;
__append_range(__dest, _Traits::__range_begin(__s),
@@ -347,6 +387,7 @@ struct _PathExport {
typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener;
template <class _Str>
+ _LIBCPP_HIDE_FROM_ABI
static void __append(_Str& __dest, const __path_string& __src) {
string __utf8;
_Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size());
@@ -357,6 +398,7 @@ struct _PathExport {
template <>
struct _PathExport<char> {
template <class _Str>
+ _LIBCPP_HIDE_FROM_ABI
static void __append(_Str& __dest, const __path_string& __src) {
size_t __size = __wide_to_char(__src, nullptr, 0);
size_t __pos = __dest.size();
@@ -368,6 +410,7 @@ struct _PathExport<char> {
template <>
struct _PathExport<wchar_t> {
template <class _Str>
+ _LIBCPP_HIDE_FROM_ABI
static void __append(_Str& __dest, const __path_string& __src) {
__dest.append(__src.begin(), __src.end());
}
@@ -376,6 +419,7 @@ struct _PathExport<wchar_t> {
template <>
struct _PathExport<char16_t> {
template <class _Str>
+ _LIBCPP_HIDE_FROM_ABI
static void __append(_Str& __dest, const __path_string& __src) {
__dest.append(__src.begin(), __src.end());
}
@@ -387,6 +431,7 @@ struct _PathExport<char8_t> {
typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
template <class _Str>
+ _LIBCPP_HIDE_FROM_ABI
static void __append(_Str& __dest, const __path_string& __src) {
_Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());
}
@@ -423,21 +468,23 @@ public:
};
// constructors and destructor
- _LIBCPP_INLINE_VISIBILITY path() noexcept {}
- _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {}
- _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept
+ _LIBCPP_HIDE_FROM_ABI path() noexcept {}
+ _LIBCPP_HIDE_FROM_ABI path(const path& __p) : __pn_(__p.__pn_) {}
+ _LIBCPP_HIDE_FROM_ABI path(path&& __p) noexcept
: __pn_(_VSTD::move(__p.__pn_)) {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path(string_type&& __s, format = format::auto_format) noexcept
: __pn_(_VSTD::move(__s)) {}
template <class _Source, class = _EnableIfPathable<_Source, void> >
+ _LIBCPP_HIDE_FROM_ABI
path(const _Source& __src, format = format::auto_format) {
_SourceCVT<_Source>::__append_source(__pn_, __src);
}
template <class _InputIt>
+ _LIBCPP_HIDE_FROM_ABI
path(_InputIt __first, _InputIt __last, format = format::auto_format) {
typedef typename iterator_traits<_InputIt>::value_type _ItVal;
_PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
@@ -454,41 +501,42 @@ public:
#endif
*/
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
~path() = default;
// assignments
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& operator=(const path& __p) {
__pn_ = __p.__pn_;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& operator=(path&& __p) noexcept {
__pn_ = _VSTD::move(__p.__pn_);
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& operator=(string_type&& __s) noexcept {
__pn_ = _VSTD::move(__s);
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& assign(string_type&& __s) noexcept {
__pn_ = _VSTD::move(__s);
return *this;
}
template <class _Source>
- _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
+ _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source>
operator=(const _Source& __src) {
return this->assign(__src);
}
template <class _Source>
+ _LIBCPP_HIDE_FROM_ABI
_EnableIfPathable<_Source> assign(const _Source& __src) {
__pn_.clear();
_SourceCVT<_Source>::__append_source(__pn_, __src);
@@ -496,6 +544,7 @@ public:
}
template <class _InputIt>
+ _LIBCPP_HIDE_FROM_ABI
path& assign(_InputIt __first, _InputIt __last) {
typedef typename iterator_traits<_InputIt>::value_type _ItVal;
__pn_.clear();
@@ -506,6 +555,7 @@ public:
public:
// appends
#if defined(_LIBCPP_WIN32API)
+ _LIBCPP_HIDE_FROM_ABI
path& operator/=(const path& __p) {
auto __p_root_name = __p.__root_name();
auto __p_root_name_size = __p_root_name.size();
@@ -532,15 +582,18 @@ public:
}
template <class _Source>
+ _LIBCPP_HIDE_FROM_ABI
_EnableIfPathable<_Source> append(const _Source& __src) {
return operator/=(path(__src));
}
template <class _InputIt>
+ _LIBCPP_HIDE_FROM_ABI
path& append(_InputIt __first, _InputIt __last) {
return operator/=(path(__first, __last));
}
#else
+ _LIBCPP_HIDE_FROM_ABI
path& operator/=(const path& __p) {
if (__p.is_absolute()) {
__pn_ = __p.__pn_;
@@ -556,12 +609,13 @@ public:
// is known at compile time to be "/' since the user almost certainly intended
// to append a separator instead of overwriting the path with "/"
template <class _Source>
- _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
+ _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source>
operator/=(const _Source& __src) {
return this->append(__src);
}
template <class _Source>
+ _LIBCPP_HIDE_FROM_ABI
_EnableIfPathable<_Source> append(const _Source& __src) {
using _Traits = __is_pathable<_Source>;
using _CVT = _PathCVT<_SourceChar<_Source> >;
@@ -575,6 +629,7 @@ public:
}
template <class _InputIt>
+ _LIBCPP_HIDE_FROM_ABI
path& append(_InputIt __first, _InputIt __last) {
typedef typename iterator_traits<_InputIt>::value_type _ItVal;
static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
@@ -589,37 +644,38 @@ public:
#endif
// concatenation
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& operator+=(const path& __x) {
__pn_ += __x.__pn_;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& operator+=(const string_type& __x) {
__pn_ += __x;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& operator+=(__string_view __x) {
__pn_ += __x;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& operator+=(const value_type* __x) {
__pn_ += __x;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& operator+=(value_type __x) {
__pn_ += __x;
return *this;
}
template <class _ECharT>
+ _LIBCPP_HIDE_FROM_ABI
typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
operator+=(_ECharT __x) {
_PathCVT<_ECharT>::__append_source(__pn_,
@@ -628,17 +684,20 @@ public:
}
template <class _Source>
+ _LIBCPP_HIDE_FROM_ABI
_EnableIfPathable<_Source> operator+=(const _Source& __x) {
return this->concat(__x);
}
template <class _Source>
+ _LIBCPP_HIDE_FROM_ABI
_EnableIfPathable<_Source> concat(const _Source& __x) {
_SourceCVT<_Source>::__append_source(__pn_, __x);
return *this;
}
template <class _InputIt>
+ _LIBCPP_HIDE_FROM_ABI
path& concat(_InputIt __first, _InputIt __last) {
typedef typename iterator_traits<_InputIt>::value_type _ItVal;
_PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
@@ -646,9 +705,10 @@ public:
}
// modifiers
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void clear() noexcept { __pn_.clear(); }
+ _LIBCPP_HIDE_FROM_ABI
path& make_preferred() {
#if defined(_LIBCPP_WIN32API)
_VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');
@@ -656,7 +716,7 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
path& remove_filename() {
auto __fname = __filename();
if (!__fname.empty())
@@ -664,6 +724,7 @@ public:
return *this;
}
+ _LIBCPP_HIDE_FROM_ABI
path& replace_filename(const path& __replacement) {
remove_filename();
return (*this /= __replacement);
@@ -671,25 +732,26 @@ public:
path& replace_extension(const path& __replacement = path());
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
// private helper to allow reserving memory in the path
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void __reserve(size_t __s) { __pn_.reserve(__s); }
// native format observers
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
const string_type& native() const noexcept { return __pn_; }
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
const value_type* c_str() const noexcept { return __pn_.c_str(); }
- _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; }
+ _LIBCPP_HIDE_FROM_ABI operator string_type() const { return __pn_; }
#if defined(_LIBCPP_WIN32API)
- _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { return __pn_; }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::wstring wstring() const { return __pn_; }
+ _LIBCPP_HIDE_FROM_ABI
_VSTD::wstring generic_wstring() const {
_VSTD::wstring __s;
__s.resize(__pn_.size());
@@ -700,6 +762,7 @@ public:
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _ECharT, class _Traits = char_traits<_ECharT>,
class _Allocator = allocator<_ECharT> >
+ _LIBCPP_HIDE_FROM_ABI
basic_string<_ECharT, _Traits, _Allocator>
string(const _Allocator& __a = _Allocator()) const {
using _Str = basic_string<_ECharT, _Traits, _Allocator>;
@@ -709,10 +772,10 @@ public:
return __s;
}
- _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const {
+ _LIBCPP_HIDE_FROM_ABI _VSTD::string string() const {
return string<char>();
}
- _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const {
+ _LIBCPP_HIDE_FROM_ABI __u8_string u8string() const {
using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
__u8_string __s;
__s.reserve(__pn_.size());
@@ -720,16 +783,17 @@ public:
return __s;
}
- _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u16string u16string() const {
return string<char16_t>();
}
- _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u32string u32string() const {
return string<char32_t>();
}
// generic format observers
template <class _ECharT, class _Traits = char_traits<_ECharT>,
class _Allocator = allocator<_ECharT> >
+ _LIBCPP_HIDE_FROM_ABI
basic_string<_ECharT, _Traits, _Allocator>
generic_string(const _Allocator& __a = _Allocator()) const {
using _Str = basic_string<_ECharT, _Traits, _Allocator>;
@@ -742,9 +806,10 @@ public:
return __s;
}
- _VSTD::string generic_string() const { return generic_string<char>(); }
- _VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); }
- _VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_string() const { return generic_string<char>(); }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); }
+ _LIBCPP_HIDE_FROM_ABI
__u8_string generic_u8string() const {
__u8_string __s = u8string();
_VSTD::replace(__s.begin(), __s.end(), '\\', '/');
@@ -753,16 +818,17 @@ public:
#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
#else /* _LIBCPP_WIN32API */
- _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::string string() const { return __pn_; }
#ifndef _LIBCPP_HAS_NO_CHAR8_T
- _LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
#else
- _LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::string u8string() const { return __pn_; }
#endif
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _ECharT, class _Traits = char_traits<_ECharT>,
class _Allocator = allocator<_ECharT> >
+ _LIBCPP_HIDE_FROM_ABI
basic_string<_ECharT, _Traits, _Allocator>
string(const _Allocator& __a = _Allocator()) const {
using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;
@@ -774,39 +840,40 @@ public:
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const {
+ _LIBCPP_HIDE_FROM_ABI _VSTD::wstring wstring() const {
return string<wchar_t>();
}
#endif
- _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const {
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u16string u16string() const {
return string<char16_t>();
}
- _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const {
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u32string u32string() const {
return string<char32_t>();
}
#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
// generic format observers
- _VSTD::string generic_string() const { return __pn_; }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_string() const { return __pn_; }
#ifndef _LIBCPP_HAS_NO_CHAR8_T
- _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
#else
- _VSTD::string generic_u8string() const { return __pn_; }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_u8string() const { return __pn_; }
#endif
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _ECharT, class _Traits = char_traits<_ECharT>,
class _Allocator = allocator<_ECharT> >
+ _LIBCPP_HIDE_FROM_ABI
basic_string<_ECharT, _Traits, _Allocator>
generic_string(const _Allocator& __a = _Allocator()) const {
return string<_ECharT, _Traits, _Allocator>(__a);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- _VSTD::wstring generic_wstring() const { return string<wchar_t>(); }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::wstring generic_wstring() const { return string<wchar_t>(); }
#endif
- _VSTD::u16string generic_u16string() const { return string<char16_t>(); }
- _VSTD::u32string generic_u32string() const { return string<char32_t>(); }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u16string generic_u16string() const { return string<char16_t>(); }
+ _LIBCPP_HIDE_FROM_ABI _VSTD::u32string generic_u32string() const { return string<char32_t>(); }
#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
#endif /* !_LIBCPP_WIN32API */
@@ -823,77 +890,77 @@ private:
public:
// compare
- _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept {
+ _LIBCPP_HIDE_FROM_ABI int compare(const path& __p) const noexcept {
return __compare(__p.__pn_);
}
- _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const {
+ _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const {
return __compare(__s);
}
- _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const {
+ _LIBCPP_HIDE_FROM_ABI int compare(__string_view __s) const {
return __compare(__s);
}
- _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const {
+ _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const {
return __compare(__s);
}
// decomposition
- _LIBCPP_INLINE_VISIBILITY path root_name() const {
+ _LIBCPP_HIDE_FROM_ABI path root_name() const {
return string_type(__root_name());
}
- _LIBCPP_INLINE_VISIBILITY path root_directory() const {
+ _LIBCPP_HIDE_FROM_ABI path root_directory() const {
return string_type(__root_directory());
}
- _LIBCPP_INLINE_VISIBILITY path root_path() const {
+ _LIBCPP_HIDE_FROM_ABI path root_path() const {
#if defined(_LIBCPP_WIN32API)
return string_type(__root_path_raw());
#else
return root_name().append(string_type(__root_directory()));
#endif
}
- _LIBCPP_INLINE_VISIBILITY path relative_path() const {
+ _LIBCPP_HIDE_FROM_ABI path relative_path() const {
return string_type(__relative_path());
}
- _LIBCPP_INLINE_VISIBILITY path parent_path() const {
+ _LIBCPP_HIDE_FROM_ABI path parent_path() const {
return string_type(__parent_path());
}
- _LIBCPP_INLINE_VISIBILITY path filename() const {
+ _LIBCPP_HIDE_FROM_ABI path filename() const {
return string_type(__filename());
}
- _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); }
- _LIBCPP_INLINE_VISIBILITY path extension() const {
+ _LIBCPP_HIDE_FROM_ABI path stem() const { return string_type(__stem()); }
+ _LIBCPP_HIDE_FROM_ABI path extension() const {
return string_type(__extension());
}
// query
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool
empty() const noexcept {
return __pn_.empty();
}
- _LIBCPP_INLINE_VISIBILITY bool has_root_name() const {
+ _LIBCPP_HIDE_FROM_ABI bool has_root_name() const {
return !__root_name().empty();
}
- _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const {
+ _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const {
return !__root_directory().empty();
}
- _LIBCPP_INLINE_VISIBILITY bool has_root_path() const {
+ _LIBCPP_HIDE_FROM_ABI bool has_root_path() const {
return !__root_path_raw().empty();
}
- _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const {
+ _LIBCPP_HIDE_FROM_ABI bool has_relative_path() const {
return !__relative_path().empty();
}
- _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const {
+ _LIBCPP_HIDE_FROM_ABI bool has_parent_path() const {
return !__parent_path().empty();
}
- _LIBCPP_INLINE_VISIBILITY bool has_filename() const {
+ _LIBCPP_HIDE_FROM_ABI bool has_filename() const {
return !__filename().empty();
}
- _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); }
- _LIBCPP_INLINE_VISIBILITY bool has_extension() const {
+ _LIBCPP_HIDE_FROM_ABI bool has_stem() const { return !__stem().empty(); }
+ _LIBCPP_HIDE_FROM_ABI bool has_extension() const {
return !__extension().empty();
}
- _LIBCPP_INLINE_VISIBILITY bool is_absolute() const {
+ _LIBCPP_HIDE_FROM_ABI bool is_absolute() const {
#if defined(_LIBCPP_WIN32API)
__string_view __root_name_str = __root_name();
__string_view __root_dir = __root_directory();
@@ -917,13 +984,13 @@ public:
return has_root_directory();
#endif
}
- _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); }
+ _LIBCPP_HIDE_FROM_ABI bool is_relative() const { return !is_absolute(); }
// relative paths
path lexically_normal() const;
path lexically_relative(const path& __base) const;
- _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const {
+ _LIBCPP_HIDE_FROM_ABI path lexically_proximate(const path& __base) const {
path __result = this->lexically_relative(__base);
if (__result.native().empty())
return *this;
@@ -939,7 +1006,7 @@ public:
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _CharT, class _Traits>
- _LIBCPP_INLINE_VISIBILITY friend
+ _LIBCPP_HIDE_FROM_ABI friend
typename enable_if<is_same<_CharT, value_type>::value &&
is_same<_Traits, char_traits<value_type> >::value,
basic_ostream<_CharT, _Traits>&>::type
@@ -949,7 +1016,7 @@ public:
}
template <class _CharT, class _Traits>
- _LIBCPP_INLINE_VISIBILITY friend
+ _LIBCPP_HIDE_FROM_ABI friend
typename enable_if<!is_same<_CharT, value_type>::value ||
!is_same<_Traits, char_traits<value_type> >::value,
basic_ostream<_CharT, _Traits>&>::type
@@ -959,42 +1026,41 @@ public:
}
template <class _CharT, class _Traits>
- _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>&
+ _LIBCPP_HIDE_FROM_ABI friend basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) {
basic_string<_CharT, _Traits> __tmp;
- __is >> __quoted(__tmp);
+ __is >> _VSTD::__quoted(__tmp);
__p = __tmp;
return __is;
}
#endif // !_LIBCPP_HAS_NO_LOCALIZATION
- friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept {
return __lhs.__compare(__rhs.__pn_) == 0;
}
- friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept {
+ friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const path& __lhs, const path& __rhs) noexcept {
return __lhs.__compare(__rhs.__pn_) != 0;
}
- friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept {
+ friend _LIBCPP_HIDE_FROM_ABI bool operator<(const path& __lhs, const path& __rhs) noexcept {
return __lhs.__compare(__rhs.__pn_) < 0;
}
- friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept {
+ friend _LIBCPP_HIDE_FROM_ABI bool operator<=(const path& __lhs, const path& __rhs) noexcept {
return __lhs.__compare(__rhs.__pn_) <= 0;
}
- friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept {
+ friend _LIBCPP_HIDE_FROM_ABI bool operator>(const path& __lhs, const path& __rhs) noexcept {
return __lhs.__compare(__rhs.__pn_) > 0;
}
- friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept {
+ friend _LIBCPP_HIDE_FROM_ABI bool operator>=(const path& __lhs, const path& __rhs) noexcept {
return __lhs.__compare(__rhs.__pn_) >= 0;
}
- friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
- const path& __rhs) {
+ friend _LIBCPP_HIDE_FROM_ABI path operator/(const path& __lhs, const path& __rhs) {
path __result(__lhs);
__result /= __rhs;
return __result;
}
private:
- inline _LIBCPP_INLINE_VISIBILITY path&
+ inline _LIBCPP_HIDE_FROM_ABI path&
__assign_view(__string_view const& __s) noexcept {
__pn_ = string_type(__s);
return *this;
@@ -1002,7 +1068,7 @@ private:
string_type __pn_;
};
-inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept {
+inline _LIBCPP_HIDE_FROM_ABI void swap(path& __lhs, path& __rhs) noexcept {
__lhs.swap(__rhs);
}
lib/libcxx/include/__filesystem/path_iterator.h
@@ -10,15 +10,19 @@
#ifndef _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
+#include <__assert>
#include <__availability>
#include <__config>
-#include <__debug>
#include <__filesystem/path.h>
#include <__iterator/iterator_traits.h>
#include <cstddef>
#include <string>
#include <string_view>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/perm_options.h
@@ -13,6 +13,10 @@
#include <__availability>
#include <__config>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -27,41 +31,41 @@ enum class _LIBCPP_ENUM_VIS perm_options : unsigned char {
};
_LIBCPP_INLINE_VISIBILITY
-inline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) {
- return static_cast<perm_options>(static_cast<unsigned>(_LHS) &
- static_cast<unsigned>(_RHS));
+inline constexpr perm_options operator&(perm_options __lhs, perm_options __rhs) {
+ return static_cast<perm_options>(static_cast<unsigned>(__lhs) &
+ static_cast<unsigned>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) {
- return static_cast<perm_options>(static_cast<unsigned>(_LHS) |
- static_cast<unsigned>(_RHS));
+inline constexpr perm_options operator|(perm_options __lhs, perm_options __rhs) {
+ return static_cast<perm_options>(static_cast<unsigned>(__lhs) |
+ static_cast<unsigned>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) {
- return static_cast<perm_options>(static_cast<unsigned>(_LHS) ^
- static_cast<unsigned>(_RHS));
+inline constexpr perm_options operator^(perm_options __lhs, perm_options __rhs) {
+ return static_cast<perm_options>(static_cast<unsigned>(__lhs) ^
+ static_cast<unsigned>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr perm_options operator~(perm_options _LHS) {
- return static_cast<perm_options>(~static_cast<unsigned>(_LHS));
+inline constexpr perm_options operator~(perm_options __lhs) {
+ return static_cast<perm_options>(~static_cast<unsigned>(__lhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) {
- return _LHS = _LHS & _RHS;
+inline perm_options& operator&=(perm_options& __lhs, perm_options __rhs) {
+ return __lhs = __lhs & __rhs;
}
_LIBCPP_INLINE_VISIBILITY
-inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) {
- return _LHS = _LHS | _RHS;
+inline perm_options& operator|=(perm_options& __lhs, perm_options __rhs) {
+ return __lhs = __lhs | __rhs;
}
_LIBCPP_INLINE_VISIBILITY
-inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) {
- return _LHS = _LHS ^ _RHS;
+inline perm_options& operator^=(perm_options& __lhs, perm_options __rhs) {
+ return __lhs = __lhs ^ __rhs;
}
_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__filesystem/perms.h
@@ -13,6 +13,10 @@
#include <__availability>
#include <__config>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -51,36 +55,36 @@ enum class _LIBCPP_ENUM_VIS perms : unsigned {
};
_LIBCPP_INLINE_VISIBILITY
-inline constexpr perms operator&(perms _LHS, perms _RHS) {
- return static_cast<perms>(static_cast<unsigned>(_LHS) &
- static_cast<unsigned>(_RHS));
+inline constexpr perms operator&(perms __lhs, perms __rhs) {
+ return static_cast<perms>(static_cast<unsigned>(__lhs) &
+ static_cast<unsigned>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr perms operator|(perms _LHS, perms _RHS) {
- return static_cast<perms>(static_cast<unsigned>(_LHS) |
- static_cast<unsigned>(_RHS));
+inline constexpr perms operator|(perms __lhs, perms __rhs) {
+ return static_cast<perms>(static_cast<unsigned>(__lhs) |
+ static_cast<unsigned>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr perms operator^(perms _LHS, perms _RHS) {
- return static_cast<perms>(static_cast<unsigned>(_LHS) ^
- static_cast<unsigned>(_RHS));
+inline constexpr perms operator^(perms __lhs, perms __rhs) {
+ return static_cast<perms>(static_cast<unsigned>(__lhs) ^
+ static_cast<unsigned>(__rhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline constexpr perms operator~(perms _LHS) {
- return static_cast<perms>(~static_cast<unsigned>(_LHS));
+inline constexpr perms operator~(perms __lhs) {
+ return static_cast<perms>(~static_cast<unsigned>(__lhs));
}
_LIBCPP_INLINE_VISIBILITY
-inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; }
+inline perms& operator&=(perms& __lhs, perms __rhs) { return __lhs = __lhs & __rhs; }
_LIBCPP_INLINE_VISIBILITY
-inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; }
+inline perms& operator|=(perms& __lhs, perms __rhs) { return __lhs = __lhs | __rhs; }
_LIBCPP_INLINE_VISIBILITY
-inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; }
+inline perms& operator^=(perms& __lhs, perms __rhs) { return __lhs = __lhs ^ __rhs; }
_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__filesystem/recursive_directory_iterator.h
@@ -22,6 +22,10 @@
#include <cstddef>
#include <system_error>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -164,7 +168,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP
_LIBCPP_END_NAMESPACE_FILESYSTEM
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <>
_LIBCPP_AVAILABILITY_FILESYSTEM
@@ -174,7 +178,7 @@ template <>
_LIBCPP_AVAILABILITY_FILESYSTEM
inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP_CXX03_LANG
lib/libcxx/include/__filesystem/space_info.h
@@ -14,6 +14,10 @@
#include <__config>
#include <cstdint>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__filesystem/u8path.h
@@ -10,11 +10,23 @@
#ifndef _LIBCPP___FILESYSTEM_U8PATH_H
#define _LIBCPP___FILESYSTEM_U8PATH_H
+#include <__algorithm/unwrap_iter.h>
#include <__availability>
#include <__config>
#include <__filesystem/path.h>
+#include <string>
#include <type_traits>
+// Only required on Windows for __widen_from_utf8, and included conservatively
+// because it requires support for localization.
+#if defined(_LIBCPP_WIN32API)
+# include <locale>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
lib/libcxx/include/__format/buffer.h
@@ -0,0 +1,369 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_BUFFER_H
+#define _LIBCPP___FORMAT_BUFFER_H
+
+#include <__algorithm/copy_n.h>
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__config>
+#include <__format/enable_insertable.h>
+#include <__format/format_to_n_result.h>
+#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/wrap_iter.h>
+#include <__utility/move.h>
+#include <concepts>
+#include <cstddef>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format {
+
+/// A "buffer" that handles writing to the proper iterator.
+///
+/// This helper is used together with the @ref back_insert_iterator to offer
+/// type-erasure for the formatting functions. This reduces the number to
+/// template instantiations.
+template <__formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __output_buffer {
+public:
+ using value_type = _CharT;
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr,
+ size_t __capacity, _Tp* __obj)
+ : __ptr_(__ptr), __capacity_(__capacity),
+ __flush_([](_CharT* __p, size_t __size, void* __o) {
+ static_cast<_Tp*>(__o)->flush(__p, __size);
+ }),
+ __obj_(__obj) {}
+
+ _LIBCPP_HIDE_FROM_ABI void reset(_CharT* __ptr, size_t __capacity) {
+ __ptr_ = __ptr;
+ __capacity_ = __capacity;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {
+ return back_insert_iterator{*this};
+ }
+
+ // TODO FMT It would be nice to have an overload taking a
+ // basic_string_view<_CharT> and append it directly.
+ _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {
+ __ptr_[__size_++] = __c;
+
+ // Profiling showed flushing after adding is more efficient than flushing
+ // when entering the function.
+ if (__size_ == __capacity_)
+ flush();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void flush() {
+ __flush_(__ptr_, __size_, __obj_);
+ __size_ = 0;
+ }
+
+private:
+ _CharT* __ptr_;
+ size_t __capacity_;
+ size_t __size_{0};
+ void (*__flush_)(_CharT*, size_t, void*);
+ void* __obj_;
+};
+
+/// A storage using an internal buffer.
+///
+/// This storage is used when writing a single element to the output iterator
+/// is expensive.
+template <__formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __internal_storage {
+public:
+ _LIBCPP_HIDE_FROM_ABI _CharT* begin() { return __buffer_; }
+
+ static constexpr size_t __buffer_size = 256 / sizeof(_CharT);
+
+private:
+ _CharT __buffer_[__buffer_size];
+};
+
+/// A storage writing directly to the storage.
+///
+/// This requires the storage to be a contiguous buffer of \a _CharT.
+/// Since the output is directly written to the underlying storage this class
+/// is just an empty class.
+template <__formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __direct_storage {};
+
+template <class _OutIt, class _CharT>
+concept __enable_direct_output = __formatter::__char_type<_CharT> &&
+ (same_as<_OutIt, _CharT*>
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
+ || same_as<_OutIt, __wrap_iter<_CharT*>>
+#endif
+ );
+
+/// Write policy for directly writing to the underlying output.
+template <class _OutIt, __formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __writer_direct {
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it)
+ : __out_it_(__out_it) {}
+
+ _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; }
+
+ _LIBCPP_HIDE_FROM_ABI void flush(_CharT*, size_t __size) {
+ // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator
+ // is adjusted.
+ __out_it_ += __size;
+ }
+
+private:
+ _OutIt __out_it_;
+};
+
+/// Write policy for copying the buffer to the output.
+template <class _OutIt, __formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __writer_iterator {
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it)
+ : __out_it_{_VSTD::move(__out_it)} {}
+
+ _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; }
+
+ _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
+ __out_it_ = _VSTD::copy_n(__ptr, __size, _VSTD::move(__out_it_));
+ }
+
+private:
+ _OutIt __out_it_;
+};
+
+/// Concept to see whether a \a _Container is insertable.
+///
+/// The concept is used to validate whether multiple calls to a
+/// \ref back_insert_iterator can be replace by a call to \c _Container::insert.
+///
+/// \note a \a _Container needs to opt-in to the concept by specializing
+/// \ref __enable_insertable.
+template <class _Container>
+concept __insertable =
+ __enable_insertable<_Container> && __formatter::__char_type<typename _Container::value_type> &&
+ requires(_Container& __t, add_pointer_t<typename _Container::value_type> __first,
+ add_pointer_t<typename _Container::value_type> __last) { __t.insert(__t.end(), __first, __last); };
+
+/// Extract the container type of a \ref back_insert_iterator.
+template <class _It>
+struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container {
+ using type = void;
+};
+
+template <__insertable _Container>
+struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> {
+ using type = _Container;
+};
+
+/// Write policy for inserting the buffer in a container.
+template <class _Container>
+class _LIBCPP_TEMPLATE_VIS __writer_container {
+public:
+ using _CharT = typename _Container::value_type;
+
+ _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it)
+ : __container_{__out_it.__get_container()} {}
+
+ _LIBCPP_HIDE_FROM_ABI auto out() { return back_inserter(*__container_); }
+
+ _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
+ __container_->insert(__container_->end(), __ptr, __ptr + __size);
+ }
+
+private:
+ _Container* __container_;
+};
+
+/// Selects the type of the writer used for the output iterator.
+template <class _OutIt, class _CharT>
+class _LIBCPP_TEMPLATE_VIS __writer_selector {
+ using _Container = typename __back_insert_iterator_container<_OutIt>::type;
+
+public:
+ using type = conditional_t<!same_as<_Container, void>, __writer_container<_Container>,
+ conditional_t<__enable_direct_output<_OutIt, _CharT>, __writer_direct<_OutIt, _CharT>,
+ __writer_iterator<_OutIt, _CharT>>>;
+};
+
+/// The generic formatting buffer.
+template <class _OutIt, __formatter::__char_type _CharT>
+requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
+ __format_buffer {
+ using _Storage =
+ conditional_t<__enable_direct_output<_OutIt, _CharT>,
+ __direct_storage<_CharT>, __internal_storage<_CharT>>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)
+ requires(same_as<_Storage, __internal_storage<_CharT>>)
+ : __output_(__storage_.begin(), __storage_.__buffer_size, this), __writer_(_VSTD::move(__out_it)) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(
+ same_as<_Storage, __direct_storage<_CharT>>)
+ : __output_(_VSTD::__unwrap_iter(__out_it), size_t(-1), this),
+ __writer_(_VSTD::move(__out_it)) {}
+
+ _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {
+ return __output_.make_output_iterator();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
+ __writer_.flush(__ptr, __size);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _OutIt out() && {
+ __output_.flush();
+ return _VSTD::move(__writer_).out();
+ }
+
+private:
+ _LIBCPP_NO_UNIQUE_ADDRESS _Storage __storage_;
+ __output_buffer<_CharT> __output_;
+ typename __writer_selector<_OutIt, _CharT>::type __writer_;
+};
+
+/// A buffer that counts the number of insertions.
+///
+/// Since \ref formatted_size only needs to know the size, the output itself is
+/// discarded.
+template <__formatter::__char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer {
+public:
+ _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return __output_.make_output_iterator(); }
+
+ _LIBCPP_HIDE_FROM_ABI void flush(const _CharT*, size_t __size) { __size_ += __size; }
+
+ _LIBCPP_HIDE_FROM_ABI size_t result() && {
+ __output_.flush();
+ return __size_;
+ }
+
+private:
+ __internal_storage<_CharT> __storage_;
+ __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this};
+ size_t __size_{0};
+};
+
+/// The base of a buffer that counts and limits the number of insertions.
+template <class _OutIt, __formatter::__char_type _CharT, bool>
+ requires(output_iterator<_OutIt, const _CharT&>)
+struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base {
+ using _Size = iter_difference_t<_OutIt>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
+ : __writer_(_VSTD::move(__out_it)), __n_(_VSTD::max(_Size(0), __n)) {}
+
+ _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
+ if (_Size(__size_) <= __n_)
+ __writer_.flush(__ptr, _VSTD::min(_Size(__size), __n_ - __size_));
+ __size_ += __size;
+ }
+
+protected:
+ __internal_storage<_CharT> __storage_;
+ __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this};
+ typename __writer_selector<_OutIt, _CharT>::type __writer_;
+
+ _Size __n_;
+ _Size __size_{0};
+};
+
+/// The base of a buffer that counts and limits the number of insertions.
+///
+/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true.
+///
+/// This class limits the size available the the direct writer so it will not
+/// exceed the maximum number of code units.
+template <class _OutIt, __formatter::__char_type _CharT>
+ requires(output_iterator<_OutIt, const _CharT&>)
+class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> {
+ using _Size = iter_difference_t<_OutIt>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
+ : __output_(_VSTD::__unwrap_iter(__out_it), __n, this), __writer_(_VSTD::move(__out_it)) {
+ if (__n <= 0) [[unlikely]]
+ __output_.reset(__storage_.begin(), __storage_.__buffer_size);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
+ // A flush to the direct writer happens in two occasions:
+ // - The format function has written the maximum number of allowed code
+ // units. At this point it's no longer valid to write to this writer. So
+ // switch to the internal storage. This internal storage doesn't need to
+ // be written anywhere so the flush for that storage writes no output.
+ // - The format_to_n function is finished. In this case there's no need to
+ // switch the buffer, but for simplicity the buffers are still switched.
+ // When the __n <= 0 the constructor already switched the buffers.
+ if (__size_ == 0 && __ptr != __storage_.begin()) {
+ __writer_.flush(__ptr, __size);
+ __output_.reset(__storage_.begin(), __storage_.__buffer_size);
+ }
+
+ __size_ += __size;
+ }
+
+protected:
+ __internal_storage<_CharT> __storage_;
+ __output_buffer<_CharT> __output_;
+ __writer_direct<_OutIt, _CharT> __writer_;
+
+ _Size __size_{0};
+};
+
+/// The buffer that counts and limits the number of insertions.
+template <class _OutIt, __formatter::__char_type _CharT>
+ requires(output_iterator<_OutIt, const _CharT&>)
+struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
+ : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> {
+ using _Base = __format_to_n_buffer_base<_OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>>;
+ using _Size = iter_difference_t<_OutIt>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __n) : _Base(_VSTD::move(__out_it), __n) {}
+ _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return this->__output_.make_output_iterator(); }
+
+ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> result() && {
+ this->__output_.flush();
+ return {_VSTD::move(this->__writer_).out(), this->__size_};
+ }
+};
+} // namespace __format
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_BUFFER_H
lib/libcxx/include/__format/concepts.h
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_CONCEPTS_H
+#define _LIBCPP___FORMAT_CONCEPTS_H
+
+#include <__concepts/same_as.h>
+#include <__concepts/semiregular.h>
+#include <__config>
+#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+// The output iterator isn't specified. A formatter should accept any
+// output_iterator. This iterator is a minimal iterator to test the concept.
+// (Note testing for (w)format_context would be a valid choice, but requires
+// selecting the proper one depending on the type of _CharT.)
+template <class _CharT>
+using __fmt_iter_for = _CharT*;
+
+// The concept is based on P2286R6
+// It lacks the const of __cf as required by, the not yet accepted, LWG-3636.
+// The current formatters can't be easily adapted, but that is WIP.
+// TODO FMT properly implement this concepts once accepted.
+template <class _Tp, class _CharT>
+concept __formattable = (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&
+ requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,
+ formatter<remove_cvref_t<_Tp>, _CharT> __cf, _Tp __t,
+ basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,
+ basic_format_parse_context<_CharT> __pc) {
+ { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>;
+ { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>;
+ };
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_CONCEPTS_H
lib/libcxx/include/__format/enable_insertable.h
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
+#define _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format {
+
+/// Opt-in to enable \ref __insertable for a \a _Container.
+template <class _Container>
+inline constexpr bool __enable_insertable = false;
+
+} // namespace __format
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
lib/libcxx/include/__format/extended_grapheme_cluster_table.h
@@ -0,0 +1,332 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// WARNING, this entire header is generated by
+// utiles/generate_extended_grapheme_cluster_table.py
+// DO NOT MODIFY!
+
+// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
+//
+// See Terms of Use <https://www.unicode.org/copyright.html>
+// for definitions of Unicode Inc.'s Data Files and Software.
+//
+// NOTICE TO USER: Carefully read the following legal agreement.
+// BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
+// DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
+// YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
+// TERMS AND CONDITIONS OF THIS AGREEMENT.
+// IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
+// THE DATA FILES OR SOFTWARE.
+//
+// COPYRIGHT AND PERMISSION NOTICE
+//
+// Copyright (c) 1991-2022 Unicode, Inc. All rights reserved.
+// Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of the Unicode data files and any associated documentation
+// (the "Data Files") or Unicode software and any associated documentation
+// (the "Software") to deal in the Data Files or Software
+// without restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, and/or sell copies of
+// the Data Files or Software, and to permit persons to whom the Data Files
+// or Software are furnished to do so, provided that either
+// (a) this copyright and permission notice appear with all copies
+// of the Data Files or Software, or
+// (b) this copyright and permission notice appear in associated
+// Documentation.
+//
+// THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
+// NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
+// DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+//
+// Except as contained in this notice, the name of a copyright holder
+// shall not be used in advertising or otherwise to promote the sale,
+// use or other dealings in these Data Files or Software without prior
+// written authorization of the copyright holder.
+
+#ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
+#define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
+
+#include <__algorithm/upper_bound.h>
+#include <__config>
+#include <__iterator/access.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __extended_grapheme_custer_property_boundary {
+
+enum class __property : uint8_t {
+ // Values generated from the data files.
+ __CR,
+ __Control,
+ __Extend,
+ __Extended_Pictographic,
+ __L,
+ __LF,
+ __LV,
+ __LVT,
+ __Prepend,
+ __Regional_Indicator,
+ __SpacingMark,
+ __T,
+ __V,
+ __ZWJ,
+
+ // The properies below aren't stored in the "database".
+
+ // Text position properties.
+ __sot,
+ __eot,
+
+ // The code unit has none of above properties.
+ __none
+};
+
+/// The entries of the extended grapheme cluster bondary property table.
+///
+/// The data is generated from
+/// - https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
+/// - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
+///
+/// The data has 3 values
+/// - bits [0, 3] The property. One of the values generated form the datafiles
+/// of \ref __property
+/// - bits [4, 10] The size of the range.
+/// - bits [11, 31] The lower bound code point of the range. The upper bound of
+/// the range is lower bound + size.
+///
+/// The 7 bits for the size allow a maximum range of 128 elements. Some ranges
+/// in the Unicode tables are larger. They are stored in multiple consecutive
+/// ranges in the data table. An alternative would be to store the sizes in a
+/// separate 16-bit value. The original MSVC STL code had such an approach, but
+/// this approach uses less space for the data and is about 4% faster in the
+/// following benchmark.
+/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
+inline constexpr uint32_t __entries[1480] = {
+ 0x00000091, 0x00005005, 0x00005811, 0x00006800, 0x00007111, 0x0003fa01, 0x00054803, 0x00056801, 0x00057003,
+ 0x001806f2, 0x00241862, 0x002c8ac2, 0x002df802, 0x002e0812, 0x002e2012, 0x002e3802, 0x00300058, 0x003080a2,
+ 0x0030e001, 0x00325942, 0x00338002, 0x0036b062, 0x0036e808, 0x0036f852, 0x00373812, 0x00375032, 0x00387808,
+ 0x00388802, 0x003981a2, 0x003d30a2, 0x003f5882, 0x003fe802, 0x0040b032, 0x0040d882, 0x00412822, 0x00414842,
+ 0x0042c822, 0x00448018, 0x0044c072, 0x00465172, 0x00471008, 0x004719f2, 0x0048180a, 0x0049d002, 0x0049d80a,
+ 0x0049e002, 0x0049f02a, 0x004a0872, 0x004a483a, 0x004a6802, 0x004a701a, 0x004a8862, 0x004b1012, 0x004c0802,
+ 0x004c101a, 0x004de002, 0x004df002, 0x004df81a, 0x004e0832, 0x004e381a, 0x004e581a, 0x004e6802, 0x004eb802,
+ 0x004f1012, 0x004ff002, 0x00500812, 0x0050180a, 0x0051e002, 0x0051f02a, 0x00520812, 0x00523812, 0x00525822,
+ 0x00528802, 0x00538012, 0x0053a802, 0x00540812, 0x0054180a, 0x0055e002, 0x0055f02a, 0x00560842, 0x00563812,
+ 0x0056480a, 0x0056581a, 0x00566802, 0x00571012, 0x0057d052, 0x00580802, 0x0058101a, 0x0059e002, 0x0059f012,
+ 0x005a000a, 0x005a0832, 0x005a381a, 0x005a581a, 0x005a6802, 0x005aa822, 0x005b1012, 0x005c1002, 0x005df002,
+ 0x005df80a, 0x005e0002, 0x005e081a, 0x005e302a, 0x005e502a, 0x005e6802, 0x005eb802, 0x00600002, 0x0060082a,
+ 0x00602002, 0x0061e002, 0x0061f022, 0x0062083a, 0x00623022, 0x00625032, 0x0062a812, 0x00631012, 0x00640802,
+ 0x0064101a, 0x0065e002, 0x0065f00a, 0x0065f802, 0x0066001a, 0x00661002, 0x0066181a, 0x00663002, 0x0066381a,
+ 0x0066501a, 0x00666012, 0x0066a812, 0x00671012, 0x00680012, 0x0068101a, 0x0069d812, 0x0069f002, 0x0069f81a,
+ 0x006a0832, 0x006a302a, 0x006a502a, 0x006a6802, 0x006a7008, 0x006ab802, 0x006b1012, 0x006c0802, 0x006c101a,
+ 0x006e5002, 0x006e7802, 0x006e801a, 0x006e9022, 0x006eb002, 0x006ec06a, 0x006ef802, 0x006f901a, 0x00718802,
+ 0x0071980a, 0x0071a062, 0x00723872, 0x00758802, 0x0075980a, 0x0075a082, 0x00764052, 0x0078c012, 0x0079a802,
+ 0x0079b802, 0x0079c802, 0x0079f01a, 0x007b88d2, 0x007bf80a, 0x007c0042, 0x007c3012, 0x007c68a2, 0x007cca32,
+ 0x007e3002, 0x00816832, 0x0081880a, 0x00819052, 0x0081c812, 0x0081d81a, 0x0081e812, 0x0082b01a, 0x0082c012,
+ 0x0082f022, 0x00838832, 0x00841002, 0x0084200a, 0x00842812, 0x00846802, 0x0084e802, 0x008805f4, 0x008b047c,
+ 0x008d457b, 0x009ae822, 0x00b89022, 0x00b8a80a, 0x00b99012, 0x00b9a00a, 0x00ba9012, 0x00bb9012, 0x00bda012,
+ 0x00bdb00a, 0x00bdb862, 0x00bdf07a, 0x00be3002, 0x00be381a, 0x00be48a2, 0x00bee802, 0x00c05822, 0x00c07001,
+ 0x00c07802, 0x00c42812, 0x00c54802, 0x00c90022, 0x00c9183a, 0x00c93812, 0x00c9482a, 0x00c9801a, 0x00c99002,
+ 0x00c9985a, 0x00c9c822, 0x00d0b812, 0x00d0c81a, 0x00d0d802, 0x00d2a80a, 0x00d2b002, 0x00d2b80a, 0x00d2c062,
+ 0x00d30002, 0x00d31002, 0x00d32872, 0x00d3685a, 0x00d39892, 0x00d3f802, 0x00d581e2, 0x00d80032, 0x00d8200a,
+ 0x00d9a062, 0x00d9d80a, 0x00d9e002, 0x00d9e84a, 0x00da1002, 0x00da181a, 0x00db5882, 0x00dc0012, 0x00dc100a,
+ 0x00dd080a, 0x00dd1032, 0x00dd301a, 0x00dd4012, 0x00dd500a, 0x00dd5822, 0x00df3002, 0x00df380a, 0x00df4012,
+ 0x00df502a, 0x00df6802, 0x00df700a, 0x00df7822, 0x00df901a, 0x00e1207a, 0x00e16072, 0x00e1a01a, 0x00e1b012,
+ 0x00e68022, 0x00e6a0c2, 0x00e7080a, 0x00e71062, 0x00e76802, 0x00e7a002, 0x00e7b80a, 0x00e7c012, 0x00ee03f2,
+ 0x01005801, 0x01006002, 0x0100680d, 0x01007011, 0x01014061, 0x0101e003, 0x01024803, 0x010300f1, 0x01068202,
+ 0x01091003, 0x0109c803, 0x010ca053, 0x010d4813, 0x0118d013, 0x01194003, 0x011c4003, 0x011e7803, 0x011f48a3,
+ 0x011fc023, 0x01261003, 0x012d5013, 0x012db003, 0x012e0003, 0x012fd833, 0x01300053, 0x013038b3, 0x0130a713,
+ 0x01348753, 0x013840a3, 0x0138a003, 0x0138b003, 0x0138e803, 0x01390803, 0x01394003, 0x01399813, 0x013a2003,
+ 0x013a3803, 0x013a6003, 0x013a7003, 0x013a9823, 0x013ab803, 0x013b1843, 0x013ca823, 0x013d0803, 0x013d8003,
+ 0x013df803, 0x0149a013, 0x01582823, 0x0158d813, 0x015a8003, 0x015aa803, 0x01677822, 0x016bf802, 0x016f01f2,
+ 0x01815052, 0x01818003, 0x0181e803, 0x0184c812, 0x0194b803, 0x0194c803, 0x05337832, 0x0533a092, 0x0534f012,
+ 0x05378012, 0x05401002, 0x05403002, 0x05405802, 0x0541181a, 0x05412812, 0x0541380a, 0x05416002, 0x0544001a,
+ 0x0545a0fa, 0x05462012, 0x05470112, 0x0547f802, 0x05493072, 0x054a38a2, 0x054a901a, 0x054b01c4, 0x054c0022,
+ 0x054c180a, 0x054d9802, 0x054da01a, 0x054db032, 0x054dd01a, 0x054de012, 0x054df02a, 0x054f2802, 0x05514852,
+ 0x0551781a, 0x05518812, 0x0551981a, 0x0551a812, 0x05521802, 0x05526002, 0x0552680a, 0x0553e002, 0x05558002,
+ 0x05559022, 0x0555b812, 0x0555f012, 0x05560802, 0x0557580a, 0x05576012, 0x0557701a, 0x0557a80a, 0x0557b002,
+ 0x055f181a, 0x055f2802, 0x055f301a, 0x055f4002, 0x055f481a, 0x055f600a, 0x055f6802, 0x05600006, 0x056009a7,
+ 0x0560e006, 0x0560e9a7, 0x0561c006, 0x0561c9a7, 0x0562a006, 0x0562a9a7, 0x05638006, 0x056389a7, 0x05646006,
+ 0x056469a7, 0x05654006, 0x056549a7, 0x05662006, 0x056629a7, 0x05670006, 0x056709a7, 0x0567e006, 0x0567e9a7,
+ 0x0568c006, 0x0568c9a7, 0x0569a006, 0x0569a9a7, 0x056a8006, 0x056a89a7, 0x056b6006, 0x056b69a7, 0x056c4006,
+ 0x056c49a7, 0x056d2006, 0x056d29a7, 0x056e0006, 0x056e09a7, 0x056ee006, 0x056ee9a7, 0x056fc006, 0x056fc9a7,
+ 0x0570a006, 0x0570a9a7, 0x05718006, 0x057189a7, 0x05726006, 0x057269a7, 0x05734006, 0x057349a7, 0x05742006,
+ 0x057429a7, 0x05750006, 0x057509a7, 0x0575e006, 0x0575e9a7, 0x0576c006, 0x0576c9a7, 0x0577a006, 0x0577a9a7,
+ 0x05788006, 0x057889a7, 0x05796006, 0x057969a7, 0x057a4006, 0x057a49a7, 0x057b2006, 0x057b29a7, 0x057c0006,
+ 0x057c09a7, 0x057ce006, 0x057ce9a7, 0x057dc006, 0x057dc9a7, 0x057ea006, 0x057ea9a7, 0x057f8006, 0x057f89a7,
+ 0x05806006, 0x058069a7, 0x05814006, 0x058149a7, 0x05822006, 0x058229a7, 0x05830006, 0x058309a7, 0x0583e006,
+ 0x0583e9a7, 0x0584c006, 0x0584c9a7, 0x0585a006, 0x0585a9a7, 0x05868006, 0x058689a7, 0x05876006, 0x058769a7,
+ 0x05884006, 0x058849a7, 0x05892006, 0x058929a7, 0x058a0006, 0x058a09a7, 0x058ae006, 0x058ae9a7, 0x058bc006,
+ 0x058bc9a7, 0x058ca006, 0x058ca9a7, 0x058d8006, 0x058d89a7, 0x058e6006, 0x058e69a7, 0x058f4006, 0x058f49a7,
+ 0x05902006, 0x059029a7, 0x05910006, 0x059109a7, 0x0591e006, 0x0591e9a7, 0x0592c006, 0x0592c9a7, 0x0593a006,
+ 0x0593a9a7, 0x05948006, 0x059489a7, 0x05956006, 0x059569a7, 0x05964006, 0x059649a7, 0x05972006, 0x059729a7,
+ 0x05980006, 0x059809a7, 0x0598e006, 0x0598e9a7, 0x0599c006, 0x0599c9a7, 0x059aa006, 0x059aa9a7, 0x059b8006,
+ 0x059b89a7, 0x059c6006, 0x059c69a7, 0x059d4006, 0x059d49a7, 0x059e2006, 0x059e29a7, 0x059f0006, 0x059f09a7,
+ 0x059fe006, 0x059fe9a7, 0x05a0c006, 0x05a0c9a7, 0x05a1a006, 0x05a1a9a7, 0x05a28006, 0x05a289a7, 0x05a36006,
+ 0x05a369a7, 0x05a44006, 0x05a449a7, 0x05a52006, 0x05a529a7, 0x05a60006, 0x05a609a7, 0x05a6e006, 0x05a6e9a7,
+ 0x05a7c006, 0x05a7c9a7, 0x05a8a006, 0x05a8a9a7, 0x05a98006, 0x05a989a7, 0x05aa6006, 0x05aa69a7, 0x05ab4006,
+ 0x05ab49a7, 0x05ac2006, 0x05ac29a7, 0x05ad0006, 0x05ad09a7, 0x05ade006, 0x05ade9a7, 0x05aec006, 0x05aec9a7,
+ 0x05afa006, 0x05afa9a7, 0x05b08006, 0x05b089a7, 0x05b16006, 0x05b169a7, 0x05b24006, 0x05b249a7, 0x05b32006,
+ 0x05b329a7, 0x05b40006, 0x05b409a7, 0x05b4e006, 0x05b4e9a7, 0x05b5c006, 0x05b5c9a7, 0x05b6a006, 0x05b6a9a7,
+ 0x05b78006, 0x05b789a7, 0x05b86006, 0x05b869a7, 0x05b94006, 0x05b949a7, 0x05ba2006, 0x05ba29a7, 0x05bb0006,
+ 0x05bb09a7, 0x05bbe006, 0x05bbe9a7, 0x05bcc006, 0x05bcc9a7, 0x05bda006, 0x05bda9a7, 0x05be8006, 0x05be89a7,
+ 0x05bf6006, 0x05bf69a7, 0x05c04006, 0x05c049a7, 0x05c12006, 0x05c129a7, 0x05c20006, 0x05c209a7, 0x05c2e006,
+ 0x05c2e9a7, 0x05c3c006, 0x05c3c9a7, 0x05c4a006, 0x05c4a9a7, 0x05c58006, 0x05c589a7, 0x05c66006, 0x05c669a7,
+ 0x05c74006, 0x05c749a7, 0x05c82006, 0x05c829a7, 0x05c90006, 0x05c909a7, 0x05c9e006, 0x05c9e9a7, 0x05cac006,
+ 0x05cac9a7, 0x05cba006, 0x05cba9a7, 0x05cc8006, 0x05cc89a7, 0x05cd6006, 0x05cd69a7, 0x05ce4006, 0x05ce49a7,
+ 0x05cf2006, 0x05cf29a7, 0x05d00006, 0x05d009a7, 0x05d0e006, 0x05d0e9a7, 0x05d1c006, 0x05d1c9a7, 0x05d2a006,
+ 0x05d2a9a7, 0x05d38006, 0x05d389a7, 0x05d46006, 0x05d469a7, 0x05d54006, 0x05d549a7, 0x05d62006, 0x05d629a7,
+ 0x05d70006, 0x05d709a7, 0x05d7e006, 0x05d7e9a7, 0x05d8c006, 0x05d8c9a7, 0x05d9a006, 0x05d9a9a7, 0x05da8006,
+ 0x05da89a7, 0x05db6006, 0x05db69a7, 0x05dc4006, 0x05dc49a7, 0x05dd2006, 0x05dd29a7, 0x05de0006, 0x05de09a7,
+ 0x05dee006, 0x05dee9a7, 0x05dfc006, 0x05dfc9a7, 0x05e0a006, 0x05e0a9a7, 0x05e18006, 0x05e189a7, 0x05e26006,
+ 0x05e269a7, 0x05e34006, 0x05e349a7, 0x05e42006, 0x05e429a7, 0x05e50006, 0x05e509a7, 0x05e5e006, 0x05e5e9a7,
+ 0x05e6c006, 0x05e6c9a7, 0x05e7a006, 0x05e7a9a7, 0x05e88006, 0x05e889a7, 0x05e96006, 0x05e969a7, 0x05ea4006,
+ 0x05ea49a7, 0x05eb2006, 0x05eb29a7, 0x05ec0006, 0x05ec09a7, 0x05ece006, 0x05ece9a7, 0x05edc006, 0x05edc9a7,
+ 0x05eea006, 0x05eea9a7, 0x05ef8006, 0x05ef89a7, 0x05f06006, 0x05f069a7, 0x05f14006, 0x05f149a7, 0x05f22006,
+ 0x05f229a7, 0x05f30006, 0x05f309a7, 0x05f3e006, 0x05f3e9a7, 0x05f4c006, 0x05f4c9a7, 0x05f5a006, 0x05f5a9a7,
+ 0x05f68006, 0x05f689a7, 0x05f76006, 0x05f769a7, 0x05f84006, 0x05f849a7, 0x05f92006, 0x05f929a7, 0x05fa0006,
+ 0x05fa09a7, 0x05fae006, 0x05fae9a7, 0x05fbc006, 0x05fbc9a7, 0x05fca006, 0x05fca9a7, 0x05fd8006, 0x05fd89a7,
+ 0x05fe6006, 0x05fe69a7, 0x05ff4006, 0x05ff49a7, 0x06002006, 0x060029a7, 0x06010006, 0x060109a7, 0x0601e006,
+ 0x0601e9a7, 0x0602c006, 0x0602c9a7, 0x0603a006, 0x0603a9a7, 0x06048006, 0x060489a7, 0x06056006, 0x060569a7,
+ 0x06064006, 0x060649a7, 0x06072006, 0x060729a7, 0x06080006, 0x060809a7, 0x0608e006, 0x0608e9a7, 0x0609c006,
+ 0x0609c9a7, 0x060aa006, 0x060aa9a7, 0x060b8006, 0x060b89a7, 0x060c6006, 0x060c69a7, 0x060d4006, 0x060d49a7,
+ 0x060e2006, 0x060e29a7, 0x060f0006, 0x060f09a7, 0x060fe006, 0x060fe9a7, 0x0610c006, 0x0610c9a7, 0x0611a006,
+ 0x0611a9a7, 0x06128006, 0x061289a7, 0x06136006, 0x061369a7, 0x06144006, 0x061449a7, 0x06152006, 0x061529a7,
+ 0x06160006, 0x061609a7, 0x0616e006, 0x0616e9a7, 0x0617c006, 0x0617c9a7, 0x0618a006, 0x0618a9a7, 0x06198006,
+ 0x061989a7, 0x061a6006, 0x061a69a7, 0x061b4006, 0x061b49a7, 0x061c2006, 0x061c29a7, 0x061d0006, 0x061d09a7,
+ 0x061de006, 0x061de9a7, 0x061ec006, 0x061ec9a7, 0x061fa006, 0x061fa9a7, 0x06208006, 0x062089a7, 0x06216006,
+ 0x062169a7, 0x06224006, 0x062249a7, 0x06232006, 0x062329a7, 0x06240006, 0x062409a7, 0x0624e006, 0x0624e9a7,
+ 0x0625c006, 0x0625c9a7, 0x0626a006, 0x0626a9a7, 0x06278006, 0x062789a7, 0x06286006, 0x062869a7, 0x06294006,
+ 0x062949a7, 0x062a2006, 0x062a29a7, 0x062b0006, 0x062b09a7, 0x062be006, 0x062be9a7, 0x062cc006, 0x062cc9a7,
+ 0x062da006, 0x062da9a7, 0x062e8006, 0x062e89a7, 0x062f6006, 0x062f69a7, 0x06304006, 0x063049a7, 0x06312006,
+ 0x063129a7, 0x06320006, 0x063209a7, 0x0632e006, 0x0632e9a7, 0x0633c006, 0x0633c9a7, 0x0634a006, 0x0634a9a7,
+ 0x06358006, 0x063589a7, 0x06366006, 0x063669a7, 0x06374006, 0x063749a7, 0x06382006, 0x063829a7, 0x06390006,
+ 0x063909a7, 0x0639e006, 0x0639e9a7, 0x063ac006, 0x063ac9a7, 0x063ba006, 0x063ba9a7, 0x063c8006, 0x063c89a7,
+ 0x063d6006, 0x063d69a7, 0x063e4006, 0x063e49a7, 0x063f2006, 0x063f29a7, 0x06400006, 0x064009a7, 0x0640e006,
+ 0x0640e9a7, 0x0641c006, 0x0641c9a7, 0x0642a006, 0x0642a9a7, 0x06438006, 0x064389a7, 0x06446006, 0x064469a7,
+ 0x06454006, 0x064549a7, 0x06462006, 0x064629a7, 0x06470006, 0x064709a7, 0x0647e006, 0x0647e9a7, 0x0648c006,
+ 0x0648c9a7, 0x0649a006, 0x0649a9a7, 0x064a8006, 0x064a89a7, 0x064b6006, 0x064b69a7, 0x064c4006, 0x064c49a7,
+ 0x064d2006, 0x064d29a7, 0x064e0006, 0x064e09a7, 0x064ee006, 0x064ee9a7, 0x064fc006, 0x064fc9a7, 0x0650a006,
+ 0x0650a9a7, 0x06518006, 0x065189a7, 0x06526006, 0x065269a7, 0x06534006, 0x065349a7, 0x06542006, 0x065429a7,
+ 0x06550006, 0x065509a7, 0x0655e006, 0x0655e9a7, 0x0656c006, 0x0656c9a7, 0x0657a006, 0x0657a9a7, 0x06588006,
+ 0x065889a7, 0x06596006, 0x065969a7, 0x065a4006, 0x065a49a7, 0x065b2006, 0x065b29a7, 0x065c0006, 0x065c09a7,
+ 0x065ce006, 0x065ce9a7, 0x065dc006, 0x065dc9a7, 0x065ea006, 0x065ea9a7, 0x065f8006, 0x065f89a7, 0x06606006,
+ 0x066069a7, 0x06614006, 0x066149a7, 0x06622006, 0x066229a7, 0x06630006, 0x066309a7, 0x0663e006, 0x0663e9a7,
+ 0x0664c006, 0x0664c9a7, 0x0665a006, 0x0665a9a7, 0x06668006, 0x066689a7, 0x06676006, 0x066769a7, 0x06684006,
+ 0x066849a7, 0x06692006, 0x066929a7, 0x066a0006, 0x066a09a7, 0x066ae006, 0x066ae9a7, 0x066bc006, 0x066bc9a7,
+ 0x066ca006, 0x066ca9a7, 0x066d8006, 0x066d89a7, 0x066e6006, 0x066e69a7, 0x066f4006, 0x066f49a7, 0x06702006,
+ 0x067029a7, 0x06710006, 0x067109a7, 0x0671e006, 0x0671e9a7, 0x0672c006, 0x0672c9a7, 0x0673a006, 0x0673a9a7,
+ 0x06748006, 0x067489a7, 0x06756006, 0x067569a7, 0x06764006, 0x067649a7, 0x06772006, 0x067729a7, 0x06780006,
+ 0x067809a7, 0x0678e006, 0x0678e9a7, 0x0679c006, 0x0679c9a7, 0x067aa006, 0x067aa9a7, 0x067b8006, 0x067b89a7,
+ 0x067c6006, 0x067c69a7, 0x067d4006, 0x067d49a7, 0x067e2006, 0x067e29a7, 0x067f0006, 0x067f09a7, 0x067fe006,
+ 0x067fe9a7, 0x0680c006, 0x0680c9a7, 0x0681a006, 0x0681a9a7, 0x06828006, 0x068289a7, 0x06836006, 0x068369a7,
+ 0x06844006, 0x068449a7, 0x06852006, 0x068529a7, 0x06860006, 0x068609a7, 0x0686e006, 0x0686e9a7, 0x0687c006,
+ 0x0687c9a7, 0x0688a006, 0x0688a9a7, 0x06898006, 0x068989a7, 0x068a6006, 0x068a69a7, 0x068b4006, 0x068b49a7,
+ 0x068c2006, 0x068c29a7, 0x068d0006, 0x068d09a7, 0x068de006, 0x068de9a7, 0x068ec006, 0x068ec9a7, 0x068fa006,
+ 0x068fa9a7, 0x06908006, 0x069089a7, 0x06916006, 0x069169a7, 0x06924006, 0x069249a7, 0x06932006, 0x069329a7,
+ 0x06940006, 0x069409a7, 0x0694e006, 0x0694e9a7, 0x0695c006, 0x0695c9a7, 0x0696a006, 0x0696a9a7, 0x06978006,
+ 0x069789a7, 0x06986006, 0x069869a7, 0x06994006, 0x069949a7, 0x069a2006, 0x069a29a7, 0x069b0006, 0x069b09a7,
+ 0x069be006, 0x069be9a7, 0x069cc006, 0x069cc9a7, 0x069da006, 0x069da9a7, 0x069e8006, 0x069e89a7, 0x069f6006,
+ 0x069f69a7, 0x06a04006, 0x06a049a7, 0x06a12006, 0x06a129a7, 0x06a20006, 0x06a209a7, 0x06a2e006, 0x06a2e9a7,
+ 0x06a3c006, 0x06a3c9a7, 0x06a4a006, 0x06a4a9a7, 0x06a58006, 0x06a589a7, 0x06a66006, 0x06a669a7, 0x06a74006,
+ 0x06a749a7, 0x06a82006, 0x06a829a7, 0x06a90006, 0x06a909a7, 0x06a9e006, 0x06a9e9a7, 0x06aac006, 0x06aac9a7,
+ 0x06aba006, 0x06aba9a7, 0x06ac8006, 0x06ac89a7, 0x06ad6006, 0x06ad69a7, 0x06ae4006, 0x06ae49a7, 0x06af2006,
+ 0x06af29a7, 0x06b00006, 0x06b009a7, 0x06b0e006, 0x06b0e9a7, 0x06b1c006, 0x06b1c9a7, 0x06b2a006, 0x06b2a9a7,
+ 0x06b38006, 0x06b389a7, 0x06b46006, 0x06b469a7, 0x06b54006, 0x06b549a7, 0x06b62006, 0x06b629a7, 0x06b70006,
+ 0x06b709a7, 0x06b7e006, 0x06b7e9a7, 0x06b8c006, 0x06b8c9a7, 0x06b9a006, 0x06b9a9a7, 0x06ba8006, 0x06ba89a7,
+ 0x06bb6006, 0x06bb69a7, 0x06bc4006, 0x06bc49a7, 0x06bd816c, 0x06be5b0b, 0x07d8f002, 0x07f000f2, 0x07f100f2,
+ 0x07f7f801, 0x07fcf012, 0x07ff80b1, 0x080fe802, 0x08170002, 0x081bb042, 0x08500822, 0x08502812, 0x08506032,
+ 0x0851c022, 0x0851f802, 0x08572812, 0x08692032, 0x08755812, 0x087a30a2, 0x087c1032, 0x0880000a, 0x08800802,
+ 0x0880100a, 0x0881c0e2, 0x08838002, 0x08839812, 0x0883f822, 0x0884100a, 0x0885802a, 0x08859832, 0x0885b81a,
+ 0x0885c812, 0x0885e808, 0x08861002, 0x08866808, 0x08880022, 0x08893842, 0x0889600a, 0x08896872, 0x088a281a,
+ 0x088b9802, 0x088c0012, 0x088c100a, 0x088d982a, 0x088db082, 0x088df81a, 0x088e1018, 0x088e4832, 0x088e700a,
+ 0x088e7802, 0x0891602a, 0x08917822, 0x0891901a, 0x0891a002, 0x0891a80a, 0x0891b012, 0x0891f002, 0x0896f802,
+ 0x0897002a, 0x08971872, 0x08980012, 0x0898101a, 0x0899d812, 0x0899f002, 0x0899f80a, 0x089a0002, 0x089a083a,
+ 0x089a381a, 0x089a582a, 0x089ab802, 0x089b101a, 0x089b3062, 0x089b8042, 0x08a1a82a, 0x08a1c072, 0x08a2001a,
+ 0x08a21022, 0x08a2280a, 0x08a23002, 0x08a2f002, 0x08a58002, 0x08a5881a, 0x08a59852, 0x08a5c80a, 0x08a5d002,
+ 0x08a5d81a, 0x08a5e802, 0x08a5f00a, 0x08a5f812, 0x08a6080a, 0x08a61012, 0x08ad7802, 0x08ad801a, 0x08ad9032,
+ 0x08adc03a, 0x08ade012, 0x08adf00a, 0x08adf812, 0x08aee012, 0x08b1802a, 0x08b19872, 0x08b1d81a, 0x08b1e802,
+ 0x08b1f00a, 0x08b1f812, 0x08b55802, 0x08b5600a, 0x08b56802, 0x08b5701a, 0x08b58052, 0x08b5b00a, 0x08b5b802,
+ 0x08b8e822, 0x08b91032, 0x08b9300a, 0x08b93842, 0x08c1602a, 0x08c17882, 0x08c1c00a, 0x08c1c812, 0x08c98002,
+ 0x08c9884a, 0x08c9b81a, 0x08c9d812, 0x08c9e80a, 0x08c9f002, 0x08c9f808, 0x08ca000a, 0x08ca0808, 0x08ca100a,
+ 0x08ca1802, 0x08ce882a, 0x08cea032, 0x08ced012, 0x08cee03a, 0x08cf0002, 0x08cf200a, 0x08d00892, 0x08d19852,
+ 0x08d1c80a, 0x08d1d008, 0x08d1d832, 0x08d23802, 0x08d28852, 0x08d2b81a, 0x08d2c822, 0x08d42058, 0x08d450c2,
+ 0x08d4b80a, 0x08d4c012, 0x08e1780a, 0x08e18062, 0x08e1c052, 0x08e1f00a, 0x08e1f802, 0x08e49152, 0x08e5480a,
+ 0x08e55062, 0x08e5880a, 0x08e59012, 0x08e5a00a, 0x08e5a812, 0x08e98852, 0x08e9d002, 0x08e9e012, 0x08e9f862,
+ 0x08ea3008, 0x08ea3802, 0x08ec504a, 0x08ec8012, 0x08ec981a, 0x08eca802, 0x08ecb00a, 0x08ecb802, 0x08f79812,
+ 0x08f7a81a, 0x09a18081, 0x0b578042, 0x0b598062, 0x0b7a7802, 0x0b7a8b6a, 0x0b7c7832, 0x0b7f2002, 0x0b7f801a,
+ 0x0de4e812, 0x0de50031, 0x0e7802d2, 0x0e798162, 0x0e8b2802, 0x0e8b300a, 0x0e8b3822, 0x0e8b680a, 0x0e8b7042,
+ 0x0e8b9871, 0x0e8bd872, 0x0e8c2862, 0x0e8d5032, 0x0e921022, 0x0ed00362, 0x0ed1db12, 0x0ed3a802, 0x0ed42002,
+ 0x0ed4d842, 0x0ed508e2, 0x0f000062, 0x0f004102, 0x0f00d862, 0x0f011812, 0x0f013042, 0x0f098062, 0x0f157002,
+ 0x0f176032, 0x0f468062, 0x0f4a2062, 0x0f8007f3, 0x0f8407f3, 0x0f886823, 0x0f897803, 0x0f8b6053, 0x0f8bf013,
+ 0x0f8c7003, 0x0f8c8893, 0x0f8d6b83, 0x0f8f3199, 0x0f9008e3, 0x0f90d003, 0x0f917803, 0x0f919083, 0x0f91e033,
+ 0x0f924ff3, 0x0f964ff3, 0x0f9a4ff3, 0x0f9e4b13, 0x0f9fd842, 0x0fa007f3, 0x0fa407f3, 0x0fa803d3, 0x0faa37f3,
+ 0x0fae37f3, 0x0fb23093, 0x0fb407f3, 0x0fbba0b3, 0x0fbeaaa3, 0x0fc06033, 0x0fc24073, 0x0fc2d053, 0x0fc44073,
+ 0x0fc57513, 0x0fc862e3, 0x0fc9e093, 0x0fca3ff3, 0x0fce3ff3, 0x0fd23ff3, 0x0fd63b83, 0x0fe007f3, 0x0fe407f3,
+ 0x0fe807f3, 0x0fec07f3, 0x0ff007f3, 0x0ff407f3, 0x0ff807f3, 0x0ffc07d3, 0x700001f1, 0x700105f2, 0x700407f1,
+ 0x700807f2, 0x700c06f2, 0x700f87f1, 0x701387f1, 0x701787f1, 0x701b87f1, 0x701f87f1, 0x702387f1, 0x702787f1,
+ 0x702b87f1, 0x702f87f1, 0x703387f1, 0x703787f1, 0x703b87f1, 0x703f87f1, 0x704387f1, 0x704787f1, 0x704b87f1,
+ 0x704f87f1, 0x705387f1, 0x705787f1, 0x705b87f1, 0x705f87f1, 0x706387f1, 0x706787f1, 0x706b87f1, 0x706f87f1,
+ 0x707387f1, 0x707787f1, 0x707b87f1, 0x707f80f1};
+
+/// Returns the extended grapheme cluster bondary property of a code point.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
+ // TODO FMT use std::ranges::upper_bound.
+
+ // The algorithm searches for the upper bound of the range and, when found,
+ // steps back one entry. This algorithm is used since the code point can be
+ // anywhere in the range. After a lower bound is found the next step is to
+ // compare whether the code unit is indeed in the range.
+ //
+ // Since the entry contains a code unit, size, and property the code point
+ // being sought needs to be adjusted. Just shifting the code point to the
+ // proper position doesn't work; suppose an entry has property 0, size 1,
+ // and lower bound 3. This results in the entry 0x1810.
+ // When searching for code point 3 it will search for 0x1800, find 0x1810
+ // and moves to the previous entry. Thus the lower bound value will never
+ // be found.
+ // The simple solution is to set the bits belonging to the property and
+ // size. Then the upper bound for code point 3 will return the entry after
+ // 0x1810. After moving to the previous entry the algorithm arrives at the
+ // correct entry.
+ ptrdiff_t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries;
+ if (__i == 0)
+ return __property::__none;
+
+ --__i;
+ uint32_t __upper_bound = (__entries[__i] >> 11) + ((__entries[__i] >> 4) & 0x7f);
+ if (__code_point <= __upper_bound)
+ return static_cast<__property>(__entries[__i] & 0xf);
+
+ return __property::__none;
+}
+
+} // namespace __extended_grapheme_custer_property_boundary
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
lib/libcxx/include/__format/format_arg.h
@@ -10,39 +10,41 @@
#ifndef _LIBCPP___FORMAT_FORMAT_ARG_H
#define _LIBCPP___FORMAT_FORMAT_ARG_H
+#include <__assert>
#include <__concepts/arithmetic.h>
#include <__config>
#include <__format/format_error.h>
#include <__format/format_fwd.h>
#include <__format/format_parse_context.h>
-#include <__functional_base>
+#include <__functional/invoke.h>
#include <__memory/addressof.h>
+#include <__utility/forward.h>
+#include <__utility/unreachable.h>
#include <__variant/monostate.h>
#include <string>
#include <string_view>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
namespace __format {
/// The type stored in @ref basic_format_arg.
///
/// @note The 128-bit types are unconditionally in the list to avoid the values
/// of the enums to depend on the availability of 128-bit integers.
+///
+/// @note The value is stored as a 5-bit value in the __packed_arg_t_bits. This
+/// limits the maximum number of elements to 32.
+/// When modifying update the test
+/// test/libcxx/utilities/format/format.arguments/format.arg/arg_t.compile.pass.cpp
+/// It could be packed in 4-bits but that means a new type directly becomes an
+/// ABI break. The packed type is 64-bit so this reduces the maximum number of
+/// packed elements from 16 to 12.
enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
__none,
__boolean,
@@ -61,58 +63,158 @@ enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
__ptr,
__handle
};
+
+inline constexpr unsigned __packed_arg_t_bits = 5;
+inline constexpr uint8_t __packed_arg_t_mask = 0x1f;
+
+inline constexpr unsigned __packed_types_storage_bits = 64;
+inline constexpr unsigned __packed_types_max = __packed_types_storage_bits / __packed_arg_t_bits;
+
+_LIBCPP_HIDE_FROM_ABI
+constexpr bool __use_packed_format_arg_store(size_t __size) { return __size <= __packed_types_max; }
+
+_LIBCPP_HIDE_FROM_ABI
+constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) {
+ _LIBCPP_ASSERT(__id <= __packed_types_max, "");
+
+ if (__id > 0)
+ __types >>= __id * __packed_arg_t_bits;
+
+ return static_cast<__format::__arg_t>(__types & __packed_arg_t_mask);
+}
+
} // namespace __format
template <class _Visitor, class _Context>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto)
-visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) visit_format_arg(_Visitor&& __vis,
+ basic_format_arg<_Context> __arg) {
switch (__arg.__type_) {
case __format::__arg_t::__none:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), monostate{});
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__monostate_);
case __format::__arg_t::__boolean:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__boolean);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__boolean_);
case __format::__arg_t::__char_type:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__char_type);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__char_type_);
case __format::__arg_t::__int:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__int);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__int_);
case __format::__arg_t::__long_long:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_long);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_long_);
case __format::__arg_t::__i128:
-#ifndef _LIBCPP_HAS_NO_INT128
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__i128);
-#else
- _LIBCPP_UNREACHABLE();
-#endif
+# ifndef _LIBCPP_HAS_NO_INT128
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__i128_);
+# else
+ __libcpp_unreachable();
+# endif
case __format::__arg_t::__unsigned:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__unsigned);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_);
case __format::__arg_t::__unsigned_long_long:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),
- __arg.__unsigned_long_long);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_);
case __format::__arg_t::__u128:
-#ifndef _LIBCPP_HAS_NO_INT128
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__u128);
-#else
- _LIBCPP_UNREACHABLE();
-#endif
+# ifndef _LIBCPP_HAS_NO_INT128
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__u128_);
+# else
+ __libcpp_unreachable();
+# endif
case __format::__arg_t::__float:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__float);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__float_);
case __format::__arg_t::__double:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__double);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__double_);
case __format::__arg_t::__long_double:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_double);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_double_);
case __format::__arg_t::__const_char_type_ptr:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),
- __arg.__const_char_type_ptr);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__const_char_type_ptr_);
case __format::__arg_t::__string_view:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__string_view);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__string_view_);
case __format::__arg_t::__ptr:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__ptr);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__ptr_);
case __format::__arg_t::__handle:
- return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__handle);
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),
+ typename basic_format_arg<_Context>::handle{__arg.__value_.__handle_});
}
- _LIBCPP_UNREACHABLE();
+
+ __libcpp_unreachable();
}
+/// Contains the values used in basic_format_arg.
+///
+/// This is a separate type so it's possible to store the values and types in
+/// separate arrays.
+template <class _Context>
+class __basic_format_arg_value {
+ using _CharT = typename _Context::char_type;
+
+public:
+ /// Contains the implementation for basic_format_arg::handle.
+ struct __handle {
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit __handle(_Tp&& __v) noexcept
+ : __ptr_(_VSTD::addressof(__v)),
+ __format_([](basic_format_parse_context<_CharT>& __parse_ctx, _Context& __ctx, const void* __ptr) {
+ using _Dp = remove_cvref_t<_Tp>;
+ using _Formatter = typename _Context::template formatter_type<_Dp>;
+ constexpr bool __const_formattable =
+ requires { _Formatter().format(declval<const _Dp&>(), declval<_Context&>()); };
+ using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>;
+
+ static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18");
+
+ _Formatter __f;
+ __parse_ctx.advance_to(__f.parse(__parse_ctx));
+ __ctx.advance_to(__f.format(*const_cast<_Qp*>(static_cast<const _Dp*>(__ptr)), __ctx));
+ }) {}
+
+ const void* __ptr_;
+ void (*__format_)(basic_format_parse_context<_CharT>&, _Context&, const void*);
+ };
+
+ union {
+ monostate __monostate_;
+ bool __boolean_;
+ _CharT __char_type_;
+ int __int_;
+ unsigned __unsigned_;
+ long long __long_long_;
+ unsigned long long __unsigned_long_long_;
+# ifndef _LIBCPP_HAS_NO_INT128
+ __int128_t __i128_;
+ __uint128_t __u128_;
+# endif
+ float __float_;
+ double __double_;
+ long double __long_double_;
+ const _CharT* __const_char_type_ptr_;
+ basic_string_view<_CharT> __string_view_;
+ const void* __ptr_;
+ __handle __handle_;
+ };
+
+ // These constructors contain the exact storage type used. If adjustments are
+ // required, these will be done in __create_format_arg.
+
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value() noexcept : __monostate_() {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(bool __value) noexcept : __boolean_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(_CharT __value) noexcept : __char_type_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(int __value) noexcept : __int_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned __value) noexcept : __unsigned_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept
+ : __unsigned_long_long_(__value) {}
+# ifndef _LIBCPP_HAS_NO_INT128
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {}
+# endif
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(float __value) noexcept : __float_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(double __value) noexcept : __double_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long double __value) noexcept : __long_double_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const _CharT* __value) noexcept : __const_char_type_ptr_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(basic_string_view<_CharT> __value) noexcept
+ : __string_view_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const void* __value) noexcept : __ptr_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__handle __value) noexcept
+ // TODO FMT Investigate why it doesn't work without the forward.
+ : __handle_(std::forward<__handle>(__value)) {}
+};
+
template <class _Context>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg {
public:
@@ -139,154 +241,32 @@ private:
// .format(declval<const T&>(), declval<Context&>())
// shall be well-formed when treated as an unevaluated operand.
- template <class _Ctx, class... _Args>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend __format_arg_store<_Ctx, _Args...>
- make_format_args(const _Args&...);
-
- template <class _Visitor, class _Ctx>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend decltype(auto)
- visit_format_arg(_Visitor&& __vis, basic_format_arg<_Ctx> __arg);
-
- union {
- bool __boolean;
- char_type __char_type;
- int __int;
- unsigned __unsigned;
- long long __long_long;
- unsigned long long __unsigned_long_long;
-#ifndef _LIBCPP_HAS_NO_INT128
- __int128_t __i128;
- __uint128_t __u128;
-#endif
- float __float;
- double __double;
- long double __long_double;
- const char_type* __const_char_type_ptr;
- basic_string_view<char_type> __string_view;
- const void* __ptr;
- handle __handle;
- };
+public:
+ __basic_format_arg_value<_Context> __value_;
__format::__arg_t __type_;
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(bool __v) noexcept
- : __boolean(__v), __type_(__format::__arg_t::__boolean) {}
-
- template <class _Tp>
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept
- requires(same_as<_Tp, char_type> ||
- (same_as<_Tp, char> && same_as<char_type, wchar_t>))
- : __char_type(__v), __type_(__format::__arg_t::__char_type) {}
-
- template <__libcpp_signed_integer _Tp>
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept {
- if constexpr (sizeof(_Tp) <= sizeof(int)) {
- __int = static_cast<int>(__v);
- __type_ = __format::__arg_t::__int;
- } else if constexpr (sizeof(_Tp) <= sizeof(long long)) {
- __long_long = static_cast<long long>(__v);
- __type_ = __format::__arg_t::__long_long;
- }
-#ifndef _LIBCPP_HAS_NO_INT128
- else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) {
- __i128 = __v;
- __type_ = __format::__arg_t::__i128;
- }
-#endif
- else
- static_assert(sizeof(_Tp) == 0, "An unsupported signed integer was used");
- }
-
- template <__libcpp_unsigned_integer _Tp>
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept {
- if constexpr (sizeof(_Tp) <= sizeof(unsigned)) {
- __unsigned = static_cast<unsigned>(__v);
- __type_ = __format::__arg_t::__unsigned;
- } else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) {
- __unsigned_long_long = static_cast<unsigned long long>(__v);
- __type_ = __format::__arg_t::__unsigned_long_long;
- }
-#ifndef _LIBCPP_HAS_NO_INT128
- else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) {
- __u128 = __v;
- __type_ = __format::__arg_t::__u128;
- }
-#endif
- else
- static_assert(sizeof(_Tp) == 0,
- "An unsupported unsigned integer was used");
- }
-
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(float __v) noexcept
- : __float(__v), __type_(__format::__arg_t::__float) {}
-
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(double __v) noexcept
- : __double(__v), __type_(__format::__arg_t::__double) {}
-
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(long double __v) noexcept
- : __long_double(__v), __type_(__format::__arg_t::__long_double) {}
-
- // Note not a 'noexcept' function.
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const char_type* __s)
- : __const_char_type_ptr(__s),
- __type_(__format::__arg_t::__const_char_type_ptr) {
- _LIBCPP_ASSERT(__s, "Used a nullptr argument to initialize a C-string");
- }
-
- template <class _Traits>
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(
- basic_string_view<char_type, _Traits> __s) noexcept
- : __string_view{__s.data(), __s.size()},
- __type_(__format::__arg_t::__string_view) {}
-
- template <class _Traits, class _Allocator>
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(
- const basic_string<char_type, _Traits, _Allocator>& __s) noexcept
- : __string_view{__s.data(), __s.size()},
- __type_(__format::__arg_t::__string_view) {}
-
- _LIBCPP_HIDE_FROM_ABI
- explicit basic_format_arg(nullptr_t) noexcept
- : __ptr(nullptr), __type_(__format::__arg_t::__ptr) {}
-
- template <class _Tp>
- requires is_void_v<_Tp> _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp* __p) noexcept
- : __ptr(__p), __type_(__format::__arg_t::__ptr) {}
-
- template <class _Tp>
- _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept
- : __handle(__v), __type_(__format::__arg_t::__handle) {}
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(__format::__arg_t __type,
+ __basic_format_arg_value<_Context> __value) noexcept
+ : __value_(__value), __type_(__type) {}
};
template <class _Context>
class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle {
- friend class basic_format_arg<_Context>;
-
public:
_LIBCPP_HIDE_FROM_ABI
void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const {
- __format_(__parse_ctx, __ctx, __ptr_);
+ __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_);
}
+ _LIBCPP_HIDE_FROM_ABI explicit handle(typename __basic_format_arg_value<_Context>::__handle& __handle) noexcept
+ : __handle_(__handle) {}
+
private:
- const void* __ptr_;
- void (*__format_)(basic_format_parse_context<char_type>&, _Context&, const void*);
-
- template <class _Tp>
- _LIBCPP_HIDE_FROM_ABI explicit handle(const _Tp& __v) noexcept
- : __ptr_(_VSTD::addressof(__v)),
- __format_([](basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx, const void* __ptr) {
- typename _Context::template formatter_type<_Tp> __f;
- __parse_ctx.advance_to(__f.parse(__parse_ctx));
- __ctx.advance_to(__f.format(*static_cast<const _Tp*>(__ptr), __ctx));
- }) {}
+ typename __basic_format_arg_value<_Context>::__handle& __handle_;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP___FORMAT_FORMAT_ARG_H
lib/libcxx/include/__format/format_arg_store.h
@@ -0,0 +1,253 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
+#define _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_arg.h>
+#include <cstring>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format {
+
+/// \returns The @c __arg_t based on the type of the formatting argument.
+///
+/// \pre \c __formattable<_Tp, typename _Context::char_type>
+template <class _Context, class _Tp>
+consteval __arg_t __determine_arg_t();
+
+// Boolean
+template <class, same_as<bool> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__boolean;
+}
+
+// Char
+template <class _Context, same_as<typename _Context::char_type> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__char_type;
+}
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _Context, class _CharT>
+ requires(same_as<typename _Context::char_type, wchar_t> && same_as<_CharT, char>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__char_type;
+}
+# endif
+
+// Signed integers
+template <class, __libcpp_signed_integer _Tp>
+consteval __arg_t __determine_arg_t() {
+ if constexpr (sizeof(_Tp) <= sizeof(int))
+ return __arg_t::__int;
+ else if constexpr (sizeof(_Tp) <= sizeof(long long))
+ return __arg_t::__long_long;
+# ifndef _LIBCPP_HAS_NO_INT128
+ else if constexpr (sizeof(_Tp) == sizeof(__int128_t))
+ return __arg_t::__i128;
+# endif
+ else
+ static_assert(sizeof(_Tp) == 0, "an unsupported signed integer was used");
+}
+
+// Unsigned integers
+template <class, __libcpp_unsigned_integer _Tp>
+consteval __arg_t __determine_arg_t() {
+ if constexpr (sizeof(_Tp) <= sizeof(unsigned))
+ return __arg_t::__unsigned;
+ else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long))
+ return __arg_t::__unsigned_long_long;
+# ifndef _LIBCPP_HAS_NO_INT128
+ else if constexpr (sizeof(_Tp) == sizeof(__uint128_t))
+ return __arg_t::__u128;
+# endif
+ else
+ static_assert(sizeof(_Tp) == 0, "an unsupported unsigned integer was used");
+}
+
+// Floating-point
+template <class, same_as<float> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__float;
+}
+template <class, same_as<double> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__double;
+}
+template <class, same_as<long double> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__long_double;
+}
+
+// Char pointer
+template <class _Context, class _Tp>
+ requires(same_as<typename _Context::char_type*, _Tp> || same_as<const typename _Context::char_type*, _Tp>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__const_char_type_ptr;
+}
+
+// Char array
+template <class _Context, class _Tp>
+ requires(is_array_v<_Tp> && same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__string_view;
+}
+
+// String view
+template <class _Context, class _Tp>
+ requires(same_as<typename _Context::char_type, typename _Tp::value_type> &&
+ same_as<_Tp, basic_string_view<typename _Tp::value_type, typename _Tp::traits_type>>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__string_view;
+}
+
+// String
+template <class _Context, class _Tp>
+ requires(
+ same_as<typename _Context::char_type, typename _Tp::value_type> &&
+ same_as<_Tp, basic_string<typename _Tp::value_type, typename _Tp::traits_type, typename _Tp::allocator_type>>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__string_view;
+}
+
+// Pointers
+template <class, class _Ptr>
+ requires(same_as<_Ptr, void*> || same_as<_Ptr, const void*> || same_as<_Ptr, nullptr_t>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__ptr;
+}
+
+// Handle
+//
+// Note this version can't be constrained avoiding ambiguous overloads.
+// That means it can be instantiated by disabled formatters. To solve this, a
+// constrained version for not formattable formatters is added. That overload
+// is marked as deleted to fail creating a storage type for disabled formatters.
+template <class _Context, class _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__handle;
+}
+
+template <class _Context, class _Tp>
+ requires(!__formattable<_Tp, typename _Context::char_type>)
+consteval __arg_t __determine_arg_t() = delete;
+
+template <class _Context, class _Tp>
+_LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp&& __value) noexcept {
+ constexpr __arg_t __arg = __determine_arg_t<_Context, remove_cvref_t<_Tp>>();
+ static_assert(__arg != __arg_t::__none);
+
+ // Not all types can be used to directly initialize the
+ // __basic_format_arg_value. First handle all types needing adjustment, the
+ // final else requires no adjustment.
+ if constexpr (__arg == __arg_t::__char_type)
+ // On some platforms initializing a wchar_t from a char is a narrowing
+ // conversion.
+ return basic_format_arg<_Context>{__arg, static_cast<typename _Context::char_type>(__value)};
+ else if constexpr (__arg == __arg_t::__int)
+ return basic_format_arg<_Context>{__arg, static_cast<int>(__value)};
+ else if constexpr (__arg == __arg_t::__long_long)
+ return basic_format_arg<_Context>{__arg, static_cast<long long>(__value)};
+ else if constexpr (__arg == __arg_t::__unsigned)
+ return basic_format_arg<_Context>{__arg, static_cast<unsigned>(__value)};
+ else if constexpr (__arg == __arg_t::__unsigned_long_long)
+ return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)};
+ else if constexpr (__arg == __arg_t::__string_view)
+ // Using std::size on a character array will add the NUL-terminator to the size.
+ if constexpr (is_array_v<remove_cvref_t<_Tp>>)
+ return basic_format_arg<_Context>{
+ __arg, basic_string_view<typename _Context::char_type>{__value, extent_v<remove_cvref_t<_Tp>> - 1}};
+ else
+ // When the _Traits or _Allocator are different an implicit conversion will
+ // fail.
+ return basic_format_arg<_Context>{
+ __arg, basic_string_view<typename _Context::char_type>{__value.data(), __value.size()}};
+ else if constexpr (__arg == __arg_t::__ptr)
+ return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)};
+ else if constexpr (__arg == __arg_t::__handle)
+ return basic_format_arg<_Context>{
+ __arg, typename __basic_format_arg_value<_Context>::__handle{_VSTD::forward<_Tp>(__value)}};
+ else
+ return basic_format_arg<_Context>{__arg, __value};
+}
+
+template <class _Context, class... _Args>
+_LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_format_arg_value<_Context>* __values,
+ _Args&&... __args) noexcept {
+ int __shift = 0;
+ (
+ [&] {
+ basic_format_arg<_Context> __arg = __create_format_arg<_Context>(__args);
+ if (__shift != 0)
+ __types |= static_cast<uint64_t>(__arg.__type_) << __shift;
+ else
+ // Assigns the initial value.
+ __types = static_cast<uint64_t>(__arg.__type_);
+ __shift += __packed_arg_t_bits;
+ *__values++ = __arg.__value_;
+ }(),
+ ...);
+}
+
+template <class _Context, class... _Args>
+_LIBCPP_HIDE_FROM_ABI void __store_basic_format_arg(basic_format_arg<_Context>* __data, _Args&&... __args) noexcept {
+ ([&] { *__data++ = __create_format_arg<_Context>(__args); }(), ...);
+}
+
+template <class _Context, size_t N>
+struct __packed_format_arg_store {
+ __basic_format_arg_value<_Context> __values_[N];
+ uint64_t __types_;
+};
+
+template <class _Context, size_t N>
+struct __unpacked_format_arg_store {
+ basic_format_arg<_Context> __args_[N];
+};
+
+} // namespace __format
+
+template <class _Context, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS __format_arg_store {
+ _LIBCPP_HIDE_FROM_ABI
+ __format_arg_store(_Args&... __args) noexcept {
+ if constexpr (sizeof...(_Args) != 0) {
+ if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args)))
+ __format::__create_packed_storage(__storage.__types_, __storage.__values_, __args...);
+ else
+ __format::__store_basic_format_arg<_Context>(__storage.__args_, __args...);
+ }
+ }
+
+ using _Storage = conditional_t<__format::__use_packed_format_arg_store(sizeof...(_Args)),
+ __format::__packed_format_arg_store<_Context, sizeof...(_Args)>,
+ __format::__unpacked_format_arg_store<_Context, sizeof...(_Args)>>;
+
+ _Storage __storage;
+};
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
lib/libcxx/include/__format/format_args.h
@@ -12,60 +12,68 @@
#include <__availability>
#include <__config>
+#include <__format/format_arg.h>
+#include <__format/format_arg_store.h>
#include <__format/format_fwd.h>
#include <cstddef>
+#include <cstdint>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
template <class _Context>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args {
public:
- // TODO FMT Implement [format.args]/5
- // [Note 1: Implementations are encouraged to optimize the representation of
- // basic_format_args for small number of formatting arguments by storing
- // indices of type alternatives separately from values and packing the
- // former. - end note]
- // Note: Change __format_arg_store to use a built-in array.
_LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default;
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI basic_format_args(
- const __format_arg_store<_Context, _Args...>& __store) noexcept
- : __size_(sizeof...(_Args)), __data_(__store.__args.data()) {}
+ _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept
+ : __size_(sizeof...(_Args)) {
+ if constexpr (sizeof...(_Args) != 0) {
+ if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) {
+ __values_ = __store.__storage.__values_;
+ __types_ = __store.__storage.__types_;
+ } else
+ __args_ = __store.__storage.__args_;
+ }
+ }
_LIBCPP_HIDE_FROM_ABI
basic_format_arg<_Context> get(size_t __id) const noexcept {
- return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{};
+ if (__id >= __size_)
+ return basic_format_arg<_Context>{};
+
+ if (__format::__use_packed_format_arg_store(__size_))
+ return basic_format_arg<_Context>{__format::__get_packed_type(__types_, __id), __values_[__id]};
+
+ return __args_[__id];
}
_LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; }
private:
size_t __size_{0};
- const basic_format_arg<_Context>* __data_{nullptr};
+ // [format.args]/5
+ // [Note 1: Implementations are encouraged to optimize the representation of
+ // basic_format_args for small number of formatting arguments by storing
+ // indices of type alternatives separately from values and packing the
+ // former. - end note]
+ union {
+ struct {
+ const __basic_format_arg_value<_Context>* __values_;
+ uint64_t __types_;
+ };
+ const basic_format_arg<_Context>* __args_;
+ };
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP___FORMAT_FORMAT_ARGS_H
lib/libcxx/include/__format/format_context.h
@@ -12,11 +12,14 @@
#include <__availability>
#include <__config>
+#include <__format/buffer.h>
#include <__format/format_args.h>
#include <__format/format_fwd.h>
#include <__iterator/back_insert_iterator.h>
#include <__iterator/concepts.h>
+#include <__utility/move.h>
#include <concepts>
+#include <cstddef>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
#include <locale>
@@ -24,22 +27,13 @@
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
template <class _OutIt, class _CharT>
requires output_iterator<_OutIt, const _CharT&>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context;
@@ -69,16 +63,12 @@ __format_context_create(
}
#endif
-// TODO FMT Implement [format.context]/4
-// [Note 1: For a given type charT, implementations are encouraged to provide a
-// single instantiation of basic_format_context for appending to
-// basic_string<charT>, vector<charT>, or any other container with contiguous
-// storage by wrapping those in temporary objects with a uniform interface
-// (such as a span<charT>) and polymorphic reallocation. - end note]
-
-using format_context = basic_format_context<back_insert_iterator<string>, char>;
+using format_context =
+ basic_format_context<back_insert_iterator<__format::__output_buffer<char>>,
+ char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>;
+using wformat_context = basic_format_context<
+ back_insert_iterator<__format::__output_buffer<wchar_t>>, wchar_t>;
#endif
template <class _OutIt, class _CharT>
@@ -101,7 +91,7 @@ public:
basic_format_context& operator=(const basic_format_context&) = delete;
_LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>
- arg(size_t __id) const {
+ arg(size_t __id) const noexcept {
return __args_.get(__id);
}
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
@@ -154,12 +144,8 @@ private:
#endif
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP___FORMAT_FORMAT_CONTEXT_H
lib/libcxx/include/__format/format_error.h
@@ -18,7 +18,7 @@
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__format/format_fwd.h
@@ -13,44 +13,27 @@
#include <__availability>
#include <__config>
#include <__iterator/concepts.h>
-#include <__utility/forward.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
template <class _Context>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg;
-template <class _Context, class... _Args>
-struct _LIBCPP_TEMPLATE_VIS __format_arg_store;
-
-template <class _Ctx, class... _Args>
-_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Ctx, _Args...>
-make_format_args(const _Args&...);
+template <class _OutIt, class _CharT>
+ requires output_iterator<_OutIt, const _CharT&>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context;
template <class _Tp, class _CharT = char>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP___FORMAT_FORMAT_FWD_H
lib/libcxx/include/__format/format_parse_context.h
@@ -15,19 +15,13 @@
#include <string_view>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
template <class _CharT>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context {
public:
@@ -100,8 +94,6 @@ using format_parse_context = basic_format_parse_context<char>;
using wformat_parse_context = basic_format_parse_context<wchar_t>;
#endif
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/format_string.h
@@ -10,26 +10,20 @@
#ifndef _LIBCPP___FORMAT_FORMAT_STRING_H
#define _LIBCPP___FORMAT_FORMAT_STRING_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__format/format_error.h>
#include <cstddef>
#include <cstdint>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
namespace __format {
template <class _CharT>
@@ -160,8 +154,6 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
} // namespace __format
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/format_to_n_result.h
@@ -21,19 +21,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
template <class _OutIt>
struct _LIBCPP_TEMPLATE_VIS format_to_n_result {
_OutIt out;
iter_difference_t<_OutIt> size;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/formatter.h
@@ -10,34 +10,19 @@
#ifndef _LIBCPP___FORMAT_FORMATTER_H
#define _LIBCPP___FORMAT_FORMATTER_H
-#include <__algorithm/copy.h>
-#include <__algorithm/fill_n.h>
#include <__availability>
+#include <__concepts/same_as.h>
#include <__config>
-#include <__format/format_error.h>
#include <__format/format_fwd.h>
-#include <__format/format_string.h>
-#include <__format/parser_std_format_spec.h>
-#include <concepts>
-#include <string_view>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
/// The default formatter template.
///
/// [format.formatter.spec]/5
@@ -54,237 +39,16 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {
formatter& operator=(const formatter&) = delete;
};
-namespace __format_spec {
-
-_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative,
- _Flags::_Sign __sign) {
- if (__negative)
- *__buf++ = '-';
- else
- switch (__sign) {
- case _Flags::_Sign::__default:
- case _Flags::_Sign::__minus:
- // No sign added.
- break;
- case _Flags::_Sign::__plus:
- *__buf++ = '+';
- break;
- case _Flags::_Sign::__space:
- *__buf++ = ' ';
- break;
- }
-
- return __buf;
-}
-
-_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char c) {
- switch (c) {
- case 'a':
- return 'A';
- case 'b':
- return 'B';
- case 'c':
- return 'C';
- case 'd':
- return 'D';
- case 'e':
- return 'E';
- case 'f':
- return 'F';
- }
- return c;
-}
-
-} // namespace __format_spec
-
namespace __formatter {
/** The character types that formatters are specialized for. */
template <class _CharT>
concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>;
-struct _LIBCPP_TEMPLATE_VIS __padding_size_result {
- size_t __before;
- size_t __after;
-};
-
-_LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result
-__padding_size(size_t __size, size_t __width,
- __format_spec::_Flags::_Alignment __align) {
- _LIBCPP_ASSERT(__width > __size,
- "Don't call this function when no padding is required");
- _LIBCPP_ASSERT(
- __align != __format_spec::_Flags::_Alignment::__default,
- "Caller should adjust the default to the value required by the type");
-
- size_t __fill = __width - __size;
- switch (__align) {
- case __format_spec::_Flags::_Alignment::__default:
- _LIBCPP_UNREACHABLE();
-
- case __format_spec::_Flags::_Alignment::__left:
- return {0, __fill};
-
- case __format_spec::_Flags::_Alignment::__center: {
- // The extra padding is divided per [format.string.std]/3
- // __before = floor(__fill, 2);
- // __after = ceil(__fill, 2);
- size_t __before = __fill / 2;
- size_t __after = __fill - __before;
- return {__before, __after};
- }
- case __format_spec::_Flags::_Alignment::__right:
- return {__fill, 0};
- }
- _LIBCPP_UNREACHABLE();
-}
-
-/**
- * Writes the input to the output with the required padding.
- *
- * Since the output column width is specified the function can be used for
- * ASCII and Unicode input.
- *
- * @pre [@a __first, @a __last) is a valid range.
- * @pre @a __size <= @a __width. Using this function when this pre-condition
- * doesn't hold incurs an unwanted overhead.
- *
- * @param __out_it The output iterator to write to.
- * @param __first Pointer to the first element to write.
- * @param __last Pointer beyond the last element to write.
- * @param __size The (estimated) output column width. When the elements
- * to be written are ASCII the following condition holds
- * @a __size == @a __last - @a __first.
- * @param __width The number of output columns to write.
- * @param __fill The character used for the alignment of the output.
- * TODO FMT Will probably change to support Unicode grapheme
- * cluster.
- * @param __alignment The requested alignment.
- *
- * @returns An iterator pointing beyond the last element written.
- *
- * @note The type of the elements in range [@a __first, @a __last) can differ
- * from the type of @a __fill. Integer output uses @c std::to_chars for its
- * conversion, which means the [@a __first, @a __last) always contains elements
- * of the type @c char.
- */
-template <class _CharT, class _Fill>
-_LIBCPP_HIDE_FROM_ABI auto
-__write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
- const _CharT* __last, size_t __size, size_t __width, _Fill __fill,
- __format_spec::_Flags::_Alignment __alignment) -> decltype(__out_it) {
-
- _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
- _LIBCPP_ASSERT(__size < __width, "Precondition failure");
-
- __padding_size_result __padding =
- __padding_size(__size, __width, __alignment);
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
- __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it));
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
-}
-
-/**
- * @overload
- *
- * Writes additional zero's for the precision before the exponent.
- * This is used when the precision requested in the format string is larger
- * than the maximum precision of the floating-point type. These precision
- * digits are always 0.
- *
- * @param __exponent The location of the exponent character.
- * @param __num_trailing_zeros The number of 0's to write before the exponent
- * character.
- */
-template <class _CharT, class _Fill>
-_LIBCPP_HIDE_FROM_ABI auto __write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
- const _CharT* __last, size_t __size, size_t __width, _Fill __fill,
- __format_spec::_Flags::_Alignment __alignment, const _CharT* __exponent,
- size_t __num_trailing_zeros) -> decltype(__out_it) {
- _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
- _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");
-
- __padding_size_result __padding = __padding_size(__size + __num_trailing_zeros, __width, __alignment);
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
- __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it));
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
- __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it));
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
-}
-
-/**
- * @overload
- *
- * Uses a transformation operation before writing an element.
- *
- * TODO FMT Fill will probably change to support Unicode grapheme cluster.
- */
-template <class _CharT, class _UnaryOperation, class _Fill>
-_LIBCPP_HIDE_FROM_ABI auto
-__write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first,
- const _CharT* __last, size_t __size, _UnaryOperation __op,
- size_t __width, _Fill __fill,
- __format_spec::_Flags::_Alignment __alignment) -> decltype(__out_it) {
-
- _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
- _LIBCPP_ASSERT(__size < __width, "Precondition failure");
-
- __padding_size_result __padding =
- __padding_size(__size, __width, __alignment);
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
- __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
-}
-
-/**
- * Writes Unicode input to the output with the required padding.
- *
- * This function does almost the same as the @ref __write function, but handles
- * the width estimation of the Unicode input.
- *
- * @param __str The range [@a __first, @a __last).
- * @param __precision The width to truncate the input string to, use @c -1 for
- * no limit.
- */
-template <class _CharT, class _Fill>
-_LIBCPP_HIDE_FROM_ABI auto
-__write_unicode(output_iterator<const _CharT&> auto __out_it,
- basic_string_view<_CharT> __str, ptrdiff_t __width,
- ptrdiff_t __precision, _Fill __fill,
- __format_spec::_Flags::_Alignment __alignment)
- -> decltype(__out_it) {
-
- // This value changes when there Unicode column width limits the output
- // size.
- auto __last = __str.end();
- if (__width != 0 || __precision != -1) {
- __format_spec::__string_alignment<_CharT> __format_traits =
- __format_spec::__get_string_alignment(__str.begin(), __str.end(),
- __width, __precision);
-
- if (__format_traits.__align)
- return __write(_VSTD::move(__out_it), __str.begin(),
- __format_traits.__last, __format_traits.__size, __width,
- __fill, __alignment);
-
- // No alignment required update the output based on the precision.
- // This might be the same as __str.end().
- __last = __format_traits.__last;
- }
-
- // Copy the input to the output. The output size might be limited by the
- // precision.
- return _VSTD::copy(__str.begin(), __last, _VSTD::move(__out_it));
-}
-
} // namespace __formatter
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP___FORMAT_FORMATTER_H
lib/libcxx/include/__format/formatter_bool.h
@@ -10,136 +10,67 @@
#ifndef _LIBCPP___FORMAT_FORMATTER_BOOL_H
#define _LIBCPP___FORMAT_FORMATTER_BOOL_H
+#include <__algorithm/copy.h>
#include <__availability>
#include <__config>
+#include <__debug>
#include <__format/format_error.h>
#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
#include <__format/parser_std_format_spec.h>
+#include <__utility/unreachable.h>
#include <string_view>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include <locale>
+# include <locale>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-namespace __format_spec {
-
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_bool : public __parser_integral<_CharT> {
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> {
public:
- _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
- -> decltype(__parse_ctx.begin()) {
- auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);
-
- switch (this->__type) {
- case _Flags::_Type::__default:
- this->__type = _Flags::_Type::__string;
- [[fallthrough]];
- case _Flags::_Type::__string:
- this->__handle_bool();
- break;
-
- case _Flags::_Type::__char:
- this->__handle_char();
- break;
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
+ __format_spec::__process_parsed_bool(__parser_);
+ return __result;
+ }
- case _Flags::_Type::__binary_lower_case:
- case _Flags::_Type::__binary_upper_case:
- case _Flags::_Type::__octal:
- case _Flags::_Type::__decimal:
- case _Flags::_Type::__hexadecimal_lower_case:
- case _Flags::_Type::__hexadecimal_upper_case:
- this->__handle_integer();
- break;
+ _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ switch (__parser_.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__string:
+ return __formatter::__format_bool(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
+
+ case __format_spec::__type::__binary_lower_case:
+ case __format_spec::__type::__binary_upper_case:
+ case __format_spec::__type::__octal:
+ case __format_spec::__type::__decimal:
+ case __format_spec::__type::__hexadecimal_lower_case:
+ case __format_spec::__type::__hexadecimal_upper_case:
+ // Promotes bool to an integral type. This reduces the number of
+ // instantiations of __format_integer reducing code size.
+ return __formatter::__format_integer(
+ static_cast<unsigned>(__value), __ctx, __parser_.__get_parsed_std_specifications(__ctx));
default:
- __throw_format_error(
- "The format-spec type has a type not supported for a bool argument");
+ _LIBCPP_ASSERT(false, "The parse function should have validated the type");
+ __libcpp_unreachable();
}
-
- return __it;
}
-};
-
-template <class _CharT>
-struct _LIBCPP_TEMPLATE_VIS __bool_strings;
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {
- static constexpr string_view __true{"true"};
- static constexpr string_view __false{"false"};
-};
-
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template <>
-struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {
- static constexpr wstring_view __true{L"true"};
- static constexpr wstring_view __false{L"false"};
-};
-#endif
-template <class _CharT>
-using __formatter_bool = __formatter_integral<__parser_bool<_CharT>>;
-
-} //namespace __format_spec
-
-// [format.formatter.spec]/2.3
-// For each charT, for each cv-unqualified arithmetic type ArithmeticT other
-// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization
-
-template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT>
- : public __format_spec::__formatter_bool<_CharT> {
- using _Base = __format_spec::__formatter_bool<_CharT>;
-
- _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx)
- -> decltype(__ctx.out()) {
- if (this->__type != __format_spec::_Flags::_Type::__string)
- return _Base::format(static_cast<unsigned char>(__value), __ctx);
-
- if (this->__width_needs_substitution())
- this->__substitute_width_arg_id(__ctx.arg(this->__width));
-
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
- if (this->__locale_specific_form) {
- const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
- basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
- return __formatter::__write_unicode(
- __ctx.out(), basic_string_view<_CharT>{__str}, this->__width, -1,
- this->__fill, this->__alignment);
- }
-#endif
- basic_string_view<_CharT> __str =
- __value ? __format_spec::__bool_strings<_CharT>::__true
- : __format_spec::__bool_strings<_CharT>::__false;
-
- // The output only uses ASCII so every character is one column.
- unsigned __size = __str.size();
- if (__size >= this->__width)
- return _VSTD::copy(__str.begin(), __str.end(), __ctx.out());
-
- return __formatter::__write(__ctx.out(), __str.begin(), __str.end(), __size,
- this->__width, this->__fill, this->__alignment);
- }
+ __format_spec::__parser<_CharT> __parser_;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/formatter_char.h
@@ -11,91 +11,71 @@
#define _LIBCPP___FORMAT_FORMATTER_CHAR_H
#include <__availability>
+#include <__concepts/same_as.h>
#include <__config>
-#include <__format/format_error.h>
#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
+#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_signed.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-namespace __format_spec {
-
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_char : public __parser_integral<_CharT> {
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char {
public:
- _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
- -> decltype(__parse_ctx.begin()) {
- auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);
-
- switch (this->__type) {
- case _Flags::_Type::__default:
- this->__type = _Flags::_Type::__char;
- [[fallthrough]];
- case _Flags::_Type::__char:
- this->__handle_char();
- break;
-
- case _Flags::_Type::__binary_lower_case:
- case _Flags::_Type::__binary_upper_case:
- case _Flags::_Type::__octal:
- case _Flags::_Type::__decimal:
- case _Flags::_Type::__hexadecimal_lower_case:
- case _Flags::_Type::__hexadecimal_upper_case:
- this->__handle_integer();
- break;
-
- default:
- __throw_format_error(
- "The format-spec type has a type not supported for a char argument");
- }
-
- return __it;
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
+ __format_spec::__process_parsed_char(__parser_);
+ return __result;
}
-};
-template <class _CharT>
-using __formatter_char = __formatter_integral<__parser_char<_CharT>>;
+ _LIBCPP_HIDE_FROM_ABI auto format(_CharT __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char)
+ return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+
+ if constexpr (sizeof(_CharT) <= sizeof(int))
+ // Promotes _CharT to an integral type. This reduces the number of
+ // instantiations of __format_integer reducing code size.
+ return __formatter::__format_integer(
+ static_cast<conditional_t<is_signed_v<_CharT>, int, unsigned>>(__value),
+ __ctx,
+ __parser_.__get_parsed_std_specifications(__ctx));
+ else
+ return __formatter::__format_integer(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
+ }
-} // namespace __format_spec
+ _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) const -> decltype(__ctx.out())
+ requires(same_as<_CharT, wchar_t>)
+ {
+ return format(static_cast<wchar_t>(__value), __ctx);
+ }
-// [format.formatter.spec]/2.1 The specializations
+ __format_spec::__parser<_CharT> __parser_;
+};
template <>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char>
- : public __format_spec::__formatter_char<char> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char> : public __formatter_char<char> {};
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t>
- : public __format_spec::__formatter_char<wchar_t> {
- using _Base = __format_spec::__formatter_char<wchar_t>;
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t> : public __formatter_char<wchar_t> {};
- _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx)
- -> decltype(__ctx.out()) {
- return _Base::format(static_cast<wchar_t>(__value), __ctx);
- }
+template <>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {
};
-template <>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<wchar_t, wchar_t>
- : public __format_spec::__formatter_char<wchar_t> {};
-#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/formatter_floating_point.h
@@ -18,17 +18,18 @@
#include <__algorithm/rotate.h>
#include <__algorithm/transform.h>
#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
#include <__config>
-#include <__debug>
-#include <__format/format_error.h>
#include <__format/format_fwd.h>
-#include <__format/format_string.h>
+#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
+#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
+#include <__memory/allocator.h>
#include <__utility/move.h>
+#include <__utility/unreachable.h>
#include <charconv>
-#include <cmath>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
# include <locale>
@@ -45,13 +46,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-namespace __format_spec {
+namespace __formatter {
template <floating_point _Tp>
_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value) {
@@ -167,7 +162,7 @@ public:
__precision_ = _Traits::__max_fractional;
}
- __size_ = __format_spec::__float_buffer_size<_Fp>(__precision_);
+ __size_ = __formatter::__float_buffer_size<_Fp>(__precision_);
if (__size_ > _Traits::__stack_buffer_size)
// The allocated buffer's contents don't need initialization.
__begin_ = allocator<char>{}.allocate(__size_);
@@ -236,9 +231,9 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_default(const __float_buffe
char* __integral) {
__float_result __result;
__result.__integral = __integral;
- __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value);
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value);
- __result.__exponent = __format_spec::__find_exponent(__result.__integral, __result.__last);
+ __result.__exponent = __formatter::__find_exponent(__result.__integral, __result.__last);
// Constrains:
// - There's at least one decimal digit before the radix point.
@@ -267,9 +262,9 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_lower_case(cons
__float_result __result;
__result.__integral = __integral;
if (__precision == -1)
- __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex);
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex);
else
- __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision);
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision);
// H = one or more hex-digits
// S = sign
@@ -318,7 +313,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_upper_case(cons
_Tp __value, int __precision,
char* __integral) {
__float_result __result =
- __format_spec::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral);
+ __formatter::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral);
_VSTD::transform(__result.__integral, __result.__exponent, __result.__integral, __hex_to_upper);
*__result.__exponent = 'P';
return __result;
@@ -331,13 +326,13 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_lower_case(const
__float_result __result;
__result.__integral = __integral;
__result.__last =
- __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision);
+ __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision);
char* __first = __integral + 1;
_LIBCPP_ASSERT(__first != __result.__last, "No exponent present");
if (*__first == '.') {
__result.__radix_point = __first;
- __result.__exponent = __format_spec::__find_exponent(__first + 1, __result.__last);
+ __result.__exponent = __formatter::__find_exponent(__first + 1, __result.__last);
} else {
__result.__radix_point = __result.__last;
__result.__exponent = __first;
@@ -357,7 +352,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_upper_case(const
_Tp __value, int __precision,
char* __integral) {
__float_result __result =
- __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral);
+ __formatter::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral);
*__result.__exponent = 'E';
return __result;
}
@@ -367,7 +362,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_fixed(const __float_buffer<
int __precision, char* __integral) {
__float_result __result;
__result.__integral = __integral;
- __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision);
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision);
// When there's no precision there's no radix point.
// Else the radix point is placed at __precision + 1 from the end.
@@ -393,14 +388,14 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_
__float_result __result;
__result.__integral = __integral;
- __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision);
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision);
char* __first = __integral + 1;
if (__first == __result.__last) {
__result.__radix_point = __result.__last;
__result.__exponent = __result.__last;
} else {
- __result.__exponent = __format_spec::__find_exponent(__first, __result.__last);
+ __result.__exponent = __formatter::__find_exponent(__first, __result.__last);
if (__result.__exponent != __result.__last)
// In scientific mode if there's a radix point it will always be after
// the first digit. (This is the position __first points at).
@@ -426,19 +421,79 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_
template <class _Fp, class _Tp>
_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_upper_case(__float_buffer<_Fp>& __buffer, _Tp __value,
int __precision, char* __integral) {
- __float_result __result =
- __format_spec::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral);
+ __float_result __result = __formatter::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral);
if (__result.__exponent != __result.__last)
*__result.__exponent = 'E';
return __result;
}
-# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+/// Fills the buffer with the data based on the requested formatting.
+///
+/// This function, when needed, turns the characters to upper case and
+/// determines the "interesting" locations which are returned to the caller.
+///
+/// This means the caller never has to convert the contents of the buffer to
+/// upper case or search for radix points and the location of the exponent.
+/// This gives a bit of overhead. The original code didn't do that, but due
+/// to the number of possible additional work needed to turn this number to
+/// the proper output the code was littered with tests for upper cases and
+/// searches for radix points and exponents.
+/// - When a precision larger than the type's precision is selected
+/// additional zero characters need to be written before the exponent.
+/// - alternate form needs to add a radix point when not present.
+/// - localization needs to do grouping in the integral part.
+template <class _Fp, class _Tp>
+// TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(
+ __float_buffer<_Fp>& __buffer,
+ _Tp __value,
+ bool __negative,
+ bool __has_precision,
+ __format_spec::__sign __sign,
+ __format_spec::__type __type) {
+ char* __first = __formatter::__insert_sign(__buffer.begin(), __negative, __sign);
+ switch (__type) {
+ case __format_spec::__type::__default:
+ return __formatter::__format_buffer_default(__buffer, __value, __first);
+
+ case __format_spec::__type::__hexfloat_lower_case:
+ return __formatter::__format_buffer_hexadecimal_lower_case(
+ __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
+
+ case __format_spec::__type::__hexfloat_upper_case:
+ return __formatter::__format_buffer_hexadecimal_upper_case(
+ __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
+
+ case __format_spec::__type::__scientific_lower_case:
+ return __formatter::__format_buffer_scientific_lower_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case __format_spec::__type::__scientific_upper_case:
+ return __formatter::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case __format_spec::__type::__fixed_lower_case:
+ case __format_spec::__type::__fixed_upper_case:
+ return __formatter::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first);
+
+ case __format_spec::__type::__general_lower_case:
+ return __formatter::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case __format_spec::__type::__general_upper_case:
+ return __formatter::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first);
+
+ default:
+ _LIBCPP_ASSERT(false, "The parser should have validated the type");
+ __libcpp_unreachable();
+ }
+}
+
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
template <class _OutIt, class _Fp, class _CharT>
-_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, const __float_buffer<_Fp>& __buffer,
- const __float_result& __result, _VSTD::locale __loc,
- size_t __width, _Flags::_Alignment __alignment,
- _CharT __fill) {
+_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
+ _OutIt __out_it,
+ const __float_buffer<_Fp>& __buffer,
+ const __float_result& __result,
+ _VSTD::locale __loc,
+ __format_spec::__parsed_specifications<_CharT> __specs) {
const auto& __np = use_facet<numpunct<_CharT>>(__loc);
string __grouping = __np.grouping();
char* __first = __result.__integral;
@@ -450,29 +505,30 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons
if (__digits <= __grouping[0])
__grouping.clear();
else
- __grouping = __determine_grouping(__digits, __grouping);
+ __grouping = __formatter::__determine_grouping(__digits, __grouping);
}
- size_t __size = __result.__last - __buffer.begin() + // Formatted string
- __buffer.__num_trailing_zeros() + // Not yet rendered zeros
- __grouping.size() - // Grouping contains one
- !__grouping.empty(); // additional character
+ ptrdiff_t __size =
+ __result.__last - __buffer.begin() + // Formatted string
+ __buffer.__num_trailing_zeros() + // Not yet rendered zeros
+ __grouping.size() - // Grouping contains one
+ !__grouping.empty(); // additional character
- __formatter::__padding_size_result __padding = {0, 0};
- bool __zero_padding = __alignment == _Flags::_Alignment::__default;
- if (__size < __width) {
+ __formatter::__padding_size_result __padding = {0, 0};
+ bool __zero_padding = __specs.__alignment_ == __format_spec::__alignment::__zero_padding;
+ if (__size < __specs.__width_) {
if (__zero_padding) {
- __alignment = _Flags::_Alignment::__right;
- __fill = _CharT('0');
+ __specs.__alignment_ = __format_spec::__alignment::__right;
+ __specs.__fill_ = _CharT('0');
}
- __padding = __formatter::__padding_size(__size, __width, __alignment);
+ __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
}
// sign and (zero padding or alignment)
if (__zero_padding && __first != __buffer.begin())
*__out_it++ = *__buffer.begin();
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill);
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
if (!__zero_padding && __first != __buffer.begin())
*__out_it++ = *__buffer.begin();
@@ -513,200 +569,148 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons
__out_it = _VSTD::copy(__result.__exponent, __result.__last, _VSTD::move(__out_it));
// alignment
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill);
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+# endif // _LIBCPP_HAS_NO_LOCALIZATION
+
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI _OutIt __format_floating_point_non_finite(
+ _OutIt __out_it, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative, bool __isnan) {
+ char __buffer[4];
+ char* __last = __formatter::__insert_sign(__buffer, __negative, __specs.__std_.__sign_);
+
+ // to_chars can return inf, infinity, nan, and nan(n-char-sequence).
+ // The format library requires inf and nan.
+ // All in one expression to avoid dangling references.
+ bool __upper_case =
+ __specs.__std_.__type_ == __format_spec::__type::__hexfloat_upper_case ||
+ __specs.__std_.__type_ == __format_spec::__type::__scientific_upper_case ||
+ __specs.__std_.__type_ == __format_spec::__type::__fixed_upper_case ||
+ __specs.__std_.__type_ == __format_spec::__type::__general_upper_case;
+ __last = _VSTD::copy_n(&("infnanINFNAN"[6 * __upper_case + 3 * __isnan]), 3, __last);
+
+ // [format.string.std]/13
+ // A zero (0) character preceding the width field pads the field with
+ // leading zeros (following any indication of sign or base) to the field
+ // width, except when applied to an infinity or NaN.
+ if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding)
+ __specs.__alignment_ = __format_spec::__alignment::__right;
+
+ return __formatter::__write(__buffer, __last, _VSTD::move(__out_it), __specs);
}
-# endif // _LIBCPP_HAS_NO_LOCALIZATION
-
-template <__formatter::__char_type _CharT>
-class _LIBCPP_TEMPLATE_VIS __formatter_floating_point : public __parser_floating_point<_CharT> {
-public:
- template <floating_point _Tp>
- _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) -> decltype(__ctx.out()) {
- if (this->__width_needs_substitution())
- this->__substitute_width_arg_id(__ctx.arg(this->__width));
-
- bool __negative = _VSTD::signbit(__value);
-
- if (!_VSTD::isfinite(__value)) [[unlikely]]
- return __format_non_finite(__ctx.out(), __negative, _VSTD::isnan(__value));
-
- bool __has_precision = this->__has_precision_field();
- if (this->__precision_needs_substitution())
- this->__substitute_precision_arg_id(__ctx.arg(this->__precision));
-
- // Depending on the std-format-spec string the sign and the value
- // might not be outputted together:
- // - zero-padding may insert additional '0' characters.
- // Therefore the value is processed as a non negative value.
- // The function @ref __insert_sign will insert a '-' when the value was
- // negative.
-
- if (__negative)
- __value = _VSTD::copysign(__value, +1.0);
-
- // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
- using _Fp = conditional_t<same_as<_Tp, long double>, double, _Tp>;
- // Force the type of the precision to avoid -1 to become an unsigned value.
- __float_buffer<_Fp> __buffer(__has_precision ? int(this->__precision) : -1);
- __float_result __result = __format_buffer(__buffer, __value, __negative, __has_precision);
-
- if (this->__alternate_form && __result.__radix_point == __result.__last) {
- *__result.__last++ = '.';
-
- // When there is an exponent the point needs to be moved before the
- // exponent. When there's no exponent the rotate does nothing. Since
- // rotate tests whether the operation is a nop, call it unconditionally.
- _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);
- __result.__radix_point = __result.__exponent;
-
- // The radix point is always placed before the exponent.
- // - No exponent needs to point to the new last.
- // - An exponent needs to move one position to the right.
- // So it's safe to increment the value unconditionally.
- ++__result.__exponent;
- }
+template <floating_point _Tp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
+ -> decltype(__ctx.out()) {
+ bool __negative = _VSTD::signbit(__value);
-# ifndef _LIBCPP_HAS_NO_LOCALIZATION
- if (this->__locale_specific_form)
- return __format_spec::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(),
- this->__width, this->__alignment, this->__fill);
-# endif
-
- ptrdiff_t __size = __result.__last - __buffer.begin();
- int __num_trailing_zeros = __buffer.__num_trailing_zeros();
- if (__size + __num_trailing_zeros >= this->__width) {
- if (__num_trailing_zeros && __result.__exponent != __result.__last)
- // Insert trailing zeros before exponent character.
- return _VSTD::copy(__result.__exponent, __result.__last,
- _VSTD::fill_n(_VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()),
- __num_trailing_zeros, _CharT('0')));
-
- return _VSTD::fill_n(_VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros,
- _CharT('0'));
- }
+ if (!_VSTD::isfinite(__value)) [[unlikely]]
+ return __formatter::__format_floating_point_non_finite(__ctx.out(), __specs, __negative, _VSTD::isnan(__value));
- auto __out_it = __ctx.out();
- char* __first = __buffer.begin();
- if (this->__alignment == _Flags::_Alignment::__default) {
- // When there is a sign output it before the padding. Note the __size
- // doesn't need any adjustment, regardless whether the sign is written
- // here or in __formatter::__write.
- if (__first != __result.__integral)
- *__out_it++ = *__first++;
- // After the sign is written, zero padding is the same a right alignment
- // with '0'.
- this->__alignment = _Flags::_Alignment::__right;
- this->__fill = _CharT('0');
- }
+ // Depending on the std-format-spec string the sign and the value
+ // might not be outputted together:
+ // - zero-padding may insert additional '0' characters.
+ // Therefore the value is processed as a non negative value.
+ // The function @ref __insert_sign will insert a '-' when the value was
+ // negative.
- if (__num_trailing_zeros)
- return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill,
- this->__alignment, __result.__exponent, __num_trailing_zeros);
+ if (__negative)
+ __value = -__value;
- return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill,
- this->__alignment);
+ // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
+ using _Fp = conditional_t<same_as<_Tp, long double>, double, _Tp>;
+ // Force the type of the precision to avoid -1 to become an unsigned value.
+ __float_buffer<_Fp> __buffer(__specs.__precision_);
+ __float_result __result = __formatter::__format_buffer(
+ __buffer, __value, __negative, (__specs.__has_precision()), __specs.__std_.__sign_, __specs.__std_.__type_);
+
+ if (__specs.__std_.__alternate_form_ && __result.__radix_point == __result.__last) {
+ *__result.__last++ = '.';
+
+ // When there is an exponent the point needs to be moved before the
+ // exponent. When there's no exponent the rotate does nothing. Since
+ // rotate tests whether the operation is a nop, call it unconditionally.
+ _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);
+ __result.__radix_point = __result.__exponent;
+
+ // The radix point is always placed before the exponent.
+ // - No exponent needs to point to the new last.
+ // - An exponent needs to move one position to the right.
+ // So it's safe to increment the value unconditionally.
+ ++__result.__exponent;
}
-private:
- template <class _OutIt>
- _LIBCPP_HIDE_FROM_ABI _OutIt __format_non_finite(_OutIt __out_it, bool __negative, bool __isnan) {
- char __buffer[4];
- char* __last = __insert_sign(__buffer, __negative, this->__sign);
-
- // to_char can return inf, infinity, nan, and nan(n-char-sequence).
- // The format library requires inf and nan.
- // All in one expression to avoid dangling references.
- __last = _VSTD::copy_n(&("infnanINFNAN"[6 * (this->__type == _Flags::_Type::__float_hexadecimal_upper_case ||
- this->__type == _Flags::_Type::__scientific_upper_case ||
- this->__type == _Flags::_Type::__fixed_upper_case ||
- this->__type == _Flags::_Type::__general_upper_case) +
- 3 * __isnan]),
- 3, __last);
-
- // [format.string.std]/13
- // A zero (0) character preceding the width field pads the field with
- // leading zeros (following any indication of sign or base) to the field
- // width, except when applied to an infinity or NaN.
- if (this->__alignment == _Flags::_Alignment::__default)
- this->__alignment = _Flags::_Alignment::__right;
-
- ptrdiff_t __size = __last - __buffer;
- if (__size >= this->__width)
- return _VSTD::copy_n(__buffer, __size, _VSTD::move(__out_it));
-
- return __formatter::__write(_VSTD::move(__out_it), __buffer, __last, __size, this->__width, this->__fill,
- this->__alignment);
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (__specs.__std_.__locale_specific_form_)
+ return __formatter::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(), __specs);
+# endif
+
+ ptrdiff_t __size = __result.__last - __buffer.begin();
+ int __num_trailing_zeros = __buffer.__num_trailing_zeros();
+ if (__size + __num_trailing_zeros >= __specs.__width_) {
+ if (__num_trailing_zeros && __result.__exponent != __result.__last)
+ // Insert trailing zeros before exponent character.
+ return _VSTD::copy(
+ __result.__exponent,
+ __result.__last,
+ _VSTD::fill_n(
+ _VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()), __num_trailing_zeros, _CharT('0')));
+
+ return _VSTD::fill_n(
+ _VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0'));
}
- /// Fills the buffer with the data based on the requested formatting.
- ///
- /// This function, when needed, turns the characters to upper case and
- /// determines the "interesting" locations which are returned to the caller.
- ///
- /// This means the caller never has to convert the contents of the buffer to
- /// upper case or search for radix points and the location of the exponent.
- /// This gives a bit of overhead. The original code didn't do that, but due
- /// to the number of possible additional work needed to turn this number to
- /// the proper output the code was littered with tests for upper cases and
- /// searches for radix points and exponents.
- /// - When a precision larger than the type's precision is selected
- /// additional zero characters need to be written before the exponent.
- /// - alternate form needs to add a radix point when not present.
- /// - localization needs to do grouping in the integral part.
- template <class _Fp, class _Tp>
- // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
- _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(__float_buffer<_Fp>& __buffer, _Tp __value, bool __negative,
- bool __has_precision) {
- char* __first = __insert_sign(__buffer.begin(), __negative, this->__sign);
- switch (this->__type) {
- case _Flags::_Type::__default:
- return __format_spec::__format_buffer_default(__buffer, __value, __first);
-
- case _Flags::_Type::__float_hexadecimal_lower_case:
- return __format_spec::__format_buffer_hexadecimal_lower_case(
- __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
-
- case _Flags::_Type::__float_hexadecimal_upper_case:
- return __format_spec::__format_buffer_hexadecimal_upper_case(
- __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
-
- case _Flags::_Type::__scientific_lower_case:
- return __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __buffer.__precision(), __first);
+ auto __out_it = __ctx.out();
+ char* __first = __buffer.begin();
+ if (__specs.__alignment_ == __format_spec::__alignment ::__zero_padding) {
+ // When there is a sign output it before the padding. Note the __size
+ // doesn't need any adjustment, regardless whether the sign is written
+ // here or in __formatter::__write.
+ if (__first != __result.__integral)
+ *__out_it++ = *__first++;
+ // After the sign is written, zero padding is the same a right alignment
+ // with '0'.
+ __specs.__alignment_ = __format_spec::__alignment::__right;
+ __specs.__fill_ = _CharT('0');
+ }
- case _Flags::_Type::__scientific_upper_case:
- return __format_spec::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first);
+ if (__num_trailing_zeros)
+ return __formatter::__write_using_trailing_zeros(
+ __first, __result.__last, _VSTD::move(__out_it), __specs, __size, __result.__exponent, __num_trailing_zeros);
- case _Flags::_Type::__fixed_lower_case:
- case _Flags::_Type::__fixed_upper_case:
- return __format_spec::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first);
+ return __formatter::__write(__first, __result.__last, _VSTD::move(__out_it), __specs, __size);
+}
- case _Flags::_Type::__general_lower_case:
- return __format_spec::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
+} // namespace __formatter
- case _Flags::_Type::__general_upper_case:
- return __format_spec::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first);
+template <__formatter::__char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_floating_point);
+ __format_spec::__process_parsed_floating_point(__parser_);
+ return __result;
+ }
- default:
- _LIBCPP_ASSERT(false, "The parser should have validated the type");
- _LIBCPP_UNREACHABLE();
- }
+ template <floating_point _Tp>
+ _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ return __formatter::__format_floating_point(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
}
-};
-} //namespace __format_spec
+ __format_spec::__parser<_CharT> __parser_;
+};
template <__formatter::__char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>
- : public __format_spec::__formatter_floating_point<_CharT> {};
+ : public __formatter_floating_point<_CharT> {};
template <__formatter::__char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>
- : public __format_spec::__formatter_floating_point<_CharT> {};
+ : public __formatter_floating_point<_CharT> {};
template <__formatter::__char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>
- : public __format_spec::__formatter_floating_point<_CharT> {};
-
-# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+ : public __formatter_floating_point<_CharT> {};
#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/formatter_integer.h
@@ -11,160 +11,97 @@
#define _LIBCPP___FORMAT_FORMATTER_INTEGER_H
#include <__availability>
+#include <__concepts/arithmetic.h>
#include <__config>
-#include <__format/format_error.h>
#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
+#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
-#include <limits>
+#include <__type_traits/make_32_64_or_128_bit.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-_LIBCPP_BEGIN_NAMESPACE_STD
+ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-namespace __format_spec {
+ template <__formatter::__char_type _CharT>
+ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer {
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_integer : public __parser_integral<_CharT> {
public:
- _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
- -> decltype(__parse_ctx.begin()) {
- auto __it = __parser_integral<_CharT>::__parse(__parse_ctx);
-
- switch (this->__type) {
- case _Flags::_Type::__default:
- this->__type = _Flags::_Type::__decimal;
- [[fallthrough]];
-
- case _Flags::_Type::__binary_lower_case:
- case _Flags::_Type::__binary_upper_case:
- case _Flags::_Type::__octal:
- case _Flags::_Type::__decimal:
- case _Flags::_Type::__hexadecimal_lower_case:
- case _Flags::_Type::__hexadecimal_upper_case:
- this->__handle_integer();
- break;
-
- case _Flags::_Type::__char:
- this->__handle_char();
- break;
-
- default:
- __throw_format_error("The format-spec type has a type not supported for "
- "an integer argument");
- }
- return __it;
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
+ __format_spec::__process_parsed_integer(__parser_);
+ return __result;
}
-};
-template <class _CharT>
-using __formatter_integer = __formatter_integral<__parser_integer<_CharT>>;
+ template <integral _Tp>
+ _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
+
+ if (__specs.__std_.__type_ == __format_spec::__type::__char)
+ return __formatter::__format_char(__value, __ctx.out(), __specs);
-} // namespace __format_spec
+ using _Type = __make_32_64_or_128_bit_t<_Tp>;
+ static_assert(!is_same<_Type, void>::value, "unsupported integral type used in __formatter_integer::__format");
-// [format.formatter.spec]/2.3
-// For each charT, for each cv-unqualified arithmetic type ArithmeticT other
-// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization
+ // Reduce the number of instantiation of the integer formatter
+ return __formatter::__format_integer(static_cast<_Type>(__value), __ctx, __specs);
+ }
+
+ __format_spec::__parser<_CharT> __parser_;
+};
// Signed integral types.
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<signed char, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT>
+ : public __formatter_integer<_CharT> {};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> {
+};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<long long, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
-#ifndef _LIBCPP_HAS_NO_INT128
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT>
+ : public __formatter_integer<_CharT> {};
+# ifndef _LIBCPP_HAS_NO_INT128
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<__int128_t, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {
- using _Base = __format_spec::__formatter_integer<_CharT>;
-
- _LIBCPP_HIDE_FROM_ABI auto format(__int128_t __value, auto& __ctx)
- -> decltype(__ctx.out()) {
- // TODO FMT Implement full 128 bit support.
- using _To = long long;
- if (__value < numeric_limits<_To>::min() ||
- __value > numeric_limits<_To>::max())
- __throw_format_error("128-bit value is outside of implemented range");
-
- return _Base::format(static_cast<_To>(__value), __ctx);
- }
-};
-#endif
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT>
+ : public __formatter_integer<_CharT> {};
+# endif
// Unsigned integral types.
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<unsigned char, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT>
+ : public __formatter_integer<_CharT> {};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<unsigned short, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT>
+ : public __formatter_integer<_CharT> {};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<unsigned, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT>
+ : public __formatter_integer<_CharT> {};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<unsigned long, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT>
+ : public __formatter_integer<_CharT> {};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<unsigned long long, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {};
-#ifndef _LIBCPP_HAS_NO_INT128
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT>
+ : public __formatter_integer<_CharT> {};
+# ifndef _LIBCPP_HAS_NO_INT128
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<__uint128_t, _CharT>
- : public __format_spec::__formatter_integer<_CharT> {
- using _Base = __format_spec::__formatter_integer<_CharT>;
-
- _LIBCPP_HIDE_FROM_ABI auto format(__uint128_t __value, auto& __ctx)
- -> decltype(__ctx.out()) {
- // TODO FMT Implement full 128 bit support.
- using _To = unsigned long long;
- if (__value < numeric_limits<_To>::min() ||
- __value > numeric_limits<_To>::max())
- __throw_format_error("128-bit value is outside of implemented range");
-
- return _Base::format(static_cast<_To>(__value), __ctx);
- }
-};
-#endif
-
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT>
+ : public __formatter_integer<_CharT> {};
+# endif
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP___FORMAT_FORMATTER_INTEGER_H
lib/libcxx/include/__format/formatter_integral.h
@@ -10,27 +10,24 @@
#ifndef _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
#define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
-#include <__algorithm/copy.h>
-#include <__algorithm/copy_n.h>
-#include <__algorithm/fill_n.h>
-#include <__algorithm/transform.h>
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
#include <__config>
#include <__format/format_error.h>
-#include <__format/format_fwd.h>
-#include <__format/formatter.h>
+#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
+#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
-#include <array>
+#include <__utility/unreachable.h>
#include <charconv>
-#include <concepts>
#include <limits>
#include <string>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include <locale>
+# include <locale>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -40,97 +37,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+namespace __formatter {
-/**
- * Integral formatting classes.
- *
- * There are two types used here:
- * * C++-type, the type as used in C++.
- * * format-type, the output type specified in the std-format-spec.
- *
- * Design of the integral formatters consists of several layers.
- * * @ref __parser_integral The basic std-format-spec parser for all integral
- * classes. This parser does the basic sanity checks. It also contains some
- * helper functions that are nice to have available for all parsers.
- * * A C++-type specific parser. These parsers must derive from
- * @ref __parser_integral. Their task is to validate whether the parsed
- * std-format-spec is valid for the C++-type and selected format-type. After
- * validation they need to make sure all members are properly set. For
- * example, when the alignment hasn't changed it needs to set the proper
- * default alignment for the format-type. The following parsers are available:
- * - @ref __parser_integer
- * - @ref __parser_char
- * - @ref __parser_bool
- * * A general formatter for all integral types @ref __formatter_integral. This
- * formatter can handle all formatting of integers and characters. The class
- * derives from the proper formatter.
- * Note the boolean string format-type isn't supported in this class.
- * * A typedef C++-type group combining the @ref __formatter_integral with a
- * parser:
- * * @ref __formatter_integer
- * * @ref __formatter_char
- * * @ref __formatter_bool
- * * Then every C++-type has its own formatter specializations. They inherit
- * from the C++-type group typedef. Most specializations need nothing else.
- * Others need some additional specializations in this class.
- */
-namespace __format_spec {
-
-/** Wrapper around @ref to_chars, returning the output pointer. */
-template <integral _Tp>
-_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last,
- _Tp __value, int __base) {
- // TODO FMT Evaluate code overhead due to not calling the internal function
- // directly. (Should be zero overhead.)
- to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base);
- _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
- return __r.ptr;
-}
-
-/**
- * Helper to determine the buffer size to output a integer in Base @em x.
- *
- * There are several overloads for the supported bases. The function uses the
- * base as template argument so it can be used in a constant expression.
- */
-template <unsigned_integral _Tp, size_t _Base>
-_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
- requires(_Base == 2) {
- return numeric_limits<_Tp>::digits // The number of binary digits.
- + 2 // Reserve space for the '0[Bb]' prefix.
- + 1; // Reserve space for the sign.
-}
-
-template <unsigned_integral _Tp, size_t _Base>
-_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
- requires(_Base == 8) {
- return numeric_limits<_Tp>::digits // The number of binary digits.
- / 3 // Adjust to octal.
- + 1 // Turn floor to ceil.
- + 1 // Reserve space for the '0' prefix.
- + 1; // Reserve space for the sign.
-}
+//
+// Generic
+//
-template <unsigned_integral _Tp, size_t _Base>
-_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
- requires(_Base == 10) {
- return numeric_limits<_Tp>::digits10 // The floored value.
- + 1 // Turn floor to ceil.
- + 1; // Reserve space for the sign.
-}
+_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative, __format_spec::__sign __sign) {
+ if (__negative)
+ *__buf++ = '-';
+ else
+ switch (__sign) {
+ case __format_spec::__sign::__default:
+ case __format_spec::__sign::__minus:
+ // No sign added.
+ break;
+ case __format_spec::__sign::__plus:
+ *__buf++ = '+';
+ break;
+ case __format_spec::__sign::__space:
+ *__buf++ = ' ';
+ break;
+ }
-template <unsigned_integral _Tp, size_t _Base>
-_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
- requires(_Base == 16) {
- return numeric_limits<_Tp>::digits // The number of binary digits.
- / 4 // Adjust to hexadecimal.
- + 2 // Reserve space for the '0[Xx]' prefix.
- + 1; // Reserve space for the sign.
+ return __buf;
}
/**
@@ -148,8 +78,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept
* @note The grouping field of the locale is always a @c std::string,
* regardless whether the @c std::numpunct's type is @c char or @c wchar_t.
*/
-_LIBCPP_HIDE_FROM_ABI inline string
-__determine_grouping(ptrdiff_t __size, const string& __grouping) {
+_LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const string& __grouping) {
_LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0],
"The slow grouping formatting is used while there will be no "
"separators written");
@@ -176,283 +105,253 @@ __determine_grouping(ptrdiff_t __size, const string& __grouping) {
}
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
-template <class _Parser>
-requires __formatter::__char_type<typename _Parser::char_type>
-class _LIBCPP_TEMPLATE_VIS __formatter_integral : public _Parser {
-public:
- using _CharT = typename _Parser::char_type;
-
- template <integral _Tp>
- _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx)
- -> decltype(__ctx.out()) {
- if (this->__width_needs_substitution())
- this->__substitute_width_arg_id(__ctx.arg(this->__width));
-
- if (this->__type == _Flags::_Type::__char)
- return __format_as_char(__value, __ctx);
+//
+// Char
+//
- if constexpr (unsigned_integral<_Tp>)
- return __format_unsigned_integral(__value, false, __ctx);
- else {
- // Depending on the std-format-spec string the sign and the value
- // might not be outputted together:
- // - alternate form may insert a prefix string.
- // - zero-padding may insert additional '0' characters.
- // Therefore the value is processed as a positive unsigned value.
- // The function @ref __insert_sign will a '-' when the value was negative.
- auto __r = __to_unsigned_like(__value);
- bool __negative = __value < 0;
- if (__negative)
- __r = __complement(__r);
-
- return __format_unsigned_integral(__r, __negative, __ctx);
+template <__formatter::__char_type _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __format_char(
+ integral auto __value,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ using _Tp = decltype(__value);
+ if constexpr (!same_as<_CharT, _Tp>) {
+ // cmp_less and cmp_greater can't be used for character types.
+ if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) {
+ if (__value < numeric_limits<_CharT>::min() || __value > numeric_limits<_CharT>::max())
+ std::__throw_format_error("Integral value outside the range of the char type");
+ } else if constexpr (signed_integral<_CharT>) {
+ // _CharT is signed _Tp is unsigned
+ if (__value > static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max()))
+ std::__throw_format_error("Integral value outside the range of the char type");
+ } else {
+ // _CharT is unsigned _Tp is signed
+ if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) > numeric_limits<_CharT>::max())
+ std::__throw_format_error("Integral value outside the range of the char type");
}
}
-private:
- /** Generic formatting for format-type c. */
- _LIBCPP_HIDE_FROM_ABI auto __format_as_char(integral auto __value,
- auto& __ctx)
- -> decltype(__ctx.out()) {
- if (this->__alignment == _Flags::_Alignment::__default)
- this->__alignment = _Flags::_Alignment::__right;
-
- using _Tp = decltype(__value);
- if constexpr (!same_as<_CharT, _Tp>) {
- // cmp_less and cmp_greater can't be used for character types.
- if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) {
- if (__value < numeric_limits<_CharT>::min() ||
- __value > numeric_limits<_CharT>::max())
- __throw_format_error(
- "Integral value outside the range of the char type");
- } else if constexpr (signed_integral<_CharT>) {
- // _CharT is signed _Tp is unsigned
- if (__value >
- static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max()))
- __throw_format_error(
- "Integral value outside the range of the char type");
- } else {
- // _CharT is unsigned _Tp is signed
- if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) >
- numeric_limits<_CharT>::max())
- __throw_format_error(
- "Integral value outside the range of the char type");
- }
- }
+ const auto __c = static_cast<_CharT>(__value);
+ return __formatter::__write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, _VSTD::move(__out_it), __specs);
+}
- const auto __c = static_cast<_CharT>(__value);
- return __write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1,
- __ctx.out());
- }
+//
+// Integer
+//
- /**
- * Generic formatting for format-type bBdoxX.
- *
- * This small wrapper allocates a buffer with the required size. Then calls
- * the real formatter with the buffer and the prefix for the base.
- */
- _LIBCPP_HIDE_FROM_ABI auto
- __format_unsigned_integral(unsigned_integral auto __value, bool __negative,
- auto& __ctx) -> decltype(__ctx.out()) {
- switch (this->__type) {
- case _Flags::_Type::__binary_lower_case: {
- array<char, __buffer_size<decltype(__value), 2>()> __array;
- return __format_unsigned_integral(__array.begin(), __array.end(), __value,
- __negative, 2, __ctx, "0b");
- }
- case _Flags::_Type::__binary_upper_case: {
- array<char, __buffer_size<decltype(__value), 2>()> __array;
- return __format_unsigned_integral(__array.begin(), __array.end(), __value,
- __negative, 2, __ctx, "0B");
- }
- case _Flags::_Type::__octal: {
- // Octal is special; if __value == 0 there's no prefix.
- array<char, __buffer_size<decltype(__value), 8>()> __array;
- return __format_unsigned_integral(__array.begin(), __array.end(), __value,
- __negative, 8, __ctx,
- __value != 0 ? "0" : nullptr);
- }
- case _Flags::_Type::__decimal: {
- array<char, __buffer_size<decltype(__value), 10>()> __array;
- return __format_unsigned_integral(__array.begin(), __array.end(), __value,
- __negative, 10, __ctx, nullptr);
- }
- case _Flags::_Type::__hexadecimal_lower_case: {
- array<char, __buffer_size<decltype(__value), 16>()> __array;
- return __format_unsigned_integral(__array.begin(), __array.end(), __value,
- __negative, 16, __ctx, "0x");
- }
- case _Flags::_Type::__hexadecimal_upper_case: {
- array<char, __buffer_size<decltype(__value), 16>()> __array;
- return __format_unsigned_integral(__array.begin(), __array.end(), __value,
- __negative, 16, __ctx, "0X");
- }
- default:
- _LIBCPP_ASSERT(false, "The parser should have validated the type");
- _LIBCPP_UNREACHABLE();
- }
- }
+/** Wrapper around @ref to_chars, returning the output pointer. */
+template <integral _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, int __base) {
+ // TODO FMT Evaluate code overhead due to not calling the internal function
+ // directly. (Should be zero overhead.)
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
- template <class _Tp>
- requires(same_as<char, _Tp> || same_as<wchar_t, _Tp>) _LIBCPP_HIDE_FROM_ABI
- auto __write(const _Tp* __first, const _Tp* __last, auto __out_it)
- -> decltype(__out_it) {
+/**
+ * Helper to determine the buffer size to output a integer in Base @em x.
+ *
+ * There are several overloads for the supported bases. The function uses the
+ * base as template argument so it can be used in a constant expression.
+ */
+template <unsigned_integral _Tp, size_t _Base>
+consteval size_t __buffer_size() noexcept
+ requires(_Base == 2)
+{
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ + 2 // Reserve space for the '0[Bb]' prefix.
+ + 1; // Reserve space for the sign.
+}
- unsigned __size = __last - __first;
- if (this->__type != _Flags::_Type::__hexadecimal_upper_case) [[likely]] {
- if (__size >= this->__width)
- return _VSTD::copy(__first, __last, _VSTD::move(__out_it));
+template <unsigned_integral _Tp, size_t _Base>
+consteval size_t __buffer_size() noexcept
+ requires(_Base == 8)
+{
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ / 3 // Adjust to octal.
+ + 1 // Turn floor to ceil.
+ + 1 // Reserve space for the '0' prefix.
+ + 1; // Reserve space for the sign.
+}
- return __formatter::__write(_VSTD::move(__out_it), __first, __last,
- __size, this->__width, this->__fill,
- this->__alignment);
- }
+template <unsigned_integral _Tp, size_t _Base>
+consteval size_t __buffer_size() noexcept
+ requires(_Base == 10)
+{
+ return numeric_limits<_Tp>::digits10 // The floored value.
+ + 1 // Turn floor to ceil.
+ + 1; // Reserve space for the sign.
+}
+
+template <unsigned_integral _Tp, size_t _Base>
+consteval size_t __buffer_size() noexcept
+ requires(_Base == 16)
+{
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ / 4 // Adjust to hexadecimal.
+ + 2 // Reserve space for the '0[Xx]' prefix.
+ + 1; // Reserve space for the sign.
+}
- // this->__type == _Flags::_Type::__hexadecimal_upper_case
- // This means all characters in the range [a-f] need to be changed to their
- // uppercase representation. The transformation is done as transformation
- // in the output routine instead of before. This avoids another pass over
- // the data.
- // TODO FMT See whether it's possible to do this transformation during the
- // conversion. (This probably requires changing std::to_chars' alphabet.)
- if (__size >= this->__width)
- return _VSTD::transform(__first, __last, _VSTD::move(__out_it),
- __hex_to_upper);
-
- return __formatter::__write(_VSTD::move(__out_it), __first, __last, __size,
- __hex_to_upper, this->__width, this->__fill,
- this->__alignment);
+template <unsigned_integral _Tp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __format_integer(
+ _Tp __value,
+ auto& __ctx,
+ __format_spec::__parsed_specifications<_CharT> __specs,
+ bool __negative,
+ char* __begin,
+ char* __end,
+ const char* __prefix,
+ int __base) -> decltype(__ctx.out()) {
+ char* __first = __formatter::__insert_sign(__begin, __negative, __specs.__std_.__sign_);
+ if (__specs.__std_.__alternate_form_ && __prefix)
+ while (*__prefix)
+ *__first++ = *__prefix++;
+
+ char* __last = __formatter::__to_buffer(__first, __end, __value, __base);
+
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (__specs.__std_.__locale_specific_form_) {
+ const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
+ string __grouping = __np.grouping();
+ ptrdiff_t __size = __last - __first;
+ // Writing the grouped form has more overhead than the normal output
+ // routines. If there will be no separators written the locale-specific
+ // form is identical to the normal routine. Test whether to grouped form
+ // is required.
+ if (!__grouping.empty() && __size > __grouping[0])
+ return __formatter::__write_using_decimal_separators(
+ __ctx.out(),
+ __begin,
+ __first,
+ __last,
+ __formatter::__determine_grouping(__size, __grouping),
+ __np.thousands_sep(),
+ __specs);
+ }
+# endif
+ auto __out_it = __ctx.out();
+ if (__specs.__alignment_ != __format_spec::__alignment::__zero_padding)
+ __first = __begin;
+ else {
+ // __buf contains [sign][prefix]data
+ // ^ location of __first
+ // The zero padding is done like:
+ // - Write [sign][prefix]
+ // - Write data right aligned with '0' as fill character.
+ __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
+ __specs.__alignment_ = __format_spec::__alignment::__right;
+ __specs.__fill_ = _CharT('0');
+ int32_t __size = __first - __begin;
+
+ __specs.__width_ -= _VSTD::min(__size, __specs.__width_);
}
- _LIBCPP_HIDE_FROM_ABI auto
- __format_unsigned_integral(char* __begin, char* __end,
- unsigned_integral auto __value, bool __negative,
- int __base, auto& __ctx, const char* __prefix)
- -> decltype(__ctx.out()) {
- char* __first = __insert_sign(__begin, __negative, this->__sign);
- if (this->__alternate_form && __prefix)
- while (*__prefix)
- *__first++ = *__prefix++;
-
- char* __last = __to_buffer(__first, __end, __value, __base);
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
- if (this->__locale_specific_form) {
- const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
- string __grouping = __np.grouping();
- ptrdiff_t __size = __last - __first;
- // Writing the grouped form has more overhead than the normal output
- // routines. If there will be no separators written the locale-specific
- // form is identical to the normal routine. Test whether to grouped form
- // is required.
- if (!__grouping.empty() && __size > __grouping[0])
- return __format_grouping(__ctx.out(), __begin, __first, __last,
- __determine_grouping(__size, __grouping),
- __np.thousands_sep());
- }
-#endif
- auto __out_it = __ctx.out();
- if (this->__alignment != _Flags::_Alignment::__default)
- __first = __begin;
- else {
- // __buf contains [sign][prefix]data
- // ^ location of __first
- // The zero padding is done like:
- // - Write [sign][prefix]
- // - Write data right aligned with '0' as fill character.
- __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
- this->__alignment = _Flags::_Alignment::__right;
- this->__fill = _CharT('0');
- uint32_t __size = __first - __begin;
- this->__width -= _VSTD::min(__size, this->__width);
- }
+ if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]]
+ return __formatter::__write(__first, __last, __ctx.out(), __specs);
+
+ return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper);
+}
- return __write(__first, __last, _VSTD::move(__out_it));
+template <unsigned_integral _Tp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __format_integer(
+ _Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative = false)
+ -> decltype(__ctx.out()) {
+ switch (__specs.__std_.__type_) {
+ case __format_spec::__type::__binary_lower_case: {
+ array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array;
+ return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0b", 2);
+ }
+ case __format_spec::__type::__binary_upper_case: {
+ array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array;
+ return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0B", 2);
+ }
+ case __format_spec::__type::__octal: {
+ // Octal is special; if __value == 0 there's no prefix.
+ array<char, __formatter::__buffer_size<decltype(__value), 8>()> __array;
+ return __formatter::__format_integer(
+ __value, __ctx, __specs, __negative, __array.begin(), __array.end(), __value != 0 ? "0" : nullptr, 8);
+ }
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__decimal: {
+ array<char, __formatter::__buffer_size<decltype(__value), 10>()> __array;
+ return __formatter::__format_integer(
+ __value, __ctx, __specs, __negative, __array.begin(), __array.end(), nullptr, 10);
+ }
+ case __format_spec::__type::__hexadecimal_lower_case: {
+ array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array;
+ return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0x", 16);
+ }
+ case __format_spec::__type::__hexadecimal_upper_case: {
+ array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array;
+ return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0X", 16);
+ }
+ default:
+ _LIBCPP_ASSERT(false, "The parse function should have validated the type");
+ __libcpp_unreachable();
}
+}
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
- /** Format's the locale-specific form's groupings. */
- template <class _OutIt, class _CharT>
- _LIBCPP_HIDE_FROM_ABI _OutIt
- __format_grouping(_OutIt __out_it, const char* __begin, const char* __first,
- const char* __last, string&& __grouping, _CharT __sep) {
-
- // TODO FMT This function duplicates some functionality of the normal
- // output routines. Evaluate whether these parts can be efficiently
- // combined with the existing routines.
-
- unsigned __size = (__first - __begin) + // [sign][prefix]
- (__last - __first) + // data
- (__grouping.size() - 1); // number of separator characters
-
- __formatter::__padding_size_result __padding = {0, 0};
- if (this->__alignment == _Flags::_Alignment::__default) {
- // Write [sign][prefix].
- __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
-
- if (this->__width > __size) {
- // Write zero padding.
- __padding.__before = this->__width - __size;
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), this->__width - __size,
- _CharT('0'));
- }
- } else {
- if (this->__width > __size) {
- // Determine padding and write padding.
- __padding = __formatter::__padding_size(__size, this->__width,
- this->__alignment);
-
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before,
- this->__fill);
- }
- // Write [sign][prefix].
- __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
- }
+template <signed_integral _Tp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
+ -> decltype(__ctx.out()) {
+ // Depending on the std-format-spec string the sign and the value
+ // might not be outputted together:
+ // - alternate form may insert a prefix string.
+ // - zero-padding may insert additional '0' characters.
+ // Therefore the value is processed as a positive unsigned value.
+ // The function @ref __insert_sign will a '-' when the value was negative.
+ auto __r = std::__to_unsigned_like(__value);
+ bool __negative = __value < 0;
+ if (__negative)
+ __r = __complement(__r);
+
+ return __formatter::__format_integer(__r, __ctx, __specs, __negative);
+}
- auto __r = __grouping.rbegin();
- auto __e = __grouping.rend() - 1;
- _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while "
- "there will be no separators written.");
- // The output is divided in small groups of numbers to write:
- // - A group before the first separator.
- // - A separator and a group, repeated for the number of separators.
- // - A group after the last separator.
- // This loop achieves that process by testing the termination condition
- // midway in the loop.
- //
- // TODO FMT This loop evaluates the loop invariant `this->__type !=
- // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test
- // happens in the __write call.) Benchmark whether making two loops and
- // hoisting the invariant is worth the effort.
- while (true) {
- if (this->__type == _Flags::_Type::__hexadecimal_upper_case) {
- __last = __first + *__r;
- __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it),
- __hex_to_upper);
- __first = __last;
- } else {
- __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
- __first += *__r;
- }
-
- if (__r == __e)
- break;
-
- ++__r;
- *__out_it++ = __sep;
- }
+//
+// Formatter arithmetic (bool)
+//
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after,
- this->__fill);
- }
-#endif // _LIBCPP_HAS_NO_LOCALIZATION
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings;
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {
+ static constexpr string_view __true{"true"};
+ static constexpr string_view __false{"false"};
};
-} // namespace __format_spec
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {
+ static constexpr wstring_view __true{L"true"};
+ static constexpr wstring_view __false{L"false"};
+};
+# endif
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
+ -> decltype(__ctx.out()) {
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (__specs.__std_.__locale_specific_form_) {
+ const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
+ basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
+ return __formatter::__write_string_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
+ }
+# endif
+ basic_string_view<_CharT> __str =
+ __value ? __formatter::__bool_strings<_CharT>::__true : __formatter::__bool_strings<_CharT>::__false;
+ return __formatter::__write(__str.begin(), __str.end(), __ctx.out(), __specs);
+}
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+} // namespace __formatter
#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/formatter_output.h
@@ -0,0 +1,308 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
+#define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/transform.h>
+#include <__config>
+#include <__format/formatter.h>
+#include <__format/parser_std_format_spec.h>
+#include <__format/unicode.h>
+#include <__utility/move.h>
+#include <__utility/unreachable.h>
+#include <cstddef>
+#include <string>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __formatter {
+
+_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char __c) {
+ switch (__c) {
+ case 'a':
+ return 'A';
+ case 'b':
+ return 'B';
+ case 'c':
+ return 'C';
+ case 'd':
+ return 'D';
+ case 'e':
+ return 'E';
+ case 'f':
+ return 'F';
+ }
+ return __c;
+}
+
+struct _LIBCPP_TYPE_VIS __padding_size_result {
+ size_t __before_;
+ size_t __after_;
+};
+
+_LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result
+__padding_size(size_t __size, size_t __width, __format_spec::__alignment __align) {
+ _LIBCPP_ASSERT(__width > __size, "don't call this function when no padding is required");
+ _LIBCPP_ASSERT(
+ __align != __format_spec::__alignment::__zero_padding, "the caller should have handled the zero-padding");
+
+ size_t __fill = __width - __size;
+ switch (__align) {
+ case __format_spec::__alignment::__zero_padding:
+ __libcpp_unreachable();
+
+ case __format_spec::__alignment::__left:
+ return {0, __fill};
+
+ case __format_spec::__alignment::__center: {
+ // The extra padding is divided per [format.string.std]/3
+ // __before = floor(__fill, 2);
+ // __after = ceil(__fill, 2);
+ size_t __before = __fill / 2;
+ size_t __after = __fill - __before;
+ return {__before, __after};
+ }
+ case __format_spec::__alignment::__default:
+ case __format_spec::__alignment::__right:
+ return {__fill, 0};
+ }
+ __libcpp_unreachable();
+}
+
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first,
+ const char* __last, string&& __grouping, _CharT __sep,
+ __format_spec::__parsed_specifications<_CharT> __specs) {
+ int __size = (__first - __begin) + // [sign][prefix]
+ (__last - __first) + // data
+ (__grouping.size() - 1); // number of separator characters
+
+ __padding_size_result __padding = {0, 0};
+ if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) {
+ // Write [sign][prefix].
+ __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
+
+ if (__specs.__width_ > __size) {
+ // Write zero padding.
+ __padding.__before_ = __specs.__width_ - __size;
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0'));
+ }
+ } else {
+ if (__specs.__width_ > __size) {
+ // Determine padding and write padding.
+ __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_);
+
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ }
+ // Write [sign][prefix].
+ __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
+ }
+
+ auto __r = __grouping.rbegin();
+ auto __e = __grouping.rend() - 1;
+ _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while "
+ "there will be no separators written.");
+ // The output is divided in small groups of numbers to write:
+ // - A group before the first separator.
+ // - A separator and a group, repeated for the number of separators.
+ // - A group after the last separator.
+ // This loop achieves that process by testing the termination condition
+ // midway in the loop.
+ //
+ // TODO FMT This loop evaluates the loop invariant `__parser.__type !=
+ // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test
+ // happens in the __write call.) Benchmark whether making two loops and
+ // hoisting the invariant is worth the effort.
+ while (true) {
+ if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) {
+ __last = __first + *__r;
+ __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper);
+ __first = __last;
+ } else {
+ __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
+ __first += *__r;
+ }
+
+ if (__r == __e)
+ break;
+
+ ++__r;
+ *__out_it++ = __sep;
+ }
+
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+/// Writes the input to the output with the required padding.
+///
+/// Since the output column width is specified the function can be used for
+/// ASCII and Unicode output.
+///
+/// \pre [\a __first, \a __last) is a valid range.
+/// \pre \a __size <= \a __width. Using this function when this pre-condition
+/// doesn't hold incurs an unwanted overhead.
+///
+/// \param __first Pointer to the first element to write.
+/// \param __last Pointer beyond the last element to write.
+/// \param __out_it The output iterator to write to.
+/// \param __specs The parsed formatting specifications.
+/// \param __size The (estimated) output column width. When the elements
+/// to be written are ASCII the following condition holds
+/// \a __size == \a __last - \a __first.
+///
+/// \returns An iterator pointing beyond the last element written.
+///
+/// \note The type of the elements in range [\a __first, \a __last) can differ
+/// from the type of \a __specs. Integer output uses \c std::to_chars for its
+/// conversion, which means the [\a __first, \a __last) always contains elements
+/// of the type \c char.
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto __write(
+ const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ ptrdiff_t __size) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+
+ if (__size >= __specs.__width_)
+ return _VSTD::copy(__first, __last, _VSTD::move(__out_it));
+
+ __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__std_.__alignment_);
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it));
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+/// \overload
+///
+/// Calls the function above where \a __size = \a __last - \a __first.
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto __write(const _CharT* __first, const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
+ return __write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first);
+}
+
+template <class _CharT, class _ParserCharT, class _UnaryOperation>
+_LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ _UnaryOperation __op) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+
+ ptrdiff_t __size = __last - __first;
+ if (__size >= __specs.__width_)
+ return _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
+
+ __padding_size_result __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_);
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+/// Writes additional zero's for the precision before the exponent.
+/// This is used when the precision requested in the format string is larger
+/// than the maximum precision of the floating-point type. These precision
+/// digits are always 0.
+///
+/// \param __exponent The location of the exponent character.
+/// \param __num_trailing_zeros The number of 0's to write before the exponent
+/// character.
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
+ const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ size_t __size,
+ const _CharT* __exponent,
+ size_t __num_trailing_zeros) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");
+
+ __padding_size_result __padding =
+ __padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_);
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it));
+ __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
+ __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it));
+ return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+/// Writes a string using format's width estimation algorithm.
+///
+/// \pre !__specs.__has_precision()
+///
+/// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the
+/// input is ASCII.
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
+ basic_string_view<_CharT> __str,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(!__specs.__has_precision(), "use __write_string");
+
+ // No padding -> copy the string
+ if (!__specs.__has_width())
+ return _VSTD::copy(__str.begin(), __str.end(), _VSTD::move(__out_it));
+
+ // Note when the estimated width is larger than size there's no padding. So
+ // there's no reason to get the real size when the estimate is larger than or
+ // equal to the minimum field width.
+ size_t __size =
+ __format_spec::__estimate_column_width(__str, __specs.__width_, __format_spec::__column_width_rounding::__up)
+ .__width_;
+
+ return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI int __truncate(basic_string_view<_CharT>& __str, int __precision) {
+ __format_spec::__column_width_result<_CharT> __result =
+ __format_spec::__estimate_column_width(__str, __precision, __format_spec::__column_width_rounding::__down);
+ __str = basic_string_view<_CharT>{__str.begin(), __result.__last_};
+ return __result.__width_;
+}
+
+/// Writes a string using format's width estimation algorithm.
+///
+/// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the
+/// input is ASCII.
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __write_string(
+ basic_string_view<_CharT> __str,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ if (!__specs.__has_precision())
+ return __formatter::__write_string_no_precision(__str, _VSTD::move(__out_it), __specs);
+
+ int __size = __formatter::__truncate(__str, __specs.__precision_);
+
+ return __write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
+}
+
+} // namespace __formatter
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
lib/libcxx/include/__format/formatter_pointer.h
@@ -10,17 +10,15 @@
#ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H
#define _LIBCPP___FORMAT_FORMATTER_POINTER_H
-#include <__algorithm/copy.h>
#include <__availability>
#include <__config>
-#include <__debug>
-#include <__format/format_error.h>
#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
+#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
-#include <__iterator/access.h>
-#include <__nullptr>
+#include <cstddef>
#include <cstdint>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -31,41 +29,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-namespace __format_spec {
-
template <__formatter::__char_type _CharT>
-class _LIBCPP_TEMPLATE_VIS __formatter_pointer : public __parser_pointer<_CharT> {
+struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {
public:
- _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) -> decltype(__ctx.out()) {
- _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default,
- "The call to parse should have updated the alignment");
- if (this->__width_needs_substitution())
- this->__substitute_width_arg_id(__ctx.arg(this->__width));
+ constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; }
- // This code looks a lot like the code to format a hexadecimal integral,
- // but that code isn't public. Making that code public requires some
- // refactoring.
- // TODO FMT Remove code duplication.
- char __buffer[2 + 2 * sizeof(uintptr_t)];
- __buffer[0] = '0';
- __buffer[1] = 'x';
- char* __last = __to_buffer(__buffer + 2, _VSTD::end(__buffer), reinterpret_cast<uintptr_t>(__ptr), 16);
-
- unsigned __size = __last - __buffer;
- if (__size >= this->__width)
- return _VSTD::copy(__buffer, __last, __ctx.out());
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_pointer);
+ __format_spec::__process_display_type_pointer(__parser_.__type_);
+ return __result;
+ }
- return __formatter::__write(__ctx.out(), __buffer, __last, __size, this->__width, this->__fill, this->__alignment);
+ _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) const -> decltype(__ctx.out()) {
+ __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
+ __specs.__std_.__alternate_form_ = true;
+ __specs.__std_.__type_ = __format_spec::__type::__hexadecimal_lower_case;
+ return __formatter::__format_integer(reinterpret_cast<uintptr_t>(__ptr), __ctx, __specs);
}
-};
-} // namespace __format_spec
+ __format_spec::__parser<_CharT> __parser_;
+};
// [format.formatter.spec]/2.4
// For each charT, the pointer type specializations template<>
@@ -74,15 +58,13 @@ public:
// - template<> struct formatter<const void*, charT>;
template <__formatter::__char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>
- : public __format_spec::__formatter_pointer<_CharT> {};
+ : public __formatter_pointer<_CharT> {};
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT>
- : public __format_spec::__formatter_pointer<_CharT> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> {
+};
template <__formatter::__char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>
- : public __format_spec::__formatter_pointer<_CharT> {};
-
-# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+ : public __formatter_pointer<_CharT> {};
#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/formatter_string.h
@@ -10,68 +10,49 @@
#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H
#define _LIBCPP___FORMAT_FORMATTER_STRING_H
+#include <__availability>
#include <__config>
-#include <__format/format_error.h>
#include <__format/format_fwd.h>
-#include <__format/format_string.h>
+#include <__format/format_parse_context.h>
#include <__format/formatter.h>
+#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
+#include <__utility/move.h>
+#include <string>
#include <string_view>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-namespace __format_spec {
-
template <__formatter::__char_type _CharT>
-class _LIBCPP_TEMPLATE_VIS __formatter_string : public __parser_string<_CharT> {
+struct _LIBCPP_TEMPLATE_VIS __formatter_string {
public:
- _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str,
- auto& __ctx) -> decltype(__ctx.out()) {
-
- _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default,
- "The parser should not use these defaults");
-
- if (this->__width_needs_substitution())
- this->__substitute_width_arg_id(__ctx.arg(this->__width));
-
- if (this->__precision_needs_substitution())
- this->__substitute_precision_arg_id(__ctx.arg(this->__precision));
-
- return __formatter::__write_unicode(
- __ctx.out(), __str, this->__width,
- this->__has_precision_field() ? this->__precision : -1, this->__fill,
- this->__alignment);
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_string);
+ __format_spec::__process_display_type_string(__parser_.__type_);
+ return __result;
}
-};
-} //namespace __format_spec
+ _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) {
+ return __formatter::__write_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+ }
-// [format.formatter.spec]/2.2 For each charT, the string type specializations
+ __format_spec::__parser<_CharT> __parser_;
+};
// Formatter const char*.
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<const _CharT*, _CharT>
- : public __format_spec::__formatter_string<_CharT> {
- using _Base = __format_spec::__formatter_string<_CharT>;
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
- _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx)
- -> decltype(__ctx.out()) {
+ _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) {
_LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "
"prevented an invalid pointer.");
@@ -86,8 +67,9 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
// now these optimizations aren't implemented. Instead the base class
// handles these options.
// TODO FMT Implement these improvements.
- if (this->__has_width_field() || this->__has_precision_field())
- return _Base::format(__str, __ctx);
+ __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);
+ if (__specs.__has_width() || __specs.__has_precision())
+ return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
// No formatting required, copy the string to the output.
auto __out_it = __ctx.out();
@@ -99,40 +81,46 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
// Formatter char*.
template <__formatter::__char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> {
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT>
+ : public formatter<const _CharT*, _CharT> {
using _Base = formatter<const _CharT*, _CharT>;
- _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx)
- -> decltype(__ctx.out()) {
+ _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) {
return _Base::format(__str, __ctx);
}
};
+// Formatter char[].
+template <__formatter::__char_type _CharT, size_t _Size>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(_CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) {
+ return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);
+ }
+};
+
// Formatter const char[].
template <__formatter::__char_type _CharT, size_t _Size>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<const _CharT[_Size], _CharT>
- : public __format_spec::__formatter_string<_CharT> {
- using _Base = __format_spec::__formatter_string<_CharT>;
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
- _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx)
- -> decltype(__ctx.out()) {
+ _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) {
return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);
}
};
// Formatter std::string.
template <__formatter::__char_type _CharT, class _Traits, class _Allocator>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
- formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
- : public __format_spec::__formatter_string<_CharT> {
- using _Base = __format_spec::__formatter_string<_CharT>;
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
- _LIBCPP_HIDE_FROM_ABI auto
- format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx)
+ _LIBCPP_HIDE_FROM_ABI auto format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) const
-> decltype(__ctx.out()) {
- // drop _Traits and _Allocator
+ // Drop _Traits and _Allocator to have one std::basic_string formatter.
return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);
}
};
@@ -140,23 +128,18 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
// Formatter std::string_view.
template <__formatter::__char_type _CharT, class _Traits>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>
- : public __format_spec::__formatter_string<_CharT> {
- using _Base = __format_spec::__formatter_string<_CharT>;
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
- _LIBCPP_HIDE_FROM_ABI auto
- format(basic_string_view<_CharT, _Traits> __str, auto& __ctx)
+ _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) const
-> decltype(__ctx.out()) {
- // drop _Traits
+ // Drop _Traits to have one std::basic_string_view formatter.
return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);
}
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP___FORMAT_FORMATTER_STRING_H
lib/libcxx/include/__format/parser_std_format_spec.h
@@ -10,21 +10,31 @@
#ifndef _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
#define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
+/// \file Contains the std-format-spec parser.
+///
+/// Most of the code can be reused in the chrono-format-spec.
+/// This header has some support for the chrono-format-spec since it doesn't
+/// affect the std-format-spec.
+
#include <__algorithm/find_if.h>
#include <__algorithm/min.h>
+#include <__assert>
#include <__config>
#include <__debug>
#include <__format/format_arg.h>
#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
#include <__format/format_string.h>
+#include <__format/unicode.h>
#include <__variant/monostate.h>
#include <bit>
#include <concepts>
#include <cstdint>
+#include <string_view>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -34,174 +44,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
namespace __format_spec {
-/**
- * Contains the flags for the std-format-spec.
- *
- * Some format-options can only be used for specific C++types and may depend on
- * the selected format-type.
- * * The C++type filtering can be done using the proper policies for
- * @ref __parser_std.
- * * The format-type filtering needs to be done post parsing in the parser
- * derived from @ref __parser_std.
- */
-class _LIBCPP_TYPE_VIS _Flags {
-public:
- enum class _LIBCPP_ENUM_VIS _Alignment : uint8_t {
- /**
- * No alignment is set in the format string.
- *
- * Zero-padding is ignored when an alignment is selected.
- * The default alignment depends on the selected format-type.
- */
- __default,
- __left,
- __center,
- __right
- };
- enum class _LIBCPP_ENUM_VIS _Sign : uint8_t {
- /**
- * No sign is set in the format string.
- *
- * The sign isn't allowed for certain format-types. By using this value
- * it's possible to detect whether or not the user explicitly set the sign
- * flag. For formatting purposes it behaves the same as @ref __minus.
- */
- __default,
- __minus,
- __plus,
- __space
- };
-
- _Alignment __alignment : 2 {_Alignment::__default};
- _Sign __sign : 2 {_Sign::__default};
- uint8_t __alternate_form : 1 {false};
- uint8_t __zero_padding : 1 {false};
- uint8_t __locale_specific_form : 1 {false};
-
- enum class _LIBCPP_ENUM_VIS _Type : uint8_t {
- __default,
- __string,
- __binary_lower_case,
- __binary_upper_case,
- __octal,
- __decimal,
- __hexadecimal_lower_case,
- __hexadecimal_upper_case,
- __pointer,
- __char,
- __float_hexadecimal_lower_case,
- __float_hexadecimal_upper_case,
- __scientific_lower_case,
- __scientific_upper_case,
- __fixed_lower_case,
- __fixed_upper_case,
- __general_lower_case,
- __general_upper_case
- };
-
- _Type __type{_Type::__default};
-};
-
-namespace __detail {
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr bool
-__parse_alignment(_CharT __c, _Flags& __flags) noexcept {
- switch (__c) {
- case _CharT('<'):
- __flags.__alignment = _Flags::_Alignment::__left;
- return true;
-
- case _CharT('^'):
- __flags.__alignment = _Flags::_Alignment::__center;
- return true;
-
- case _CharT('>'):
- __flags.__alignment = _Flags::_Alignment::__right;
- return true;
- }
- return false;
-}
-} // namespace __detail
-
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_fill_align {
-public:
- // TODO FMT The standard doesn't specify this character is a Unicode
- // character. Validate what fmt and MSVC have implemented.
- _CharT __fill{_CharT(' ')};
-
-protected:
- _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
- __parse(const _CharT* __begin, const _CharT* __end, _Flags& __flags) {
- _LIBCPP_ASSERT(__begin != __end,
- "When called with an empty input the function will cause "
- "undefined behavior by evaluating data not in the input");
- if (__begin + 1 != __end) {
- if (__detail::__parse_alignment(*(__begin + 1), __flags)) {
- if (*__begin == _CharT('{') || *__begin == _CharT('}'))
- __throw_format_error(
- "The format-spec fill field contains an invalid character");
- __fill = *__begin;
- return __begin + 2;
- }
- }
-
- if (__detail::__parse_alignment(*__begin, __flags))
- return __begin + 1;
-
- return __begin;
- }
-};
-
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
-__parse_sign(const _CharT* __begin, _Flags& __flags) noexcept {
- switch (*__begin) {
- case _CharT('-'):
- __flags.__sign = _Flags::_Sign::__minus;
- break;
- case _CharT('+'):
- __flags.__sign = _Flags::_Sign::__plus;
- break;
- case _CharT(' '):
- __flags.__sign = _Flags::_Sign::__space;
- break;
- default:
- return __begin;
- }
- return __begin + 1;
-}
-
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
-__parse_alternate_form(const _CharT* __begin, _Flags& __flags) noexcept {
- if (*__begin == _CharT('#')) {
- __flags.__alternate_form = true;
- ++__begin;
- }
-
- return __begin;
-}
-
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
-__parse_zero_padding(const _CharT* __begin, _Flags& __flags) noexcept {
- if (*__begin == _CharT('0')) {
- __flags.__zero_padding = true;
- ++__begin;
- }
-
- return __begin;
-}
-
template <class _CharT>
_LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result< _CharT>
__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
@@ -222,7 +66,7 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
template <class _Context>
_LIBCPP_HIDE_FROM_ABI constexpr uint32_t
-__substitute_arg_id(basic_format_arg<_Context> __arg) {
+__substitute_arg_id(basic_format_arg<_Context> __format_arg) {
return visit_format_arg(
[](auto __arg) -> uint32_t {
using _Type = decltype(__arg);
@@ -246,803 +90,638 @@ __substitute_arg_id(basic_format_arg<_Context> __arg) {
__throw_format_error("A format-spec arg-id replacement argument "
"isn't an integral type");
},
- __arg);
+ __format_arg);
}
-class _LIBCPP_TYPE_VIS __parser_width {
-public:
- /** Contains a width or an arg-id. */
- uint32_t __width : 31 {0};
- /** Determines whether the value stored is a width or an arg-id. */
- uint32_t __width_as_arg : 1 {0};
-
-protected:
- /**
- * Does the supplied std-format-spec contain a width field?
- *
- * When the field isn't present there's no padding required. This can be used
- * to optimize the formatting.
- */
- constexpr bool __has_width_field() const noexcept {
- return __width_as_arg || __width;
- }
-
- /**
- * Does the supplied width field contain an arg-id?
- *
- * If @c true the formatter needs to call @ref __substitute_width_arg_id.
- */
- constexpr bool __width_needs_substitution() const noexcept {
- return __width_as_arg;
- }
-
- template <class _CharT>
- _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
- __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
- if (*__begin == _CharT('0'))
- __throw_format_error(
- "A format-spec width field shouldn't have a leading zero");
-
- if (*__begin == _CharT('{')) {
- __format::__parse_number_result __r =
- __parse_arg_id(++__begin, __end, __parse_ctx);
- __width = __r.__value;
- __width_as_arg = 1;
- return __r.__ptr;
- }
+/// These fields are a filter for which elements to parse.
+///
+/// They default to false so when a new field is added it needs to be opted in
+/// explicitly.
+struct __fields {
+ uint8_t __sign_ : 1 {false};
+ uint8_t __alternate_form_ : 1 {false};
+ uint8_t __zero_padding_ : 1 {false};
+ uint8_t __precision_ : 1 {false};
+ uint8_t __locale_specific_form_ : 1 {false};
+ uint8_t __type_ : 1 {false};
+};
- if (*__begin < _CharT('0') || *__begin > _CharT('9'))
- return __begin;
+// By not placing this constant in the formatter class it's not duplicated for
+// char and wchar_t.
+inline constexpr __fields __fields_integral{
+ .__sign_ = true,
+ .__alternate_form_ = true,
+ .__zero_padding_ = true,
+ .__locale_specific_form_ = true,
+ .__type_ = true};
+inline constexpr __fields __fields_floating_point{
+ .__sign_ = true,
+ .__alternate_form_ = true,
+ .__zero_padding_ = true,
+ .__precision_ = true,
+ .__locale_specific_form_ = true,
+ .__type_ = true};
+inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true};
+inline constexpr __fields __fields_pointer{.__type_ = true};
+
+enum class _LIBCPP_ENUM_VIS __alignment : uint8_t {
+ /// No alignment is set in the format string.
+ __default,
+ __left,
+ __center,
+ __right,
+ __zero_padding
+};
- __format::__parse_number_result __r =
- __format::__parse_number(__begin, __end);
- __width = __r.__value;
- _LIBCPP_ASSERT(__width != 0,
- "A zero value isn't allowed and should be impossible, "
- "due to validations in this function");
- return __r.__ptr;
- }
+enum class _LIBCPP_ENUM_VIS __sign : uint8_t {
+ /// No sign is set in the format string.
+ ///
+ /// The sign isn't allowed for certain format-types. By using this value
+ /// it's possible to detect whether or not the user explicitly set the sign
+ /// flag. For formatting purposes it behaves the same as \ref __minus.
+ __default,
+ __minus,
+ __plus,
+ __space
+};
- _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_width_arg_id(auto __arg) {
- _LIBCPP_ASSERT(__width_as_arg == 1,
- "Substitute width called when no substitution is required");
-
- // The clearing of the flag isn't required but looks better when debugging
- // the code.
- __width_as_arg = 0;
- __width = __substitute_arg_id(__arg);
- if (__width == 0)
- __throw_format_error(
- "A format-spec width field replacement should have a positive value");
- }
+enum class _LIBCPP_ENUM_VIS __type : uint8_t {
+ __default,
+ __string,
+ __binary_lower_case,
+ __binary_upper_case,
+ __octal,
+ __decimal,
+ __hexadecimal_lower_case,
+ __hexadecimal_upper_case,
+ __pointer,
+ __char,
+ __hexfloat_lower_case,
+ __hexfloat_upper_case,
+ __scientific_lower_case,
+ __scientific_upper_case,
+ __fixed_lower_case,
+ __fixed_upper_case,
+ __general_lower_case,
+ __general_upper_case
};
-class _LIBCPP_TYPE_VIS __parser_precision {
-public:
- /** Contains a precision or an arg-id. */
- uint32_t __precision : 31 {__format::__number_max};
- /**
- * Determines whether the value stored is a precision or an arg-id.
- *
- * @note Since @ref __precision == @ref __format::__number_max is a valid
- * value, the default value contains an arg-id of INT32_MAX. (This number of
- * arguments isn't supported by compilers.) This is used to detect whether
- * the std-format-spec contains a precision field.
- */
- uint32_t __precision_as_arg : 1 {1};
-
-protected:
- /**
- * Does the supplied std-format-spec contain a precision field?
- *
- * When the field isn't present there's no truncating required. This can be
- * used to optimize the formatting.
- */
- constexpr bool __has_precision_field() const noexcept {
-
- return __precision_as_arg == 0 || // Contains a value?
- __precision != __format::__number_max; // The arg-id is valid?
- }
+struct __std {
+ __alignment __alignment_ : 3;
+ __sign __sign_ : 2;
+ bool __alternate_form_ : 1;
+ bool __locale_specific_form_ : 1;
+ __type __type_;
+};
- /**
- * Does the supplied precision field contain an arg-id?
- *
- * If @c true the formatter needs to call @ref __substitute_precision_arg_id.
- */
- constexpr bool __precision_needs_substitution() const noexcept {
- return __precision_as_arg && __precision != __format::__number_max;
- }
+struct __chrono {
+ __alignment __alignment_ : 3;
+ bool __weekday_name_ : 1;
+ bool __month_name_ : 1;
+};
- template <class _CharT>
- _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
- __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
- if (*__begin != _CharT('.'))
- return __begin;
+/// Contains the parsed formatting specifications.
+///
+/// This contains information for both the std-format-spec and the
+/// chrono-format-spec. This results in some unused members for both
+/// specifications. However these unused members don't increase the size
+/// of the structure.
+///
+/// This struct doesn't cross ABI boundaries so its layout doesn't need to be
+/// kept stable.
+template <class _CharT>
+struct __parsed_specifications {
+ union {
+ // The field __alignment_ is the first element in __std_ and __chrono_.
+ // This allows the code to always inspect this value regards which member
+ // of the union is the active member [class.union.general]/2.
+ //
+ // This is needed since the generic output routines handle the alignment of
+ // the output.
+ __alignment __alignment_ : 3;
+ __std __std_;
+ __chrono __chrono_;
+ };
- ++__begin;
- if (__begin == __end)
- __throw_format_error("End of input while parsing format-spec precision");
+ /// The requested width.
+ ///
+ /// When the format-spec used an arg-id for this field it has already been
+ /// replaced with the value of that arg-id.
+ int32_t __width_;
- if (*__begin == _CharT('{')) {
- __format::__parse_number_result __arg_id =
- __parse_arg_id(++__begin, __end, __parse_ctx);
- _LIBCPP_ASSERT(__arg_id.__value != __format::__number_max,
- "Unsupported number of arguments, since this number of "
- "arguments is used a special value");
- __precision = __arg_id.__value;
- return __arg_id.__ptr;
- }
+ /// The requested precision.
+ ///
+ /// When the format-spec used an arg-id for this field it has already been
+ /// replaced with the value of that arg-id.
+ int32_t __precision_;
- if (*__begin < _CharT('0') || *__begin > _CharT('9'))
- __throw_format_error(
- "The format-spec precision field doesn't contain a value or arg-id");
-
- __format::__parse_number_result __r =
- __format::__parse_number(__begin, __end);
- __precision = __r.__value;
- __precision_as_arg = 0;
- return __r.__ptr;
- }
+ _CharT __fill_;
- _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_precision_arg_id(
- auto __arg) {
- _LIBCPP_ASSERT(
- __precision_as_arg == 1 && __precision != __format::__number_max,
- "Substitute precision called when no substitution is required");
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_width() const { return __width_ > 0; }
- // The clearing of the flag isn't required but looks better when debugging
- // the code.
- __precision_as_arg = 0;
- __precision = __substitute_arg_id(__arg);
- }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_precision() const { return __precision_ >= 0; }
};
+// Validate the struct is small and cheap to copy since the struct is passed by
+// value in formatting functions.
+static_assert(sizeof(__parsed_specifications<char>) == 16);
+static_assert(is_trivially_copyable_v<__parsed_specifications<char>>);
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static_assert(sizeof(__parsed_specifications<wchar_t>) == 16);
+static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>);
+# endif
+
+/// The parser for the std-format-spec.
+///
+/// Note this class is a member of std::formatter specializations. It's
+/// expected developers will create their own formatter specializations that
+/// inherit from the std::formatter specializations. This means this class
+/// must be ABI stable. To aid the stability the unused bits in the class are
+/// set to zero. That way they can be repurposed if a future revision of the
+/// Standards adds new fields to std-format-spec.
template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
-__parse_locale_specific_form(const _CharT* __begin, _Flags& __flags) noexcept {
- if (*__begin == _CharT('L')) {
- __flags.__locale_specific_form = true;
- ++__begin;
- }
-
- return __begin;
-}
-
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
-__parse_type(const _CharT* __begin, _Flags& __flags) {
-
- // Determines the type. It does not validate whether the selected type is
- // valid. Most formatters have optional fields that are only allowed for
- // certain types. These parsers need to do validation after the type has
- // been parsed. So its easier to implement the validation for all types in
- // the specific parse function.
- switch (*__begin) {
- case 'A':
- __flags.__type = _Flags::_Type::__float_hexadecimal_upper_case;
- break;
- case 'B':
- __flags.__type = _Flags::_Type::__binary_upper_case;
- break;
- case 'E':
- __flags.__type = _Flags::_Type::__scientific_upper_case;
- break;
- case 'F':
- __flags.__type = _Flags::_Type::__fixed_upper_case;
- break;
- case 'G':
- __flags.__type = _Flags::_Type::__general_upper_case;
- break;
- case 'X':
- __flags.__type = _Flags::_Type::__hexadecimal_upper_case;
- break;
- case 'a':
- __flags.__type = _Flags::_Type::__float_hexadecimal_lower_case;
- break;
- case 'b':
- __flags.__type = _Flags::_Type::__binary_lower_case;
- break;
- case 'c':
- __flags.__type = _Flags::_Type::__char;
- break;
- case 'd':
- __flags.__type = _Flags::_Type::__decimal;
- break;
- case 'e':
- __flags.__type = _Flags::_Type::__scientific_lower_case;
- break;
- case 'f':
- __flags.__type = _Flags::_Type::__fixed_lower_case;
- break;
- case 'g':
- __flags.__type = _Flags::_Type::__general_lower_case;
- break;
- case 'o':
- __flags.__type = _Flags::_Type::__octal;
- break;
- case 'p':
- __flags.__type = _Flags::_Type::__pointer;
- break;
- case 's':
- __flags.__type = _Flags::_Type::__string;
- break;
- case 'x':
- __flags.__type = _Flags::_Type::__hexadecimal_lower_case;
- break;
- default:
- return __begin;
- }
- return ++__begin;
-}
-
-/**
- * Process the parsed alignment and zero-padding state of arithmetic types.
- *
- * [format.string.std]/13
- * If the 0 character and an align option both appear, the 0 character is
- * ignored.
- *
- * For the formatter a @ref __default alignment means zero-padding.
- */
-_LIBCPP_HIDE_FROM_ABI constexpr void __process_arithmetic_alignment(_Flags& __flags) {
- __flags.__zero_padding &= __flags.__alignment == _Flags::_Alignment::__default;
- if (!__flags.__zero_padding && __flags.__alignment == _Flags::_Alignment::__default)
- __flags.__alignment = _Flags::_Alignment::__right;
-}
-
-/**
- * The parser for the std-format-spec.
- *
- * [format.string.std]/1 specifies the std-format-spec:
- * fill-and-align sign # 0 width precision L type
- *
- * All these fields are optional. Whether these fields can be used depend on:
- * - The type supplied to the format string.
- * E.g. A string never uses the sign field so the field may not be set.
- * This constrain is validated by the parsers in this file.
- * - The supplied value for the optional type field.
- * E.g. A int formatted as decimal uses the sign field.
- * When formatted as a char the sign field may no longer be set.
- * This constrain isn't validated by the parsers in this file.
- *
- * The base classes are ordered to minimize the amount of padding.
- *
- * This implements the parser for the string types.
- */
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_string
- : public __parser_width, // provides __width(|as_arg)
- public __parser_precision, // provides __precision(|as_arg)
- public __parser_fill_align<_CharT>, // provides __fill and uses __flags
- public _Flags // provides __flags
-{
+class _LIBCPP_TEMPLATE_VIS __parser {
public:
- using char_type = _CharT;
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields)
+ -> decltype(__parse_ctx.begin()) {
- _LIBCPP_HIDE_FROM_ABI constexpr __parser_string() {
- this->__alignment = _Flags::_Alignment::__left;
- }
+ const _CharT* __begin = __parse_ctx.begin();
+ const _CharT* __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
- /**
- * The low-level std-format-spec parse function.
- *
- * @pre __begin points at the beginning of the std-format-spec. This means
- * directly after the ':'.
- * @pre The std-format-spec parses the entire input, or the first unmatched
- * character is a '}'.
- *
- * @returns The iterator pointing at the last parsed character.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
- -> decltype(__parse_ctx.begin()) {
- auto __it = __parse(__parse_ctx);
- __process_display_type();
- return __it;
- }
+ if (__parse_fill_align(__begin, __end) && __begin == __end)
+ return __begin;
-private:
- /**
- * Parses the std-format-spec.
- *
- * @throws __throw_format_error When @a __parse_ctx contains an ill-formed
- * std-format-spec.
- *
- * @returns An iterator to the end of input or point at the closing '}'.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
- -> decltype(__parse_ctx.begin()) {
+ if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end)
+ return __begin;
- auto __begin = __parse_ctx.begin();
- auto __end = __parse_ctx.end();
- if (__begin == __end)
+ if (__fields.__alternate_form_ && __parse_alternate_form(__begin) && __begin == __end)
return __begin;
- __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,
- static_cast<_Flags&>(*this));
- if (__begin == __end)
+ if (__fields.__zero_padding_ && __parse_zero_padding(__begin) && __begin == __end)
return __begin;
- __begin = __parser_width::__parse(__begin, __end, __parse_ctx);
- if (__begin == __end)
+ if (__parse_width(__begin, __end, __parse_ctx) && __begin == __end)
return __begin;
- __begin = __parser_precision::__parse(__begin, __end, __parse_ctx);
- if (__begin == __end)
+ if (__fields.__precision_ && __parse_precision(__begin, __end, __parse_ctx) && __begin == __end)
+ return __begin;
+
+ if (__fields.__locale_specific_form_ && __parse_locale_specific_form(__begin) && __begin == __end)
return __begin;
- __begin = __parse_type(__begin, static_cast<_Flags&>(*this));
+ if (__fields.__type_) {
+ __parse_type(__begin);
- if (__begin != __end && *__begin != _CharT('}'))
- __throw_format_error(
- "The format-spec should consume the input or end with a '}'");
+ // When __type_ is false the calling parser is expected to do additional
+ // parsing. In that case that parser should do the end of format string
+ // validation.
+ if (__begin != __end && *__begin != _CharT('}'))
+ __throw_format_error("The format-spec should consume the input or end with a '}'");
+ }
return __begin;
}
- /** Processes the parsed std-format-spec based on the parsed display type. */
- _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {
- switch (this->__type) {
- case _Flags::_Type::__default:
- case _Flags::_Type::__string:
- break;
+ /// \returns the `__parsed_specifications` with the resolved dynamic sizes..
+ _LIBCPP_HIDE_FROM_ABI
+ __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const {
+ return __parsed_specifications<_CharT>{
+ .__std_ =
+ __std{.__alignment_ = __alignment_,
+ .__sign_ = __sign_,
+ .__alternate_form_ = __alternate_form_,
+ .__locale_specific_form_ = __locale_specific_form_,
+ .__type_ = __type_},
+ .__width_{__get_width(__ctx)},
+ .__precision_{__get_precision(__ctx)},
+ .__fill_{__fill_}};
+ }
+
+ __alignment __alignment_ : 3 {__alignment::__default};
+ __sign __sign_ : 2 {__sign::__default};
+ bool __alternate_form_ : 1 {false};
+ bool __locale_specific_form_ : 1 {false};
+ bool __reserved_0_ : 1 {false};
+ __type __type_{__type::__default};
+
+ // These two flags are used for formatting chrono. Since the struct has
+ // padding space left it's added to this structure.
+ bool __weekday_name_ : 1 {false};
+ bool __month_name_ : 1 {false};
+
+ uint8_t __reserved_1_ : 6 {0};
+ uint8_t __reserved_2_ : 6 {0};
+ // These two flags are only used internally and not part of the
+ // __parsed_specifications. Therefore put them at the end.
+ bool __width_as_arg_ : 1 {false};
+ bool __precision_as_arg_ : 1 {false};
+
+ /// The requested width, either the value or the arg-id.
+ int32_t __width_{0};
+
+ /// The requested precision, either the value or the arg-id.
+ int32_t __precision_{-1};
+
+ // LWG 3576 will probably change this to always accept a Unicode code point
+ // To avoid changing the size with that change align the field so when it
+ // becomes 32-bit its alignment will remain the same. That also means the
+ // size will remain the same. (D2572 addresses the solution for LWG 3576.)
+ _CharT __fill_{_CharT(' ')};
- default:
- __throw_format_error("The format-spec type has a type not supported for "
- "a string argument");
+private:
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alignment(_CharT __c) {
+ switch (__c) {
+ case _CharT('<'):
+ __alignment_ = __alignment::__left;
+ return true;
+
+ case _CharT('^'):
+ __alignment_ = __alignment::__center;
+ return true;
+
+ case _CharT('>'):
+ __alignment_ = __alignment::__right;
+ return true;
}
+ return false;
}
-};
-
-/**
- * The parser for the std-format-spec.
- *
- * This implements the parser for the integral types. This includes the
- * character type and boolean type.
- *
- * See @ref __parser_string.
- */
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_integral
- : public __parser_width, // provides __width(|as_arg)
- public __parser_fill_align<_CharT>, // provides __fill and uses __flags
- public _Flags // provides __flags
-{
-public:
- using char_type = _CharT;
-
-protected:
- /**
- * The low-level std-format-spec parse function.
- *
- * @pre __begin points at the beginning of the std-format-spec. This means
- * directly after the ':'.
- * @pre The std-format-spec parses the entire input, or the first unmatched
- * character is a '}'.
- *
- * @returns The iterator pointing at the last parsed character.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
- -> decltype(__parse_ctx.begin()) {
- auto __begin = __parse_ctx.begin();
- auto __end = __parse_ctx.end();
- if (__begin == __end)
- return __begin;
- __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,
- static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
-
- __begin = __parse_sign(__begin, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
-
- __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(const _CharT*& __begin, const _CharT* __end) {
+ _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause "
+ "undefined behavior by evaluating data not in the input");
+ if (__begin + 1 != __end) {
+ if (__parse_alignment(*(__begin + 1))) {
+ if (*__begin == _CharT('{') || *__begin == _CharT('}'))
+ __throw_format_error("The format-spec fill field contains an invalid character");
- __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+ __fill_ = *__begin;
+ __begin += 2;
+ return true;
+ }
+ }
- __begin = __parser_width::__parse(__begin, __end, __parse_ctx);
- if (__begin == __end)
- return __begin;
+ if (!__parse_alignment(*__begin))
+ return false;
- __begin =
- __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+ ++__begin;
+ return true;
+ }
- __begin = __parse_type(__begin, static_cast<_Flags&>(*this));
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_sign(const _CharT*& __begin) {
+ switch (*__begin) {
+ case _CharT('-'):
+ __sign_ = __sign::__minus;
+ break;
+ case _CharT('+'):
+ __sign_ = __sign::__plus;
+ break;
+ case _CharT(' '):
+ __sign_ = __sign::__space;
+ break;
+ default:
+ return false;
+ }
+ ++__begin;
+ return true;
+ }
- if (__begin != __end && *__begin != _CharT('}'))
- __throw_format_error(
- "The format-spec should consume the input or end with a '}'");
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alternate_form(const _CharT*& __begin) {
+ if (*__begin != _CharT('#'))
+ return false;
- return __begin;
+ __alternate_form_ = true;
+ ++__begin;
+ return true;
}
- /** Handles the post-parsing updates for the integer types. */
- _LIBCPP_HIDE_FROM_ABI constexpr void __handle_integer() noexcept {
- __process_arithmetic_alignment(static_cast<_Flags&>(*this));
- }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_zero_padding(const _CharT*& __begin) {
+ if (*__begin != _CharT('0'))
+ return false;
- /**
- * Handles the post-parsing updates for the character types.
- *
- * Sets the alignment and validates the format flags set for a character type.
- *
- * At the moment the validation for a character and a Boolean behave the
- * same, but this may change in the future.
- * Specifically at the moment the locale-specific form is allowed for the
- * char output type, but it has no effect on the output.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr void __handle_char() { __handle_bool(); }
-
- /**
- * Handles the post-parsing updates for the Boolean types.
- *
- * Sets the alignment and validates the format flags set for a Boolean type.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr void __handle_bool() {
- if (this->__sign != _Flags::_Sign::__default)
- __throw_format_error("A sign field isn't allowed in this format-spec");
-
- if (this->__alternate_form)
- __throw_format_error(
- "An alternate form field isn't allowed in this format-spec");
-
- if (this->__zero_padding)
- __throw_format_error(
- "A zero-padding field isn't allowed in this format-spec");
-
- if (this->__alignment == _Flags::_Alignment::__default)
- this->__alignment = _Flags::_Alignment::__left;
+ if (__alignment_ == __alignment::__default)
+ __alignment_ = __alignment::__zero_padding;
+ ++__begin;
+ return true;
}
-};
-/**
- * The parser for the std-format-spec.
- *
- * This implements the parser for the floating-point types.
- *
- * See @ref __parser_string.
- */
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_floating_point
- : public __parser_width, // provides __width(|as_arg)
- public __parser_precision, // provides __precision(|as_arg)
- public __parser_fill_align<_CharT>, // provides __fill and uses __flags
- public _Flags // provides __flags
-{
-public:
- using char_type = _CharT;
-
- /**
- * The low-level std-format-spec parse function.
- *
- * @pre __begin points at the beginning of the std-format-spec. This means
- * directly after the ':'.
- * @pre The std-format-spec parses the entire input, or the first unmatched
- * character is a '}'.
- *
- * @returns The iterator pointing at the last parsed character.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx)
- -> decltype(__parse_ctx.begin()) {
- auto __it = __parse(__parse_ctx);
- __process_arithmetic_alignment(static_cast<_Flags&>(*this));
- __process_display_type();
- return __it;
- }
-protected:
- /**
- * The low-level std-format-spec parse function.
- *
- * @pre __begin points at the beginning of the std-format-spec. This means
- * directly after the ':'.
- * @pre The std-format-spec parses the entire input, or the first unmatched
- * character is a '}'.
- *
- * @returns The iterator pointing at the last parsed character.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx)
- -> decltype(__parse_ctx.begin()) {
- auto __begin = __parse_ctx.begin();
- auto __end = __parse_ctx.end();
- if (__begin == __end)
- return __begin;
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) {
+ if (*__begin == _CharT('0'))
+ __throw_format_error("A format-spec width field shouldn't have a leading zero");
- __begin = __parser_fill_align<_CharT>::__parse(__begin, __end,
- static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+ if (*__begin == _CharT('{')) {
+ __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
+ __width_as_arg_ = true;
+ __width_ = __r.__value;
+ __begin = __r.__ptr;
+ return true;
+ }
- __begin = __parse_sign(__begin, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ return false;
- __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+ __format::__parse_number_result __r = __format::__parse_number(__begin, __end);
+ __width_ = __r.__value;
+ _LIBCPP_ASSERT(__width_ != 0, "A zero value isn't allowed and should be impossible, "
+ "due to validations in this function");
+ __begin = __r.__ptr;
+ return true;
+ }
- __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_precision(const _CharT*& __begin, const _CharT* __end,
+ auto& __parse_ctx) {
+ if (*__begin != _CharT('.'))
+ return false;
- __begin = __parser_width::__parse(__begin, __end, __parse_ctx);
+ ++__begin;
if (__begin == __end)
- return __begin;
+ __throw_format_error("End of input while parsing format-spec precision");
- __begin = __parser_precision::__parse(__begin, __end, __parse_ctx);
- if (__begin == __end)
- return __begin;
+ if (*__begin == _CharT('{')) {
+ __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
+ __precision_as_arg_ = true;
+ __precision_ = __arg_id.__value;
+ __begin = __arg_id.__ptr;
+ return true;
+ }
- __begin =
- __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ __throw_format_error("The format-spec precision field doesn't contain a value or arg-id");
- __begin = __parse_type(__begin, static_cast<_Flags&>(*this));
+ __format::__parse_number_result __r = __format::__parse_number(__begin, __end);
+ __precision_ = __r.__value;
+ __precision_as_arg_ = false;
+ __begin = __r.__ptr;
+ return true;
+ }
- if (__begin != __end && *__begin != _CharT('}'))
- __throw_format_error(
- "The format-spec should consume the input or end with a '}'");
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_locale_specific_form(const _CharT*& __begin) {
+ if (*__begin != _CharT('L'))
+ return false;
- return __begin;
+ __locale_specific_form_ = true;
+ ++__begin;
+ return true;
}
- /** Processes the parsed std-format-spec based on the parsed display type. */
- _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {
- switch (this->__type) {
- case _Flags::_Type::__default:
- // When no precision specified then it keeps default since that
- // formatting differs from the other types.
- if (this->__has_precision_field())
- this->__type = _Flags::_Type::__general_lower_case;
+ _LIBCPP_HIDE_FROM_ABI constexpr void __parse_type(const _CharT*& __begin) {
+ // Determines the type. It does not validate whether the selected type is
+ // valid. Most formatters have optional fields that are only allowed for
+ // certain types. These parsers need to do validation after the type has
+ // been parsed. So its easier to implement the validation for all types in
+ // the specific parse function.
+ switch (*__begin) {
+ case 'A':
+ __type_ = __type::__hexfloat_upper_case;
break;
- case _Flags::_Type::__float_hexadecimal_lower_case:
- case _Flags::_Type::__float_hexadecimal_upper_case:
- // Precision specific behavior will be handled later.
+ case 'B':
+ __type_ = __type::__binary_upper_case;
break;
- case _Flags::_Type::__scientific_lower_case:
- case _Flags::_Type::__scientific_upper_case:
- case _Flags::_Type::__fixed_lower_case:
- case _Flags::_Type::__fixed_upper_case:
- case _Flags::_Type::__general_lower_case:
- case _Flags::_Type::__general_upper_case:
- if (!this->__has_precision_field()) {
- // Set the default precision for the call to to_chars.
- this->__precision = 6;
- this->__precision_as_arg = false;
- }
+ case 'E':
+ __type_ = __type::__scientific_upper_case;
+ break;
+ case 'F':
+ __type_ = __type::__fixed_upper_case;
+ break;
+ case 'G':
+ __type_ = __type::__general_upper_case;
+ break;
+ case 'X':
+ __type_ = __type::__hexadecimal_upper_case;
+ break;
+ case 'a':
+ __type_ = __type::__hexfloat_lower_case;
+ break;
+ case 'b':
+ __type_ = __type::__binary_lower_case;
+ break;
+ case 'c':
+ __type_ = __type::__char;
+ break;
+ case 'd':
+ __type_ = __type::__decimal;
+ break;
+ case 'e':
+ __type_ = __type::__scientific_lower_case;
+ break;
+ case 'f':
+ __type_ = __type::__fixed_lower_case;
+ break;
+ case 'g':
+ __type_ = __type::__general_lower_case;
+ break;
+ case 'o':
+ __type_ = __type::__octal;
+ break;
+ case 'p':
+ __type_ = __type::__pointer;
+ break;
+ case 's':
+ __type_ = __type::__string;
+ break;
+ case 'x':
+ __type_ = __type::__hexadecimal_lower_case;
break;
-
default:
- __throw_format_error("The format-spec type has a type not supported for "
- "a floating-point argument");
+ return;
}
+ ++__begin;
}
-};
-/**
- * The parser for the std-format-spec.
- *
- * This implements the parser for the pointer types.
- *
- * See @ref __parser_string.
- */
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_pointer : public __parser_width, // provides __width(|as_arg)
- public __parser_fill_align<_CharT>, // provides __fill and uses __flags
- public _Flags // provides __flags
-{
-public:
- using char_type = _CharT;
+ _LIBCPP_HIDE_FROM_ABI
+ int32_t __get_width(auto& __ctx) const {
+ if (!__width_as_arg_)
+ return __width_;
- _LIBCPP_HIDE_FROM_ABI constexpr __parser_pointer() {
- // Implements LWG3612 Inconsistent pointer alignment in std::format.
- // The issue's current status is "Tentatively Ready" and libc++ status is
- // still experimental.
- //
- // TODO FMT Validate this with the final resolution of LWG3612.
- this->__alignment = _Flags::_Alignment::__right;
+ int32_t __result = __format_spec::__substitute_arg_id(__ctx.arg(__width_));
+ if (__result == 0)
+ __throw_format_error("A format-spec width field replacement should have a positive value");
+ return __result;
}
- /**
- * The low-level std-format-spec parse function.
- *
- * @pre __begin points at the beginning of the std-format-spec. This means
- * directly after the ':'.
- * @pre The std-format-spec parses the entire input, or the first unmatched
- * character is a '}'.
- *
- * @returns The iterator pointing at the last parsed character.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) {
- auto __it = __parse(__parse_ctx);
- __process_display_type();
- return __it;
+ _LIBCPP_HIDE_FROM_ABI
+ int32_t __get_precision(auto& __ctx) const {
+ if (!__precision_as_arg_)
+ return __precision_;
+
+ return __format_spec::__substitute_arg_id(__ctx.arg(__precision_));
}
+};
-protected:
- /**
- * The low-level std-format-spec parse function.
- *
- * @pre __begin points at the beginning of the std-format-spec. This means
- * directly after the ':'.
- * @pre The std-format-spec parses the entire input, or the first unmatched
- * character is a '}'.
- *
- * @returns The iterator pointing at the last parsed character.
- */
- _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) {
- auto __begin = __parse_ctx.begin();
- auto __end = __parse_ctx.end();
- if (__begin == __end)
- return __begin;
+// Validates whether the reserved bitfields don't change the size.
+static_assert(sizeof(__parser<char>) == 16);
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static_assert(sizeof(__parser<wchar_t>) == 16);
+# endif
- __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, static_cast<_Flags&>(*this));
- if (__begin == __end)
- return __begin;
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec::__type __type) {
+ switch (__type) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__string:
+ break;
- // An integer presentation type isn't defined in the Standard.
- // Since a pointer is formatted as an integer it can be argued it's an
- // integer presentation type. However there are two LWG-issues asserting it
- // isn't an integer presentation type:
- // - LWG3612 Inconsistent pointer alignment in std::format
- // - LWG3644 std::format does not define "integer presentation type"
- //
- // There's a paper to make additional clarifications on the status of
- // formatting pointers and proposes additional fields to be valid. That
- // paper hasn't been reviewed by the Committee yet.
- // - P2510 Formatting pointers
- //
- // The current implementation assumes formatting pointers isn't covered by
- // "integer presentation type".
- // TODO FMT Apply the LWG-issues/papers after approval/rejection by the Committee.
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a string argument");
+ }
+}
- __begin = __parser_width::__parse(__begin, __end, __parse_ctx);
- if (__begin == __end)
- return __begin;
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_bool_string(__parser<_CharT>& __parser) {
+ if (__parser.__sign_ != __sign::__default)
+ std::__throw_format_error("A sign field isn't allowed in this format-spec");
- __begin = __parse_type(__begin, static_cast<_Flags&>(*this));
+ if (__parser.__alternate_form_)
+ std::__throw_format_error("An alternate form field isn't allowed in this format-spec");
- if (__begin != __end && *__begin != _CharT('}'))
- __throw_format_error("The format-spec should consume the input or end with a '}'");
+ if (__parser.__alignment_ == __alignment::__zero_padding)
+ std::__throw_format_error("A zero-padding field isn't allowed in this format-spec");
- return __begin;
- }
+ if (__parser.__alignment_ == __alignment::__default)
+ __parser.__alignment_ = __alignment::__left;
+}
- /** Processes the parsed std-format-spec based on the parsed display type. */
- _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() {
- switch (this->__type) {
- case _Flags::_Type::__default:
- this->__type = _Flags::_Type::__pointer;
- break;
- case _Flags::_Type::__pointer:
- break;
- default:
- __throw_format_error("The format-spec type has a type not supported for a pointer argument");
- }
- }
-};
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_char(__parser<_CharT>& __parser) {
+ __format_spec::__process_display_type_bool_string(__parser);
+}
-/** Helper struct returned from @ref __get_string_alignment. */
template <class _CharT>
-struct _LIBCPP_TEMPLATE_VIS __string_alignment {
- /** Points beyond the last character to write to the output. */
- const _CharT* __last;
- /**
- * The estimated number of columns in the output or 0.
- *
- * Only when the output needs to be aligned it's required to know the exact
- * number of columns in the output. So if the formatted output has only a
- * minimum width the exact size isn't important. It's only important to know
- * the minimum has been reached. The minimum width is the width specified in
- * the format-spec.
- *
- * For example in this code @code std::format("{:10}", MyString); @endcode
- * the width estimation can stop once the algorithm has determined the output
- * width is 10 columns.
- *
- * So if:
- * * @ref __align == @c true the @ref __size is the estimated number of
- * columns required.
- * * @ref __align == @c false the @ref __size is the estimated number of
- * columns required or 0 when the estimation algorithm stopped prematurely.
- */
- ptrdiff_t __size;
- /**
- * Does the output need to be aligned.
- *
- * When alignment is needed the output algorithm needs to add the proper
- * padding. Else the output algorithm just needs to copy the input up to
- * @ref __last.
- */
- bool __align;
-};
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_bool(__parser<_CharT>& __parser) {
+ switch (__parser.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__string:
+ __format_spec::__process_display_type_bool_string(__parser);
+ break;
-#ifndef _LIBCPP_HAS_NO_UNICODE
-namespace __detail {
+ case __format_spec::__type::__binary_lower_case:
+ case __format_spec::__type::__binary_upper_case:
+ case __format_spec::__type::__octal:
+ case __format_spec::__type::__decimal:
+ case __format_spec::__type::__hexadecimal_lower_case:
+ case __format_spec::__type::__hexadecimal_upper_case:
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a bool argument");
+ }
+}
-/**
- * Unicode column width estimates.
- *
- * Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32.
- * Depending on format the relation between the number of code units stored and
- * the number of output columns differs. The first relation is the number of
- * code units forming a code point. (The text assumes the code units are
- * unsigned.)
- * - UTF-8 The number of code units is between one and four. The first 127
- * Unicode code points match the ASCII character set. When the highest bit is
- * set it means the code point has more than one code unit.
- * - UTF-16: The number of code units is between 1 and 2. When the first
- * code unit is in the range [0xd800,0xdfff) it means the code point uses two
- * code units.
- * - UTF-32: The number of code units is always one.
- *
- * The code point to the number of columns isn't well defined. The code uses the
- * estimations defined in [format.string.std]/11. This list might change in the
- * future.
- *
- * The algorithm of @ref __get_string_alignment uses two different scanners:
- * - The simple scanner @ref __estimate_column_width_fast. This scanner assumes
- * 1 code unit is 1 column. This scanner stops when it can't be sure the
- * assumption is valid:
- * - UTF-8 when the code point is encoded in more than 1 code unit.
- * - UTF-16 and UTF-32 when the first multi-column code point is encountered.
- * (The code unit's value is lower than 0xd800 so the 2 code unit encoding
- * is irrelevant for this scanner.)
- * Due to these assumptions the scanner is faster than the full scanner. It
- * can process all text only containing ASCII. For UTF-16/32 it can process
- * most (all?) European languages. (Note the set it can process might be
- * reduced in the future, due to updates in the scanning rules.)
- * - The full scanner @ref __estimate_column_width. This scanner, if needed,
- * converts multiple code units into one code point then converts the code
- * point to a column width.
- *
- * See also:
- * - [format.string.general]/11
- * - https://en.wikipedia.org/wiki/UTF-8#Encoding
- * - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
- */
-
-/**
- * The first 2 column code point.
- *
- * This is the point where the fast UTF-16/32 scanner needs to stop processing.
- */
-inline constexpr uint32_t __two_column_code_point = 0x1100;
-
-/** Helper concept for an UTF-8 character type. */
template <class _CharT>
-concept __utf8_character = same_as<_CharT, char> || same_as<_CharT, char8_t>;
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __parser) {
+ switch (__parser.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__char:
+ __format_spec::__process_display_type_char(__parser);
+ break;
+
+ case __format_spec::__type::__binary_lower_case:
+ case __format_spec::__type::__binary_upper_case:
+ case __format_spec::__type::__octal:
+ case __format_spec::__type::__decimal:
+ case __format_spec::__type::__hexadecimal_lower_case:
+ case __format_spec::__type::__hexadecimal_upper_case:
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a char argument");
+ }
+}
-/** Helper concept for an UTF-16 character type. */
template <class _CharT>
-concept __utf16_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) || same_as<_CharT, char16_t>;
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_integer(__parser<_CharT>& __parser) {
+ switch (__parser.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__binary_lower_case:
+ case __format_spec::__type::__binary_upper_case:
+ case __format_spec::__type::__octal:
+ case __format_spec::__type::__decimal:
+ case __format_spec::__type::__hexadecimal_lower_case:
+ case __format_spec::__type::__hexadecimal_upper_case:
+ break;
+
+ case __format_spec::__type::__char:
+ __format_spec::__process_display_type_char(__parser);
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for an integer argument");
+ }
+}
-/** Helper concept for an UTF-32 character type. */
template <class _CharT>
-concept __utf32_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) || same_as<_CharT, char32_t>;
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_floating_point(__parser<_CharT>& __parser) {
+ switch (__parser.__type_) {
+ case __format_spec::__type::__default:
+ // When no precision specified then it keeps default since that
+ // formatting differs from the other types.
+ if (__parser.__precision_as_arg_ || __parser.__precision_ != -1)
+ __parser.__type_ = __format_spec::__type::__general_lower_case;
+ break;
+ case __format_spec::__type::__hexfloat_lower_case:
+ case __format_spec::__type::__hexfloat_upper_case:
+ // Precision specific behavior will be handled later.
+ break;
+ case __format_spec::__type::__scientific_lower_case:
+ case __format_spec::__type::__scientific_upper_case:
+ case __format_spec::__type::__fixed_lower_case:
+ case __format_spec::__type::__fixed_upper_case:
+ case __format_spec::__type::__general_lower_case:
+ case __format_spec::__type::__general_upper_case:
+ if (!__parser.__precision_as_arg_ && __parser.__precision_ == -1)
+ // Set the default precision for the call to to_chars.
+ __parser.__precision_ = 6;
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a floating-point argument");
+ }
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_pointer(__format_spec::__type __type) {
+ switch (__type) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__pointer:
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a pointer argument");
+ }
+}
-/** Helper concept for an UTF-16 or UTF-32 character type. */
template <class _CharT>
-concept __utf16_or_32_character = __utf16_character<_CharT> || __utf32_character<_CharT>;
-
-/**
- * Converts a code point to the column width.
- *
- * The estimations are conforming to [format.string.general]/11
- *
- * This version expects a value less than 0x1'0000, which is a 3-byte UTF-8
- * character.
- */
-_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexcept {
- _LIBCPP_ASSERT(__c < 0x1'0000,
- "Use __column_width_4 or __column_width for larger values");
+struct __column_width_result {
+ /// The number of output columns.
+ size_t __width_;
+ /// One beyond the last code unit used in the estimation.
+ ///
+ /// This limits the original output to fit in the wanted number of columns.
+ const _CharT* __last_;
+};
+
+/// Since a column width can be two it's possible that the requested column
+/// width can't be achieved. Depending on the intended usage the policy can be
+/// selected.
+/// - When used as precision the maximum width may not be exceeded and the
+/// result should be "rounded down" to the previous boundary.
+/// - When used as a width we're done once the minimum is reached, but
+/// exceeding is not an issue. Rounding down is an issue since that will
+/// result in writing fill characters. Therefore the result needs to be
+/// "rounded up".
+enum class __column_width_rounding { __down, __up };
+
+# ifndef _LIBCPP_HAS_NO_UNICODE
+
+namespace __detail {
+
+/// Converts a code point to the column width.
+///
+/// The estimations are conforming to [format.string.general]/11
+///
+/// This version expects a value less than 0x1'0000, which is a 3-byte UTF-8
+/// character.
+_LIBCPP_HIDE_FROM_ABI constexpr int __column_width_3(uint32_t __c) noexcept {
+ _LIBCPP_ASSERT(__c < 0x10000, "Use __column_width_4 or __column_width for larger values");
// clang-format off
return 1 + (__c >= 0x1100 && (__c <= 0x115f ||
@@ -1059,15 +738,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexce
// clang-format on
}
-/**
- * @overload
- *
- * This version expects a value greater than or equal to 0x1'0000, which is a
- * 4-byte UTF-8 character.
- */
-_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexcept {
- _LIBCPP_ASSERT(__c >= 0x1'0000,
- "Use __column_width_3 or __column_width for smaller values");
+/// @overload
+///
+/// This version expects a value greater than or equal to 0x1'0000, which is a
+/// 4-byte UTF-8 character.
+_LIBCPP_HIDE_FROM_ABI constexpr int __column_width_4(uint32_t __c) noexcept {
+ _LIBCPP_ASSERT(__c >= 0x10000, "Use __column_width_3 or __column_width for smaller values");
// clang-format off
return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f ||
@@ -1078,316 +754,148 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexce
// clang-format on
}
-/**
- * @overload
- *
- * The general case, accepting all values.
- */
-_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width(uint32_t __c) noexcept {
- if (__c < 0x1'0000)
- return __column_width_3(__c);
+/// @overload
+///
+/// The general case, accepting all values.
+_LIBCPP_HIDE_FROM_ABI constexpr int __column_width(uint32_t __c) noexcept {
+ if (__c < 0x10000)
+ return __detail::__column_width_3(__c);
- return __column_width_4(__c);
-}
-
-/**
- * Estimate the column width for the UTF-8 sequence using the fast algorithm.
- */
-template <__utf8_character _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
-__estimate_column_width_fast(const _CharT* __first,
- const _CharT* __last) noexcept {
- return _VSTD::find_if(__first, __last,
- [](unsigned char __c) { return __c & 0x80; });
-}
-
-/**
- * @overload
- *
- * The implementation for UTF-16/32.
- */
-template <__utf16_or_32_character _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
-__estimate_column_width_fast(const _CharT* __first,
- const _CharT* __last) noexcept {
- return _VSTD::find_if(__first, __last,
- [](uint32_t __c) { return __c >= 0x1100; });
+ return __detail::__column_width_4(__c);
}
template <class _CharT>
-struct _LIBCPP_TEMPLATE_VIS __column_width_result {
- /** The number of output columns. */
- size_t __width;
- /**
- * The last parsed element.
- *
- * This limits the original output to fit in the wanted number of columns.
- */
- const _CharT* __ptr;
-};
-
-/**
- * Small helper to determine the width of malformed Unicode.
- *
- * @note This function's only needed for UTF-8. During scanning UTF-8 there
- * are multiple place where it can be detected that the Unicode is malformed.
- * UTF-16 only requires 1 test and UTF-32 requires no testing.
- */
-template <__utf8_character _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
-__estimate_column_width_malformed(const _CharT* __first, const _CharT* __last,
- size_t __maximum, size_t __result) noexcept {
- size_t __size = __last - __first;
- size_t __n = _VSTD::min(__size, __maximum);
- return {__result + __n, __first + __n};
-}
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width_grapheme_clustering(
+ const _CharT* __first, const _CharT* __last, size_t __maximum, __column_width_rounding __rounding) noexcept {
+ __unicode::__extended_grapheme_cluster_view<_CharT> __view{__first, __last};
-/**
- * Determines the number of output columns needed to render the input.
- *
- * @note When the scanner encounters malformed Unicode it acts as-if every code
- * unit at the end of the input is one output column. It's expected the output
- * terminal will replace these malformed code units with a one column
- * replacement characters.
- *
- * @param __first Points to the first element of the input range.
- * @param __last Points beyond the last element of the input range.
- * @param __maximum The maximum number of output columns. The returned number
- * of estimated output columns will not exceed this value.
- */
-template <__utf8_character _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
-__estimate_column_width(const _CharT* __first, const _CharT* __last,
- size_t __maximum) noexcept {
- size_t __result = 0;
-
- while (__first != __last) {
- // Based on the number of leading 1 bits the number of code units in the
- // code point can be determined. See
- // https://en.wikipedia.org/wiki/UTF-8#Encoding
- switch (_VSTD::countl_one(static_cast<unsigned char>(*__first))) {
- case 0: // 1-code unit encoding: all 1 column
- ++__result;
- ++__first;
- break;
+ __column_width_result<_CharT> __result{0, __first};
+ while (__result.__last_ != __last && __result.__width_ <= __maximum) {
+ typename __unicode::__extended_grapheme_cluster_view<_CharT>::__cluster __cluster = __view.__consume();
+ int __width = __detail::__column_width(__cluster.__code_point_);
- case 2: // 2-code unit encoding: all 1 column
- // Malformed Unicode.
- if (__last - __first < 2) [[unlikely]]
- return __estimate_column_width_malformed(__first, __last, __maximum,
- __result);
- __first += 2;
- ++__result;
- break;
+ // When the next entry would exceed the maximum width the previous width
+ // might be returned. For example when a width of 100 is requested the
+ // returned width might be 99, since the next code point has an estimated
+ // column width of 2. This depends on the rounding flag.
+ // When the maximum is exceeded the loop will abort the next iteration.
+ if (__rounding == __column_width_rounding::__down && __result.__width_ + __width > __maximum)
+ return __result;
- case 3: // 3-code unit encoding: either 1 or 2 columns
- // Malformed Unicode.
- if (__last - __first < 3) [[unlikely]]
- return __estimate_column_width_malformed(__first, __last, __maximum,
- __result);
- {
- uint32_t __c = static_cast<unsigned char>(*__first++) & 0x0f;
- __c <<= 6;
- __c |= static_cast<unsigned char>(*__first++) & 0x3f;
- __c <<= 6;
- __c |= static_cast<unsigned char>(*__first++) & 0x3f;
- __result += __column_width_3(__c);
- if (__result > __maximum)
- return {__result - 2, __first - 3};
- }
- break;
- case 4: // 4-code unit encoding: either 1 or 2 columns
- // Malformed Unicode.
- if (__last - __first < 4) [[unlikely]]
- return __estimate_column_width_malformed(__first, __last, __maximum,
- __result);
- {
- uint32_t __c = static_cast<unsigned char>(*__first++) & 0x07;
- __c <<= 6;
- __c |= static_cast<unsigned char>(*__first++) & 0x3f;
- __c <<= 6;
- __c |= static_cast<unsigned char>(*__first++) & 0x3f;
- __c <<= 6;
- __c |= static_cast<unsigned char>(*__first++) & 0x3f;
- __result += __column_width_4(__c);
- if (__result > __maximum)
- return {__result - 2, __first - 4};
- }
- break;
- default:
- // Malformed Unicode.
- return __estimate_column_width_malformed(__first, __last, __maximum,
- __result);
- }
-
- if (__result >= __maximum)
- return {__result, __first};
+ __result.__width_ += __width;
+ __result.__last_ = __cluster.__last_;
}
- return {__result, __first};
-}
-template <__utf16_character _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
-__estimate_column_width(const _CharT* __first, const _CharT* __last,
- size_t __maximum) noexcept {
- size_t __result = 0;
-
- while (__first != __last) {
- uint32_t __c = *__first;
- // Is the code unit part of a surrogate pair? See
- // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
- if (__c >= 0xd800 && __c <= 0xDfff) {
- // Malformed Unicode.
- if (__last - __first < 2) [[unlikely]]
- return {__result + 1, __first + 1};
-
- __c -= 0xd800;
- __c <<= 10;
- __c += (*(__first + 1) - 0xdc00);
- __c += 0x10'000;
-
- __result += __column_width_4(__c);
- if (__result > __maximum)
- return {__result - 2, __first};
- __first += 2;
- } else {
- __result += __column_width_3(__c);
- if (__result > __maximum)
- return {__result - 2, __first};
- ++__first;
- }
-
- if (__result >= __maximum)
- return {__result, __first};
- }
-
- return {__result, __first};
-}
-
-template <__utf32_character _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
-__estimate_column_width(const _CharT* __first, const _CharT* __last,
- size_t __maximum) noexcept {
- size_t __result = 0;
-
- while (__first != __last) {
- wchar_t __c = *__first;
- __result += __column_width(__c);
-
- if (__result > __maximum)
- return {__result - 2, __first};
-
- ++__first;
- if (__result >= __maximum)
- return {__result, __first};
- }
-
- return {__result, __first};
+ return __result;
}
} // namespace __detail
+// Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32.
+// Depending on format the relation between the number of code units stored and
+// the number of output columns differs. The first relation is the number of
+// code units forming a code point. (The text assumes the code units are
+// unsigned.)
+// - UTF-8 The number of code units is between one and four. The first 127
+// Unicode code points match the ASCII character set. When the highest bit is
+// set it means the code point has more than one code unit.
+// - UTF-16: The number of code units is between 1 and 2. When the first
+// code unit is in the range [0xd800,0xdfff) it means the code point uses two
+// code units.
+// - UTF-32: The number of code units is always one.
+//
+// The code point to the number of columns is specified in
+// [format.string.std]/11. This list might change in the future.
+//
+// Another thing to be taken into account is Grapheme clustering. This means
+// that in some cases multiple code points are combined one element in the
+// output. For example:
+// - an ASCII character with a combined diacritical mark
+// - an emoji with a skin tone modifier
+// - a group of combined people emoji to create a family
+// - a combination of flag emoji
+//
+// See also:
+// - [format.string.general]/11
+// - https://en.wikipedia.org/wiki/UTF-8#Encoding
+// - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_ascii(char32_t __c) { return __c < 0x80; }
+
+/// Determines the number of output columns needed to render the input.
+///
+/// \note When the scanner encounters malformed Unicode it acts as-if every
+/// code unit is a one column code point. Typically a terminal uses the same
+/// strategy and replaces every malformed code unit with a one column
+/// replacement character.
+///
+/// \param __first Points to the first element of the input range.
+/// \param __last Points beyond the last element of the input range.
+/// \param __maximum The maximum number of output columns. The returned number
+/// of estimated output columns will not exceed this value.
+/// \param __rounding Selects the rounding method.
+/// \c __down result.__width_ <= __maximum
+/// \c __up result.__width_ <= __maximum + 1
template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT>
-__get_string_alignment(const _CharT* __first, const _CharT* __last,
- ptrdiff_t __width, ptrdiff_t __precision) noexcept {
- _LIBCPP_ASSERT(__width != 0 || __precision != -1,
- "The function has no effect and shouldn't be used");
-
- // TODO FMT There might be more optimizations possible:
- // If __precision == __format::__number_max and the encoding is:
- // * UTF-8 : 4 * (__last - __first) >= __width
- // * UTF-16 : 2 * (__last - __first) >= __width
- // * UTF-32 : (__last - __first) >= __width
- // In these cases it's certain the output is at least the requested width.
- // It's unknown how often this happens in practice. For now the improvement
- // isn't implemented.
-
- /*
- * First assume there are no special Unicode code units in the input.
- * - Apply the precision (this may reduce the size of the input). When
- * __precison == -1 this step is omitted.
- * - Scan for special code units in the input.
- * If our assumption was correct the __pos will be at the end of the input.
- */
- const ptrdiff_t __length = __last - __first;
- const _CharT* __limit =
- __first +
- (__precision == -1 ? __length : _VSTD::min(__length, __precision));
- ptrdiff_t __size = __limit - __first;
- const _CharT* __pos =
- __detail::__estimate_column_width_fast(__first, __limit);
-
- if (__pos == __limit)
- return {__limit, __size, __size < __width};
-
- /*
- * Our assumption was wrong, there are special Unicode code units.
- * The range [__first, __pos) contains a set of code units with the
- * following property:
- * Every _CharT in the range will be rendered in 1 column.
- *
- * If there's no maximum width and the parsed size already exceeds the
- * minimum required width. The real size isn't important. So bail out.
- */
- if (__precision == -1 && (__pos - __first) >= __width)
- return {__last, 0, false};
-
- /* If there's a __precision, truncate the output to that width. */
- ptrdiff_t __prefix = __pos - __first;
- if (__precision != -1) {
- _LIBCPP_ASSERT(__precision > __prefix, "Logic error.");
- auto __lengh_info = __detail::__estimate_column_width(
- __pos, __last, __precision - __prefix);
- __size = __lengh_info.__width + __prefix;
- return {__lengh_info.__ptr, __size, __size < __width};
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width(
+ basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding __rounding) noexcept {
+ // The width estimation is done in two steps:
+ // - Quickly process for the ASCII part. ASCII has the following properties
+ // - One code unit is one code point
+ // - Every code point has an estimated width of one
+ // - When needed it will a Unicode Grapheme clustering algorithm to find
+ // the proper place for truncation.
+
+ if (__str.empty() || __maximum == 0)
+ return {0, __str.begin()};
+
+ // ASCII has one caveat; when an ASCII character is followed by a non-ASCII
+ // character they might be part of an extended grapheme cluster. For example:
+ // an ASCII letter and a COMBINING ACUTE ACCENT
+ // The truncate should happen after the COMBINING ACUTE ACCENT. Therefore we
+ // need to scan one code unit beyond the requested precision. When this code
+ // unit is non-ASCII we omit the current code unit and let the Grapheme
+ // clustering algorithm do its work.
+ const _CharT* __it = __str.begin();
+ if (__is_ascii(*__it)) {
+ do {
+ --__maximum;
+ ++__it;
+ if (__it == __str.end())
+ return {__str.size(), __str.end()};
+
+ if (__maximum == 0) {
+ if (__is_ascii(*__it))
+ return {static_cast<size_t>(__it - __str.begin()), __it};
+
+ break;
+ }
+ } while (__is_ascii(*__it));
+ --__it;
+ ++__maximum;
}
- /* Else use __width to determine the number of required padding characters. */
- _LIBCPP_ASSERT(__width > __prefix, "Logic error.");
- /*
- * The column width is always one or two columns. For the precision the wanted
- * column width is the maximum, for the width it's the minimum. Using the
- * width estimation with its truncating behavior will result in the wrong
- * result in the following case:
- * - The last code unit processed requires two columns and exceeds the
- * maximum column width.
- * By increasing the __maximum by one avoids this issue. (It means it may
- * pass one code point more than required to determine the proper result;
- * that however isn't a problem for the algorithm.)
- */
- size_t __maximum = 1 + __width - __prefix;
- auto __lengh_info =
- __detail::__estimate_column_width(__pos, __last, __maximum);
- if (__lengh_info.__ptr != __last) {
- // Consumed the width number of code units. The exact size of the string
- // is unknown. We only know we don't need to align the output.
- _LIBCPP_ASSERT(static_cast<ptrdiff_t>(__lengh_info.__width + __prefix) >=
- __width,
- "Logic error");
- return {__last, 0, false};
- }
+ ptrdiff_t __ascii_size = __it - __str.begin();
+ __column_width_result __result =
+ __detail::__estimate_column_width_grapheme_clustering(__it, __str.end(), __maximum, __rounding);
- __size = __lengh_info.__width + __prefix;
- return {__last, __size, __size < __width};
+ __result.__width_ += __ascii_size;
+ return __result;
}
-#else // _LIBCPP_HAS_NO_UNICODE
+# else // !defined(_LIBCPP_HAS_NO_UNICODE)
template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT>
-__get_string_alignment(const _CharT* __first, const _CharT* __last,
- ptrdiff_t __width, ptrdiff_t __precision) noexcept {
- const ptrdiff_t __length = __last - __first;
- const _CharT* __limit =
- __first +
- (__precision == -1 ? __length : _VSTD::min(__length, __precision));
- ptrdiff_t __size = __limit - __first;
- return {__limit, __size, __size < __width};
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
+__estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding) noexcept {
+ // When Unicode isn't supported assume ASCII and every code unit is one code
+ // point. In ASCII the estimated column width is always one. Thus there's no
+ // need for rounding.
+ size_t __width_ = _VSTD::min(__str.size(), __maximum);
+ return {__width_, __str.begin() + __width_};
}
-#endif // _LIBCPP_HAS_NO_UNICODE
-} // namespace __format_spec
+# endif // !defined(_LIBCPP_HAS_NO_UNICODE)
-# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+} // namespace __format_spec
#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/unicode.h
@@ -0,0 +1,339 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_UNICODE_H
+#define _LIBCPP___FORMAT_UNICODE_H
+
+#include <__assert>
+#include <__config>
+#include <__format/extended_grapheme_cluster_table.h>
+#include <__utility/unreachable.h>
+#include <bit>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+# ifndef _LIBCPP_HAS_NO_UNICODE
+
+/// Implements the grapheme cluster boundary rules
+///
+/// These rules are used to implement format's width estimation as stated in
+/// [format.string.std]/11
+///
+/// The Standard refers to UAX \#29 for Unicode 12.0.0
+/// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules
+///
+/// The data tables used are
+/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
+/// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
+/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only)
+
+namespace __unicode {
+
+inline constexpr char32_t __replacement_character = U'\ufffd';
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(const char* __char, int __count) {
+ do {
+ if ((*__char & 0b1000'0000) != 0b1000'0000)
+ return false;
+ --__count;
+ ++__char;
+ } while (__count);
+ return true;
+}
+
+/// Helper class to extract a code unit from a Unicode character range.
+///
+/// The stored range is a view. There are multiple specialization for different
+/// character types.
+template <class _CharT>
+class __code_point_view;
+
+/// UTF-8 specialization.
+template <>
+class __code_point_view<char> {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const char* __first, const char* __last)
+ : __first_(__first), __last_(__last) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr const char* __position() const noexcept { return __first_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ // Based on the number of leading 1 bits the number of code units in the
+ // code point can be determined. See
+ // https://en.wikipedia.org/wiki/UTF-8#Encoding
+ switch (_VSTD::countl_one(static_cast<unsigned char>(*__first_))) {
+ case 0:
+ return *__first_++;
+
+ case 2:
+ if (__last_ - __first_ < 2 || !__unicode::__is_continuation(__first_ + 1, 1)) [[unlikely]]
+ break;
+ else {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x1f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return __value;
+ }
+
+ case 3:
+ if (__last_ - __first_ < 3 || !__unicode::__is_continuation(__first_ + 1, 2)) [[unlikely]]
+ break;
+ else {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x0f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return __value;
+ }
+
+ case 4:
+ if (__last_ - __first_ < 4 || !__unicode::__is_continuation(__first_ + 1, 3)) [[unlikely]]
+ break;
+ else {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x07;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return __value;
+ }
+ }
+ // An invalid number of leading ones can be garbage or a code unit in the
+ // middle of a code point. By consuming one code unit the parser may get
+ // "in sync" after a few code units.
+ ++__first_;
+ return __replacement_character;
+ }
+
+private:
+ const char* __first_;
+ const char* __last_;
+};
+
+# ifndef TEST_HAS_NO_WIDE_CHARACTERS
+/// This specialization depends on the size of wchar_t
+/// - 2 UTF-16 (for example Windows and AIX)
+/// - 4 UTF-32 (for example Linux)
+template <>
+class __code_point_view<wchar_t> {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const wchar_t* __first, const wchar_t* __last)
+ : __first_(__first), __last_(__last) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const wchar_t* __position() const noexcept { return __first_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ if constexpr (sizeof(wchar_t) == 2) {
+ char32_t __result = *__first_++;
+ // Is the code unit part of a surrogate pair? See
+ // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
+ if (__result >= 0xd800 && __result <= 0xDfff) {
+ // Malformed Unicode.
+ if (__first_ == __last_) [[unlikely]]
+ return __replacement_character;
+
+ __result -= 0xd800;
+ __result <<= 10;
+ __result += *__first_++ - 0xdc00;
+ __result += 0x10000;
+ }
+ return __result;
+
+ } else if constexpr (sizeof(wchar_t) == 4) {
+ char32_t __result = *__first_++;
+ if (__result > 0x10FFFF) [[unlikely]]
+ return __replacement_character;
+ return __result;
+ } else {
+ // TODO FMT P2593R0 Use static_assert(false, "sizeof(wchar_t) has a not implemented value");
+ _LIBCPP_ASSERT(sizeof(wchar_t) == 0, "sizeof(wchar_t) has a not implemented value");
+ __libcpp_unreachable();
+ }
+ }
+
+private:
+ const wchar_t* __first_;
+ const wchar_t* __last_;
+};
+# endif
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
+ bool& __ri_break_allowed,
+ bool __has_extened_pictographic,
+ __extended_grapheme_custer_property_boundary::__property __prev,
+ __extended_grapheme_custer_property_boundary::__property __next) {
+ using __extended_grapheme_custer_property_boundary::__property;
+
+ __has_extened_pictographic |= __prev == __property::__Extended_Pictographic;
+
+ // https://www.unicode.org/reports/tr29/tr29-39.html#Grapheme_Cluster_Boundary_Rules
+
+ // *** Break at the start and end of text, unless the text is empty. ***
+
+ _LIBCPP_ASSERT(__prev != __property::__sot, "should be handled in the constructor"); // GB1
+ _LIBCPP_ASSERT(__prev != __property::__eot, "should be handled by our caller"); // GB2
+
+ // *** Do not break between a CR and LF. Otherwise, break before and after controls. ***
+ if (__prev == __property::__CR && __next == __property::__LF) // GB3
+ return false;
+
+ if (__prev == __property::__Control || __prev == __property::__CR || __prev == __property::__LF) // GB4
+ return true;
+
+ if (__next == __property::__Control || __next == __property::__CR || __next == __property::__LF) // GB5
+ return true;
+
+ // *** Do not break Hangul syllable sequences. ***
+ if (__prev == __property::__L &&
+ (__next == __property::__L || __next == __property::__V || __next == __property::__LV ||
+ __next == __property::__LVT)) // GB6
+ return false;
+
+ if ((__prev == __property::__LV || __prev == __property::__V) &&
+ (__next == __property::__V || __next == __property::__T)) // GB7
+ return false;
+
+ if ((__prev == __property::__LVT || __prev == __property::__T) && __next == __property::__T) // GB8
+ return false;
+
+ // *** Do not break before extending characters or ZWJ. ***
+ if (__next == __property::__Extend || __next == __property::__ZWJ)
+ return false; // GB9
+
+ // *** Do not break before SpacingMarks, or after Prepend characters. ***
+ if (__next == __property::__SpacingMark) // GB9a
+ return false;
+
+ if (__prev == __property::__Prepend) // GB9b
+ return false;
+
+ // *** Do not break within emoji modifier sequences or emoji zwj sequences. ***
+
+ // GB11 \p{Extended_Pictographic} Extend* ZWJ x \p{Extended_Pictographic}
+ //
+ // Note that several parts of this rule are matched by GB9: Any x (Extend | ZWJ)
+ // - \p{Extended_Pictographic} x Extend
+ // - Extend x Extend
+ // - \p{Extended_Pictographic} x ZWJ
+ // - Extend x ZWJ
+ //
+ // So the only case left to test is
+ // - \p{Extended_Pictographic}' x ZWJ x \p{Extended_Pictographic}
+ // where \p{Extended_Pictographic}' is stored in __has_extened_pictographic
+ if (__has_extened_pictographic && __prev == __property::__ZWJ && __next == __property::__Extended_Pictographic)
+ return false;
+
+ // *** Do not break within emoji flag sequences ***
+
+ // That is, do not break between regional indicator (RI) symbols if there
+ // is an odd number of RI characters before the break point.
+
+ if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13
+ __ri_break_allowed = !__ri_break_allowed;
+ if (__ri_break_allowed)
+ return true;
+
+ return false;
+ }
+
+ // *** Otherwise, break everywhere. ***
+ return true; // GB999
+}
+
+/// Helper class to extract an extended grapheme cluster from a Unicode character range.
+///
+/// This function is used to determine the column width of an extended grapheme
+/// cluster. In order to do that only the first code point is evaluated.
+/// Therefore only this code point is extracted.
+template <class _CharT>
+class __extended_grapheme_cluster_view {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(const _CharT* __first, const _CharT* __last)
+ : __code_point_view_(__first, __last),
+ __next_code_point_(__code_point_view_.__consume()),
+ __next_prop_(__extended_grapheme_custer_property_boundary::__get_property(__next_code_point_)) {}
+
+ struct __cluster {
+ /// The first code point of the extended grapheme cluster.
+ ///
+ /// The first code point is used to estimate the width of the extended
+ /// grapheme cluster.
+ char32_t __code_point_;
+
+ /// Points one beyond the last code unit in the extended grapheme cluster.
+ ///
+ /// It's expected the caller has the start position and thus can determine
+ /// the code unit range of the extended grapheme cluster.
+ const _CharT* __last_;
+ };
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __cluster __consume() {
+ _LIBCPP_ASSERT(
+ __next_prop_ != __extended_grapheme_custer_property_boundary::__property::__eot,
+ "can't move beyond the end of input");
+ char32_t __code_point = __next_code_point_;
+ if (!__code_point_view_.__at_end())
+ return {__code_point, __get_break()};
+
+ __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot;
+ return {__code_point, __code_point_view_.__position()};
+ }
+
+private:
+ __code_point_view<_CharT> __code_point_view_;
+
+ char32_t __next_code_point_;
+ __extended_grapheme_custer_property_boundary::__property __next_prop_;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __get_break() {
+ bool __ri_break_allowed = true;
+ bool __has_extened_pictographic = false;
+ while (true) {
+ const _CharT* __result = __code_point_view_.__position();
+ __extended_grapheme_custer_property_boundary::__property __prev = __next_prop_;
+ if (__code_point_view_.__at_end()) {
+ __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot;
+ return __result;
+ }
+ __next_code_point_ = __code_point_view_.__consume();
+ __next_prop_ = __extended_grapheme_custer_property_boundary::__get_property(__next_code_point_);
+
+ __has_extened_pictographic |=
+ __prev == __extended_grapheme_custer_property_boundary::__property::__Extended_Pictographic;
+
+ if (__at_extended_grapheme_cluster_break(__ri_break_allowed, __has_extened_pictographic, __prev, __next_prop_))
+ return __result;
+ }
+ }
+};
+
+} // namespace __unicode
+
+# endif // _LIBCPP_HAS_NO_UNICODE
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_UNICODE_H
lib/libcxx/include/__functional/binary_function.h
@@ -13,19 +13,42 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
template <class _Arg1, class _Arg2, class _Result>
-struct _LIBCPP_TEMPLATE_VIS binary_function
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
};
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
+template <class _Arg1, class _Arg2, class _Result> struct __binary_function_keep_layout_base {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using first_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg1;
+ using second_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg2;
+ using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
+#endif
+};
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+template <class _Arg1, class _Arg2, class _Result>
+using __binary_function = binary_function<_Arg1, _Arg2, _Result>;
+_LIBCPP_DIAGNOSTIC_POP
+#else
+template <class _Arg1, class _Arg2, class _Result>
+using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
+#endif
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H
lib/libcxx/include/__functional/binary_negate.h
@@ -14,7 +14,7 @@
#include <__functional/binary_function.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -23,9 +23,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Predicate>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
- : public binary_function<typename _Predicate::first_argument_type,
- typename _Predicate::second_argument_type,
- bool>
+ : public __binary_function<typename _Predicate::first_argument_type,
+ typename _Predicate::second_argument_type,
+ bool>
{
_Predicate __pred_;
public:
lib/libcxx/include/__functional/bind.h
@@ -18,16 +18,16 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp>
struct is_bind_expression : _If<
- _IsSame<_Tp, typename __uncvref<_Tp>::type>::value,
+ _IsSame<_Tp, __uncvref_t<_Tp> >::value,
false_type,
- is_bind_expression<typename __uncvref<_Tp>::type>
+ is_bind_expression<__uncvref_t<_Tp> >
> {};
#if _LIBCPP_STD_VER > 14
@@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
template<class _Tp>
struct is_placeholder : _If<
- _IsSame<_Tp, typename __uncvref<_Tp>::type>::value,
+ _IsSame<_Tp, __uncvref_t<_Tp> >::value,
integral_constant<int, 0>,
- is_placeholder<typename __uncvref<_Tp>::type>
+ is_placeholder<__uncvref_t<_Tp> >
> {};
#if _LIBCPP_STD_VER > 14
@@ -264,10 +264,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
}
template<class _Fp, class ..._BoundArgs>
-class __bind
-#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public __weak_result_type<typename decay<_Fp>::type>
-#endif
+class __bind : public __weak_result_type<typename decay<_Fp>::type>
{
protected:
typedef typename decay<_Fp>::type _Fd;
lib/libcxx/include/__functional/bind_back.h
@@ -19,7 +19,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -31,12 +31,11 @@ struct __bind_back_op;
template <size_t _NBound, size_t ..._Ip>
struct __bind_back_op<_NBound, index_sequence<_Ip...>> {
- template <class _Fn, class _Bound, class ..._Args>
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Fn&& __f, _Bound&& __bound, _Args&& ...__args) const
- noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...)))
- -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...))
- { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...); }
+ template <class _Fn, class _BoundArgs, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f, _BoundArgs&& __bound_args, _Args&&... __args) const
+ noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)))
+ -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...))
+ { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...); }
};
template <class _Fn, class _BoundArgs>
lib/libcxx/include/__functional/bind_front.h
@@ -13,11 +13,11 @@
#include <__config>
#include <__functional/invoke.h>
#include <__functional/perfect_forward.h>
+#include <__utility/forward.h>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/binder1st.h
@@ -14,7 +14,7 @@
#include <__functional/unary_function.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class __Operation>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st
- : public unary_function<typename __Operation::second_argument_type,
- typename __Operation::result_type>
+ : public __unary_function<typename __Operation::second_argument_type, typename __Operation::result_type>
{
protected:
__Operation op;
lib/libcxx/include/__functional/binder2nd.h
@@ -14,7 +14,7 @@
#include <__functional/unary_function.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class __Operation>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
- : public unary_function<typename __Operation::first_argument_type,
- typename __Operation::result_type>
+ : public __unary_function<typename __Operation::first_argument_type, typename __Operation::result_type>
{
protected:
__Operation op;
lib/libcxx/include/__functional/boyer_moore_searcher.h
@@ -0,0 +1,313 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
+#define _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__algorithm/fill_n.h>
+#include <__config>
+#include <__functional/hash.h>
+#include <__functional/operations.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/shared_ptr.h>
+#include <__utility/pair.h>
+#include <array>
+#include <unordered_map>
+#include <vector>
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Key,
+ class _Value,
+ class _Hash,
+ class _BinaryPredicate,
+ bool /*useArray*/>
+class _BMSkipTable;
+
+// General case for BM data searching; use a map
+template <class _Key,
+ class _Value,
+ class _Hash,
+ class _BinaryPredicate>
+class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
+private:
+ using value_type = _Value;
+ using key_type = _Key;
+
+ const value_type __default_value_;
+ unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ explicit _BMSkipTable(size_t __sz, value_type __default_value, _Hash __hash, _BinaryPredicate __pred)
+ : __default_value_(__default_value),
+ __table_(__sz, __hash, __pred) {}
+
+ _LIBCPP_HIDE_FROM_ABI void insert(const key_type& __key, value_type __val) {
+ __table_[__key] = __val;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI value_type operator[](const key_type& __key) const {
+ auto __it = __table_.find(__key);
+ return __it == __table_.end() ? __default_value_ : __it->second;
+ }
+};
+
+// Special case small numeric values; use an array
+template <class _Key,
+ class _Value,
+ class _Hash,
+ class _BinaryPredicate>
+class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> {
+private:
+ using value_type = _Value;
+ using key_type = _Key;
+
+ using unsigned_key_type = make_unsigned_t<key_type>;
+ std::array<value_type, 256> __table_;
+ static_assert(numeric_limits<unsigned_key_type>::max() < 256);
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit _BMSkipTable(size_t, value_type __default_value, _Hash, _BinaryPredicate) {
+ std::fill_n(__table_.data(), __table_.size(), __default_value);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void insert(key_type __key, value_type __val) {
+ __table_[static_cast<unsigned_key_type>(__key)] = __val;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI value_type operator[](key_type __key) const {
+ return __table_[static_cast<unsigned_key_type>(__key)];
+ }
+};
+
+template <class _RandomAccessIterator1,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+ class _BinaryPredicate = equal_to<>>
+class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {
+private:
+ using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type;
+ using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type;
+ using __skip_table_type = _BMSkipTable<value_type,
+ difference_type,
+ _Hash,
+ _BinaryPredicate,
+ is_integral_v<value_type>
+ && sizeof(value_type) == 1
+ && is_same_v<_Hash, hash<value_type>>
+ && is_same_v<_BinaryPredicate, equal_to<>>>;
+
+public:
+ boyer_moore_searcher(_RandomAccessIterator1 __first,
+ _RandomAccessIterator1 __last,
+ _Hash __hash = _Hash(),
+ _BinaryPredicate __pred = _BinaryPredicate())
+ : __first_(__first),
+ __last_(__last),
+ __pred_(__pred),
+ __pattern_length_(__last - __first),
+ __skip_table_(std::make_shared<__skip_table_type>(__pattern_length_, -1, __hash, __pred_)),
+ __suffix_(std::__allocate_shared_unbounded_array<difference_type[]>(
+ allocator<difference_type>(), __pattern_length_ + 1)) {
+ difference_type __i = 0;
+ while (__first != __last) {
+ __skip_table_->insert(*__first, __i);
+ ++__first;
+ ++__i;
+ }
+ __build_suffix_table(__first_, __last_, __pred_);
+ }
+
+ template <class _RandomAccessIterator2>
+ pair<_RandomAccessIterator2, _RandomAccessIterator2>
+ operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
+ static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type,
+ typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
+ "Corpus and Pattern iterators must point to the same type");
+ if (__first == __last)
+ return std::make_pair(__last, __last);
+ if (__first_ == __last_)
+ return std::make_pair(__first, __first);
+
+ if (__pattern_length_ > (__last - __first))
+ return std::make_pair(__last, __last);
+ return __search(__first, __last);
+ }
+
+private:
+ _RandomAccessIterator1 __first_;
+ _RandomAccessIterator1 __last_;
+ _BinaryPredicate __pred_;
+ difference_type __pattern_length_;
+ shared_ptr<__skip_table_type> __skip_table_;
+ shared_ptr<difference_type[]> __suffix_;
+
+ template <class _RandomAccessIterator2>
+ pair<_RandomAccessIterator2, _RandomAccessIterator2>
+ __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const {
+ _RandomAccessIterator2 __current = __f;
+ const _RandomAccessIterator2 __last = __l - __pattern_length_;
+ const __skip_table_type& __skip_table = *__skip_table_;
+
+ while (__current <= __last) {
+ difference_type __j = __pattern_length_;
+ while (__pred_(__first_[__j - 1], __current[__j - 1])) {
+ --__j;
+ if (__j == 0)
+ return std::make_pair(__current, __current + __pattern_length_);
+ }
+
+ difference_type __k = __skip_table[__current[__j - 1]];
+ difference_type __m = __j - __k - 1;
+ if (__k < __j && __m > __suffix_[__j])
+ __current += __m;
+ else
+ __current += __suffix_[__j];
+ }
+ return std::make_pair(__l, __l);
+ }
+
+ template <class _Iterator, class _Container>
+ void __compute_bm_prefix(_Iterator __first, _Iterator __last, _BinaryPredicate __pred, _Container& __prefix) {
+ const size_t __count = __last - __first;
+
+ __prefix[0] = 0;
+ size_t __k = 0;
+
+ for (size_t __i = 1; __i != __count; ++__i) {
+ while (__k > 0 && !__pred(__first[__k], __first[__i]))
+ __k = __prefix[__k - 1];
+
+ if (__pred(__first[__k], __first[__i]))
+ ++__k;
+ __prefix[__i] = __k;
+ }
+ }
+
+ void __build_suffix_table(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _BinaryPredicate __pred) {
+ const size_t __count = __last - __first;
+
+ if (__count == 0)
+ return;
+
+ vector<difference_type> __scratch(__count);
+
+ __compute_bm_prefix(__first, __last, __pred, __scratch);
+ for (size_t __i = 0; __i <= __count; ++__i)
+ __suffix_[__i] = __count - __scratch[__count - 1];
+
+ using _ReverseIter = reverse_iterator<_RandomAccessIterator1>;
+ __compute_bm_prefix(_ReverseIter(__last), _ReverseIter(__first), __pred, __scratch);
+
+ for (size_t __i = 0; __i != __count; ++__i) {
+ const size_t __j = __count - __scratch[__i];
+ const difference_type __k = __i - __scratch[__i] + 1;
+
+ if (__suffix_[__j] > __k)
+ __suffix_[__j] = __k;
+ }
+ }
+};
+
+template <class _RandomAccessIterator1,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+ class _BinaryPredicate = equal_to<>>
+class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {
+private:
+ using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type;
+ using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type;
+ using __skip_table_type = _BMSkipTable<value_type,
+ difference_type,
+ _Hash,
+ _BinaryPredicate,
+ is_integral_v<value_type>
+ && sizeof(value_type) == 1
+ && is_same_v<_Hash, hash<value_type>>
+ && is_same_v<_BinaryPredicate, equal_to<>>>;
+public:
+ boyer_moore_horspool_searcher(_RandomAccessIterator1 __first,
+ _RandomAccessIterator1 __last,
+ _Hash __hash = _Hash(),
+ _BinaryPredicate __pred = _BinaryPredicate())
+ : __first_(__first),
+ __last_(__last),
+ __pred_(__pred),
+ __pattern_length_(__last - __first),
+ __skip_table_(std::make_shared<__skip_table_type>(__pattern_length_, __pattern_length_, __hash, __pred_)) {
+ if (__first == __last)
+ return;
+ --__last;
+ difference_type __i = 0;
+ while (__first != __last) {
+ __skip_table_->insert(*__first, __pattern_length_ - 1 - __i);
+ ++__first;
+ ++__i;
+ }
+ }
+
+ template <class _RandomAccessIterator2>
+ pair<_RandomAccessIterator2, _RandomAccessIterator2>
+ operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
+ static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type,
+ typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
+ "Corpus and Pattern iterators must point to the same type");
+ if (__first == __last)
+ return std::make_pair(__last, __last);
+ if (__first_ == __last_)
+ return std::make_pair(__first, __first);
+
+ if (__pattern_length_ > __last - __first)
+ return std::make_pair(__last, __last);
+
+ return __search(__first, __last);
+ }
+
+private:
+ _RandomAccessIterator1 __first_;
+ _RandomAccessIterator1 __last_;
+ _BinaryPredicate __pred_;
+ difference_type __pattern_length_;
+ shared_ptr<__skip_table_type> __skip_table_;
+
+ template <class _RandomAccessIterator2>
+ pair<_RandomAccessIterator2, _RandomAccessIterator2>
+ __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const {
+ _RandomAccessIterator2 __current = __f;
+ const _RandomAccessIterator2 __last = __l - __pattern_length_;
+ const __skip_table_type& __skip_table = *__skip_table_;
+
+ while (__current <= __last) {
+ difference_type __j = __pattern_length_;
+ while (__pred_(__first_[__j - 1], __current[__j - 1])) {
+ --__j;
+ if (__j == 0)
+ return std::make_pair(__current, __current + __pattern_length_);
+ }
+ __current += __skip_table[__current[__pattern_length_ - 1]];
+ }
+ return std::make_pair(__l, __l);
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
lib/libcxx/include/__functional/compose.h
@@ -17,7 +17,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/default_searcher.h
@@ -12,12 +12,13 @@
#include <__algorithm/search.h>
#include <__config>
+#include <__functional/identity.h>
#include <__functional/operations.h>
#include <__iterator/iterator_traits.h>
-#include <utility>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -38,16 +39,15 @@ public:
pair<_ForwardIterator2, _ForwardIterator2>
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
{
- return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
- typename iterator_traits<_ForwardIterator>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category());
+ auto __proj = __identity();
+ return std::__search_impl(__f, __l, __first_, __last_, __pred_, __proj, __proj);
}
private:
_ForwardIterator __first_;
_ForwardIterator __last_;
_BinaryPredicate __pred_;
- };
+};
#endif // _LIBCPP_STD_VER > 14
lib/libcxx/include/__functional/function.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___FUNCTIONAL_FUNCTION_H
#define _LIBCPP___FUNCTIONAL_FUNCTION_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__functional/binary_function.h>
#include <__functional/invoke.h>
#include <__functional/unary_function.h>
@@ -20,19 +20,23 @@
#include <__memory/allocator_traits.h>
#include <__memory/compressed_pair.h>
#include <__memory/shared_ptr.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <exception>
#include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
// bad_function_call
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
class _LIBCPP_EXCEPTION_ABI bad_function_call
: public exception
{
@@ -50,6 +54,7 @@ public:
virtual const char* what() const _NOEXCEPT;
#endif
};
+_LIBCPP_DIAGNOSTIC_POP
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
void __throw_bad_function_call()
@@ -80,7 +85,7 @@ struct __maybe_derive_from_unary_function
template<class _Rp, class _A1>
struct __maybe_derive_from_unary_function<_Rp(_A1)>
- : public unary_function<_A1, _Rp>
+ : public __unary_function<_A1, _Rp>
{
};
@@ -91,7 +96,7 @@ struct __maybe_derive_from_binary_function
template<class _Rp, class _A1, class _A2>
struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
+ : public __binary_function<_A1, _A2, _Rp>
{
};
@@ -385,9 +390,9 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
typedef __base<_Rp(_ArgTypes...)> __func;
__func* __f_;
- _LIBCPP_NO_CFI static __func* __as_base(void* p)
+ _LIBCPP_NO_CFI static __func* __as_base(void* __p)
{
- return reinterpret_cast<__func*>(p);
+ return reinterpret_cast<__func*>(__p);
}
public:
@@ -951,10 +956,8 @@ public:
template<class _Rp, class ..._ArgTypes>
class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
-#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
: public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
-#endif
{
#ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
typedef __function::__value_func<_Rp(_ArgTypes...)> __func;
@@ -1237,7 +1240,7 @@ void
swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
{return __x.swap(__y);}
-#else // _LIBCPP_CXX03_LANG
+#elif defined(_LIBCPP_ENABLE_CXX03_FUNCTION)
namespace __function {
@@ -2803,7 +2806,7 @@ void
swap(function<_Fp>& __x, function<_Fp>& __y)
{return __x.swap(__y);}
-#endif
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__functional/hash.h
@@ -23,7 +23,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -265,18 +265,10 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
struct __scalar_hash;
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp>
struct __scalar_hash<_Tp, 0>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<_Tp, size_t>
-#endif
+ : public __unary_function<_Tp, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(_Tp __v) const _NOEXCEPT
{
@@ -291,18 +283,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp>
struct __scalar_hash<_Tp, 1>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<_Tp, size_t>
-#endif
+ : public __unary_function<_Tp, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(_Tp __v) const _NOEXCEPT
{
@@ -316,18 +300,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp>
struct __scalar_hash<_Tp, 2>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<_Tp, size_t>
-#endif
+ : public __unary_function<_Tp, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(_Tp __v) const _NOEXCEPT
{
@@ -345,18 +321,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp>
struct __scalar_hash<_Tp, 3>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<_Tp, size_t>
-#endif
+ : public __unary_function<_Tp, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(_Tp __v) const _NOEXCEPT
{
@@ -375,18 +343,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp>
struct __scalar_hash<_Tp, 4>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<_Tp, size_t>
-#endif
+ : public __unary_function<_Tp, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(_Tp __v) const _NOEXCEPT
{
@@ -418,18 +378,10 @@ inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
return _HashT()(__p);
}
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash<_Tp*>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<_Tp*, size_t>
-#endif
+ : public __unary_function<_Tp*, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(_Tp* __v) const _NOEXCEPT
{
@@ -443,234 +395,118 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<bool>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<bool, size_t>
-#endif
+ : public __unary_function<bool, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<char, size_t>
-#endif
+ : public __unary_function<char, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef char argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<signed char>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<signed char, size_t>
-#endif
+ : public __unary_function<signed char, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef signed char argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<unsigned char, size_t>
-#endif
+ : public __unary_function<unsigned char, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned char argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
#ifndef _LIBCPP_HAS_NO_CHAR8_T
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char8_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<char8_t, size_t>
-#endif
+ : public __unary_function<char8_t, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef char8_t argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
#endif // !_LIBCPP_HAS_NO_CHAR8_T
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char16_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<char16_t, size_t>
-#endif
+ : public __unary_function<char16_t, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef char16_t argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char32_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<char32_t, size_t>
-#endif
+ : public __unary_function<char32_t, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef char32_t argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
-
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<wchar_t, size_t>
-#endif
+ : public __unary_function<wchar_t, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef wchar_t argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<short>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<short, size_t>
-#endif
+ : public __unary_function<short, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef short argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<unsigned short, size_t>
-#endif
+ : public __unary_function<unsigned short, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned short argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<int>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<int, size_t>
-#endif
+ : public __unary_function<int, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef int argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<unsigned int, size_t>
-#endif
+ : public __unary_function<unsigned int, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned int argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<long>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<long, size_t>
-#endif
+ : public __unary_function<long, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef long argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<unsigned long, size_t>
-#endif
+ : public __unary_function<unsigned long, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned long argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
@@ -781,25 +617,15 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double>
}
};
-#if _LIBCPP_STD_VER > 11
-
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp, bool = is_enum<_Tp>::value>
struct _LIBCPP_TEMPLATE_VIS __enum_hash
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<_Tp, size_t>
-#endif
+ : public __unary_function<_Tp, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(_Tp __v) const _NOEXCEPT
{
typedef typename underlying_type<_Tp>::type type;
- return hash<type>{}(static_cast<type>(__v));
+ return hash<type>()(static_cast<type>(__v));
}
};
template <class _Tp>
@@ -813,22 +639,13 @@ template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
{
};
-#endif
#if _LIBCPP_STD_VER > 14
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public unary_function<nullptr_t, size_t>
-#endif
+ : public __unary_function<nullptr_t, size_t>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef nullptr_t argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
size_t operator()(nullptr_t) const _NOEXCEPT {
return 662607004ull;
lib/libcxx/include/__functional/identity.h
@@ -11,14 +11,23 @@
#define _LIBCPP___FUNCTIONAL_IDENTITY_H
#include <__config>
-#include <utility>
+#include <__utility/forward.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+struct __identity {
+ template <class _Tp>
+ _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT {
+ return std::forward<_Tp>(__t);
+ }
+
+ using is_transparent = void;
+};
+
#if _LIBCPP_STD_VER > 17
struct identity {
lib/libcxx/include/__functional/invoke.h
@@ -11,79 +11,517 @@
#define _LIBCPP___FUNCTIONAL_INVOKE_H
#include <__config>
-#include <__functional/weak_result_type.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/apply_cv.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/is_core_convertible.h>
+#include <__type_traits/is_member_function_pointer.h>
+#include <__type_traits/is_member_object_pointer.h>
+#include <__type_traits/is_reference_wrapper.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/nat.h>
+#include <__type_traits/remove_cv.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
+// TODO: Disentangle the type traits and std::invoke properly
+
_LIBCPP_BEGIN_NAMESPACE_STD
+struct __any
+{
+ __any(...);
+};
+
+template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
+struct __member_pointer_traits_imp
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
+{
+ typedef _Class _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
+{
+ typedef _Class _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
+{
+ typedef _Class const _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
+{
+ typedef _Class const _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
+{
+ typedef _Class volatile _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
+{
+ typedef _Class volatile _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
+{
+ typedef _Class const volatile _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
+{
+ typedef _Class const volatile _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
+{
+ typedef _Class& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
+{
+ typedef _Class& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
+{
+ typedef _Class const& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
+{
+ typedef _Class const& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
+{
+ typedef _Class volatile& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
+{
+ typedef _Class volatile& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
+{
+ typedef _Class const volatile& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
+{
+ typedef _Class const volatile& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
+{
+ typedef _Class&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
+{
+ typedef _Class&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
+{
+ typedef _Class const&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
+{
+ typedef _Class const&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
+{
+ typedef _Class volatile&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
+{
+ typedef _Class volatile&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
+{
+ typedef _Class const volatile&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
+{
+ typedef _Class const volatile&& _ClassType;
+ typedef _Rp _ReturnType;
+ typedef _Rp (_FnType) (_Param..., ...);
+};
+
+template <class _Rp, class _Class>
+struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
+{
+ typedef _Class _ClassType;
+ typedef _Rp _ReturnType;
+};
+
+template <class _MP>
+struct __member_pointer_traits
+ : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
+ is_member_function_pointer<_MP>::value,
+ is_member_object_pointer<_MP>::value>
+{
+// typedef ... _ClassType;
+// typedef ... _ReturnType;
+// typedef ... _FnType;
+};
+
+template <class _DecayedFp>
+struct __member_pointer_class_type {};
+
+template <class _Ret, class _ClassType>
+struct __member_pointer_class_type<_Ret _ClassType::*> {
+ typedef _ClassType type;
+};
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type,
+ class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet1 = typename enable_if
+ <
+ is_member_function_pointer<_DecayFp>::value
+ && is_base_of<_ClassT, _DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type>
+using __enable_if_bullet2 = typename enable_if
+ <
+ is_member_function_pointer<_DecayFp>::value
+ && __is_reference_wrapper<_DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type,
+ class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet3 = typename enable_if
+ <
+ is_member_function_pointer<_DecayFp>::value
+ && !is_base_of<_ClassT, _DecayA0>::value
+ && !__is_reference_wrapper<_DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type,
+ class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet4 = typename enable_if
+ <
+ is_member_object_pointer<_DecayFp>::value
+ && is_base_of<_ClassT, _DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type>
+using __enable_if_bullet5 = typename enable_if
+ <
+ is_member_object_pointer<_DecayFp>::value
+ && __is_reference_wrapper<_DecayA0>::value
+ >::type;
+
+template <class _Fp, class _A0,
+ class _DecayFp = typename decay<_Fp>::type,
+ class _DecayA0 = typename decay<_A0>::type,
+ class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
+using __enable_if_bullet6 = typename enable_if
+ <
+ is_member_object_pointer<_DecayFp>::value
+ && !is_base_of<_ClassT, _DecayA0>::value
+ && !__is_reference_wrapper<_DecayA0>::value
+ >::type;
+
+// __invoke forward declarations
+
+// fall back - none of the bullets
+
+template <class ..._Args>
+__nat __invoke(__any, _Args&& ...__args);
+
+// bullets 1, 2 and 3
+
+template <class _Fp, class _A0, class ..._Args,
+ class = __enable_if_bullet1<_Fp, _A0> >
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR decltype((std::declval<_A0>().*std::declval<_Fp>())(std::declval<_Args>()...))
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+ _NOEXCEPT_(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
+ { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
+
+template <class _Fp, class _A0, class ..._Args,
+ class = __enable_if_bullet2<_Fp, _A0> >
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR decltype((std::declval<_A0>().get().*std::declval<_Fp>())(std::declval<_Args>()...))
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+ _NOEXCEPT_(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
+ { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
+
+template <class _Fp, class _A0, class ..._Args,
+ class = __enable_if_bullet3<_Fp, _A0> >
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR decltype(((*std::declval<_A0>()).*std::declval<_Fp>())(std::declval<_Args>()...))
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+ _NOEXCEPT_(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
+ { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
+
+// bullets 4, 5 and 6
+
+template <class _Fp, class _A0,
+ class = __enable_if_bullet4<_Fp, _A0> >
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR decltype(std::declval<_A0>().*std::declval<_Fp>())
+__invoke(_Fp&& __f, _A0&& __a0)
+ _NOEXCEPT_(noexcept(static_cast<_A0&&>(__a0).*__f))
+ { return static_cast<_A0&&>(__a0).*__f; }
+
+template <class _Fp, class _A0,
+ class = __enable_if_bullet5<_Fp, _A0> >
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR decltype(std::declval<_A0>().get().*std::declval<_Fp>())
+__invoke(_Fp&& __f, _A0&& __a0)
+ _NOEXCEPT_(noexcept(__a0.get().*__f))
+ { return __a0.get().*__f; }
+
+template <class _Fp, class _A0,
+ class = __enable_if_bullet6<_Fp, _A0> >
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR decltype((*std::declval<_A0>()).*std::declval<_Fp>())
+__invoke(_Fp&& __f, _A0&& __a0)
+ _NOEXCEPT_(noexcept((*static_cast<_A0&&>(__a0)).*__f))
+ { return (*static_cast<_A0&&>(__a0)).*__f; }
+
+// bullet 7
+
+template <class _Fp, class ..._Args>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR decltype(std::declval<_Fp>()(std::declval<_Args>()...))
+__invoke(_Fp&& __f, _Args&& ...__args)
+ _NOEXCEPT_(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
+ { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
+
+// __invokable
+template <class _Ret, class _Fp, class ..._Args>
+struct __invokable_r
+{
+ template <class _XFp, class ..._XArgs>
+ static decltype(std::__invoke(declval<_XFp>(), declval<_XArgs>()...)) __try_call(int);
+ template <class _XFp, class ..._XArgs>
+ static __nat __try_call(...);
+
+ // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
+ // or incomplete array types as required by the standard.
+ using _Result = decltype(__try_call<_Fp, _Args...>(0));
+
+ using type = typename conditional<
+ _IsNotSame<_Result, __nat>::value,
+ typename conditional< is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >::type,
+ false_type >::type;
+ static const bool value = type::value;
+};
+template <class _Fp, class ..._Args>
+using __invokable = __invokable_r<void, _Fp, _Args...>;
+
+template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
+struct __nothrow_invokable_r_imp {
+ static const bool value = false;
+};
+
+template <class _Ret, class _Fp, class ..._Args>
+struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
+{
+ typedef __nothrow_invokable_r_imp _ThisT;
+
+ template <class _Tp>
+ static void __test_noexcept(_Tp) _NOEXCEPT;
+
+ static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
+ _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
+};
+
+template <class _Ret, class _Fp, class ..._Args>
+struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
+{
+ static const bool value = noexcept(
+ _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
+};
+
+template <class _Ret, class _Fp, class ..._Args>
+using __nothrow_invokable_r =
+ __nothrow_invokable_r_imp<
+ __invokable_r<_Ret, _Fp, _Args...>::value,
+ is_void<_Ret>::value,
+ _Ret, _Fp, _Args...
+ >;
+
+template <class _Fp, class ..._Args>
+using __nothrow_invokable =
+ __nothrow_invokable_r_imp<
+ __invokable<_Fp, _Args...>::value,
+ true, void, _Fp, _Args...
+ >;
+
+template <class _Fp, class ..._Args>
+struct __invoke_of
+ : public enable_if<
+ __invokable<_Fp, _Args...>::value,
+ typename __invokable_r<void, _Fp, _Args...>::_Result>
+{
+};
+
template <class _Ret, bool = is_void<_Ret>::value>
struct __invoke_void_return_wrapper
{
-#ifndef _LIBCPP_CXX03_LANG
template <class ..._Args>
static _Ret __call(_Args&&... __args) {
- return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
- }
-#else
- template <class _Fn>
- static _Ret __call(_Fn __f) {
- return _VSTD::__invoke(__f);
+ return std::__invoke(std::forward<_Args>(__args)...);
}
-
- template <class _Fn, class _A0>
- static _Ret __call(_Fn __f, _A0& __a0) {
- return _VSTD::__invoke(__f, __a0);
- }
-
- template <class _Fn, class _A0, class _A1>
- static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
- return _VSTD::__invoke(__f, __a0, __a1);
- }
-
- template <class _Fn, class _A0, class _A1, class _A2>
- static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
- return _VSTD::__invoke(__f, __a0, __a1, __a2);
- }
-#endif
};
template <class _Ret>
struct __invoke_void_return_wrapper<_Ret, true>
{
-#ifndef _LIBCPP_CXX03_LANG
template <class ..._Args>
static void __call(_Args&&... __args) {
- _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
- }
-#else
- template <class _Fn>
- static void __call(_Fn __f) {
- _VSTD::__invoke(__f);
+ std::__invoke(std::forward<_Args>(__args)...);
}
+};
- template <class _Fn, class _A0>
- static void __call(_Fn __f, _A0& __a0) {
- _VSTD::__invoke(__f, __a0);
- }
+#if _LIBCPP_STD_VER > 14
- template <class _Fn, class _A0, class _A1>
- static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
- _VSTD::__invoke(__f, __a0, __a1);
- }
+// is_invocable
- template <class _Fn, class _A0, class _A1, class _A2>
- static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
- _VSTD::__invoke(__f, __a0, __a1, __a2);
- }
-#endif
+template <class _Fn, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_invocable
+ : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
+
+template <class _Ret, class _Fn, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_invocable_r
+ : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
+
+template <class _Fn, class ..._Args>
+inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
+
+template <class _Ret, class _Fn, class ..._Args>
+inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
+
+// is_nothrow_invocable
+
+template <class _Fn, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
+ : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
+
+template <class _Ret, class _Fn, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
+ : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
+
+template <class _Fn, class ..._Args>
+inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
+
+template <class _Ret, class _Fn, class ..._Args>
+inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
+
+template <class _Fn, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS invoke_result
+ : __invoke_of<_Fn, _Args...>
+{
};
-#if _LIBCPP_STD_VER > 14
+template <class _Fn, class... _Args>
+using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
template <class _Fn, class ..._Args>
_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
lib/libcxx/include/__functional/is_transparent.h
@@ -14,7 +14,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/mem_fn.h
@@ -14,19 +14,17 @@
#include <__functional/binary_function.h>
#include <__functional/invoke.h>
#include <__functional/weak_result_type.h>
-#include <utility>
+#include <__utility/forward.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-class __mem_fn
-#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public __weak_result_type<_Tp>
-#endif
+class __mem_fn : public __weak_result_type<_Tp>
{
public:
// types
@@ -38,114 +36,14 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
-#ifndef _LIBCPP_CXX03_LANG
// invoke
template <class... _ArgTypes>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+
typename __invoke_return<type, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
- return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
- }
-#else
-
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return0<type, _A0>::type
- operator() (_A0& __a0) const {
- return _VSTD::__invoke(__f_, __a0);
- }
-
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return0<type, _A0 const>::type
- operator() (_A0 const& __a0) const {
- return _VSTD::__invoke(__f_, __a0);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0, _A1>::type
- operator() (_A0& __a0, _A1& __a1) const {
- return _VSTD::__invoke(__f_, __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0 const, _A1>::type
- operator() (_A0 const& __a0, _A1& __a1) const {
- return _VSTD::__invoke(__f_, __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0, _A1 const>::type
- operator() (_A0& __a0, _A1 const& __a1) const {
- return _VSTD::__invoke(__f_, __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0 const, _A1 const>::type
- operator() (_A0 const& __a0, _A1 const& __a1) const {
- return _VSTD::__invoke(__f_, __a0, __a1);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1, _A2>::type
- operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);
}
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1, _A2>::type
- operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1 const, _A2>::type
- operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1, _A2 const>::type
- operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
- operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
- operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
- operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
- operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-#endif
};
template<class _Rp, class _Tp>
lib/libcxx/include/__functional/mem_fun_ref.h
@@ -15,7 +15,7 @@
#include <__functional/unary_function.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _Sp, class _Tp>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
- : public unary_function<_Tp*, _Sp>
+ : public __unary_function<_Tp*, _Sp>
{
_Sp (_Tp::*__p_)();
public:
@@ -36,7 +36,7 @@ public:
template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t
- : public binary_function<_Tp*, _Ap, _Sp>
+ : public __binary_function<_Tp*, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap);
public:
@@ -60,7 +60,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap))
template<class _Sp, class _Tp>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
- : public unary_function<_Tp, _Sp>
+ : public __unary_function<_Tp, _Sp>
{
_Sp (_Tp::*__p_)();
public:
@@ -72,7 +72,7 @@ public:
template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t
- : public binary_function<_Tp, _Ap, _Sp>
+ : public __binary_function<_Tp, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap);
public:
@@ -96,7 +96,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
template <class _Sp, class _Tp>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
- : public unary_function<const _Tp*, _Sp>
+ : public __unary_function<const _Tp*, _Sp>
{
_Sp (_Tp::*__p_)() const;
public:
@@ -108,7 +108,7 @@ public:
template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
- : public binary_function<const _Tp*, _Ap, _Sp>
+ : public __binary_function<const _Tp*, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap) const;
public:
@@ -132,7 +132,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const)
template <class _Sp, class _Tp>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
- : public unary_function<_Tp, _Sp>
+ : public __unary_function<_Tp, _Sp>
{
_Sp (_Tp::*__p_)() const;
public:
@@ -144,7 +144,7 @@ public:
template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t
- : public binary_function<_Tp, _Ap, _Sp>
+ : public __binary_function<_Tp, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap) const;
public:
lib/libcxx/include/__functional/not_fn.h
@@ -13,10 +13,11 @@
#include <__config>
#include <__functional/invoke.h>
#include <__functional/perfect_forward.h>
-#include <utility>
+#include <__utility/forward.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/operations.h
@@ -16,31 +16,22 @@
#include <__utility/forward.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
// Arithmetic operations
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS plus
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, _Tp>
-#endif
+ : __binary_function<_Tp, _Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x + __y;}
@@ -60,24 +51,15 @@ struct _LIBCPP_TEMPLATE_VIS plus<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS minus
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, _Tp>
-#endif
+ : __binary_function<_Tp, _Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x - __y;}
@@ -97,24 +79,15 @@ struct _LIBCPP_TEMPLATE_VIS minus<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS multiplies
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, _Tp>
-#endif
+ : __binary_function<_Tp, _Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x * __y;}
@@ -134,24 +107,15 @@ struct _LIBCPP_TEMPLATE_VIS multiplies<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS divides
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, _Tp>
-#endif
+ : __binary_function<_Tp, _Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x / __y;}
@@ -171,24 +135,15 @@ struct _LIBCPP_TEMPLATE_VIS divides<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS modulus
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, _Tp>
-#endif
+ : __binary_function<_Tp, _Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x % __y;}
@@ -208,23 +163,15 @@ struct _LIBCPP_TEMPLATE_VIS modulus<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS negate
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : unary_function<_Tp, _Tp>
-#endif
+ : __unary_function<_Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return -__x;}
@@ -246,24 +193,15 @@ struct _LIBCPP_TEMPLATE_VIS negate<void>
// Bitwise operations
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS bit_and
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, _Tp>
-#endif
+ : __binary_function<_Tp, _Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x & __y;}
@@ -284,18 +222,10 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void>
#endif
#if _LIBCPP_STD_VER > 11
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp = void>
struct _LIBCPP_TEMPLATE_VIS bit_not
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : unary_function<_Tp, _Tp>
-#endif
+ : __unary_function<_Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return ~__x;}
@@ -314,24 +244,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_not<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS bit_or
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, _Tp>
-#endif
+ : __binary_function<_Tp, _Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x | __y;}
@@ -351,24 +272,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_or<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS bit_xor
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, _Tp>
-#endif
+ : __binary_function<_Tp, _Tp, _Tp>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef _Tp __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x ^ __y;}
@@ -390,24 +302,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
// Comparison operations
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS equal_to
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, bool>
-#endif
+ : __binary_function<_Tp, _Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x == __y;}
@@ -427,24 +330,15 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS not_equal_to
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, bool>
-#endif
+ : __binary_function<_Tp, _Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x != __y;}
@@ -464,24 +358,15 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS less
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, bool>
-#endif
+ : __binary_function<_Tp, _Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x < __y;}
@@ -501,24 +386,15 @@ struct _LIBCPP_TEMPLATE_VIS less<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS less_equal
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, bool>
-#endif
+ : __binary_function<_Tp, _Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x <= __y;}
@@ -538,24 +414,15 @@ struct _LIBCPP_TEMPLATE_VIS less_equal<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS greater_equal
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, bool>
-#endif
+ : __binary_function<_Tp, _Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x >= __y;}
@@ -575,24 +442,15 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS greater
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, bool>
-#endif
+ : __binary_function<_Tp, _Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x > __y;}
@@ -614,24 +472,15 @@ struct _LIBCPP_TEMPLATE_VIS greater<void>
// Logical operations
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_and
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, bool>
-#endif
+ : __binary_function<_Tp, _Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x && __y;}
@@ -651,23 +500,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_and<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_not
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : unary_function<_Tp, bool>
-#endif
+ : __unary_function<_Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x) const
{return !__x;}
@@ -687,24 +528,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_not<void>
};
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_or
-#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : binary_function<_Tp, _Tp, bool>
-#endif
+ : __binary_function<_Tp, _Tp, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
typedef bool __result_type; // used by valarray
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
-#endif
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x || __y;}
lib/libcxx/include/__functional/perfect_forward.h
@@ -18,70 +18,69 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
-template <class _Op, class _Indices, class ..._Bound>
+template <class _Op, class _Indices, class... _BoundArgs>
struct __perfect_forward_impl;
-template <class _Op, size_t ..._Idx, class ..._Bound>
-struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _Bound...> {
+template <class _Op, size_t... _Idx, class... _BoundArgs>
+struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _BoundArgs...> {
private:
- tuple<_Bound...> __bound_;
+ tuple<_BoundArgs...> __bound_args_;
public:
- template <class ..._BoundArgs, class = enable_if_t<
- is_constructible_v<tuple<_Bound...>, _BoundArgs&&...>
- >>
- explicit constexpr __perfect_forward_impl(_BoundArgs&& ...__bound)
- : __bound_(_VSTD::forward<_BoundArgs>(__bound)...)
- { }
-
- __perfect_forward_impl(__perfect_forward_impl const&) = default;
- __perfect_forward_impl(__perfect_forward_impl&&) = default;
-
- __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
- __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
-
- template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound&..., _Args...>>>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &
- noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)))
- -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))
- { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound&..., _Args...>>>
- auto operator()(_Args&&...) & = delete;
-
- template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const&..., _Args...>>>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&
- noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)))
- -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))
- { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const&..., _Args...>>>
- auto operator()(_Args&&...) const& = delete;
-
- template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound..., _Args...>>>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &&
- noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)))
- -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))
- { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound..., _Args...>>>
- auto operator()(_Args&&...) && = delete;
-
- template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const..., _Args...>>>
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&&
- noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)))
- -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))
- { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const..., _Args...>>>
- auto operator()(_Args&&...) const&& = delete;
+ template <class... _Args, class = enable_if_t<
+ is_constructible_v<tuple<_BoundArgs...>, _Args&&...>
+ >>
+ explicit constexpr __perfect_forward_impl(_Args&&... __bound_args)
+ : __bound_args_(_VSTD::forward<_Args>(__bound_args)...) {}
+
+ __perfect_forward_impl(__perfect_forward_impl const&) = default;
+ __perfect_forward_impl(__perfect_forward_impl&&) = default;
+
+ __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
+ __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &
+ noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))
+ { return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...); }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
+ auto operator()(_Args&&...) & = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&
+ noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))
+ { return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...); }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
+ auto operator()(_Args&&...) const& = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) &&
+ noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))
+ { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...); }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs..., _Args...>>>
+ auto operator()(_Args&&...) && = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&&
+ noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))
+ { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...); }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
+ auto operator()(_Args&&...) const&& = delete;
};
// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].
lib/libcxx/include/__functional/pointer_to_binary_function.h
@@ -14,7 +14,7 @@
#include <__functional/binary_function.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Arg1, class _Arg2, class _Result>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function
- : public binary_function<_Arg1, _Arg2, _Result>
+ : public __binary_function<_Arg1, _Arg2, _Result>
{
_Result (*__f_)(_Arg1, _Arg2);
public:
lib/libcxx/include/__functional/pointer_to_unary_function.h
@@ -14,7 +14,7 @@
#include <__functional/unary_function.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Arg, class _Result>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function
- : public unary_function<_Arg, _Result>
+ : public __unary_function<_Arg, _Result>
{
_Result (*__f_)(_Arg);
public:
lib/libcxx/include/__functional/ranges_operations.h
@@ -11,16 +11,16 @@
#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
#include <__config>
+#include <__utility/forward.h>
#include <concepts>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -91,7 +91,8 @@ struct greater_equal {
};
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__functional/reference_wrapper.h
@@ -17,16 +17,13 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-class _LIBCPP_TEMPLATE_VIS reference_wrapper
-#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
- : public __weak_result_type<_Tp>
-#endif
+class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp>
{
public:
// types
@@ -51,120 +48,13 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
type& get() const _NOEXCEPT {return *__f_;}
-#ifndef _LIBCPP_CXX03_LANG
// invoke
template <class... _ArgTypes>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename __invoke_of<type&, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
- return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
- }
-#else
-
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return<type>::type
- operator() () const {
- return _VSTD::__invoke(get());
- }
-
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return0<type, _A0>::type
- operator() (_A0& __a0) const {
- return _VSTD::__invoke(get(), __a0);
- }
-
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return0<type, _A0 const>::type
- operator() (_A0 const& __a0) const {
- return _VSTD::__invoke(get(), __a0);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0, _A1>::type
- operator() (_A0& __a0, _A1& __a1) const {
- return _VSTD::__invoke(get(), __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0 const, _A1>::type
- operator() (_A0 const& __a0, _A1& __a1) const {
- return _VSTD::__invoke(get(), __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0, _A1 const>::type
- operator() (_A0& __a0, _A1 const& __a1) const {
- return _VSTD::__invoke(get(), __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0 const, _A1 const>::type
- operator() (_A0 const& __a0, _A1 const& __a1) const {
- return _VSTD::__invoke(get(), __a0, __a1);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1, _A2>::type
- operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1, _A2>::type
- operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1 const, _A2>::type
- operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1, _A2 const>::type
- operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
- operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
- operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
- operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
- operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
}
-#endif // _LIBCPP_CXX03_LANG
};
#if _LIBCPP_STD_VER > 14
lib/libcxx/include/__functional/unary_function.h
@@ -12,18 +12,40 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
template <class _Arg, class _Result>
-struct _LIBCPP_TEMPLATE_VIS unary_function
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function
{
typedef _Arg argument_type;
typedef _Result result_type;
};
+#endif // _LIBCPP_STD_VER <= 14
+
+template <class _Arg, class _Result> struct __unary_function_keep_layout_base {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg;
+ using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
+#endif
+};
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+template <class _Arg, class _Result>
+using __unary_function = unary_function<_Arg, _Result>;
+_LIBCPP_DIAGNOSTIC_POP
+#else
+template <class _Arg, class _Result>
+using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;
+#endif
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H
lib/libcxx/include/__functional/unary_negate.h
@@ -14,7 +14,7 @@
#include <__functional/unary_function.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Predicate>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
- : public unary_function<typename _Predicate::argument_type, bool>
+ : public __unary_function<typename _Predicate::argument_type, bool>
{
_Predicate __pred_;
public:
lib/libcxx/include/__functional/unwrap_ref.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional/weak_result_type.h
@@ -16,7 +16,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -25,11 +25,10 @@ template <class _Tp>
struct __has_result_type
{
private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename _Up::result_type* = 0);
+ template <class _Up> static false_type __test(...);
+ template <class _Up> static true_type __test(typename _Up::result_type* = 0);
public:
- static const bool value = sizeof(__test<_Tp>(0)) == 1;
+ static const bool value = decltype(__test<_Tp>(0))::value;
};
// __weak_result_type
@@ -41,8 +40,9 @@ private:
struct __two {char __lx; char __lxx;};
static __two __test(...);
template <class _Ap, class _Rp>
- static unary_function<_Ap, _Rp>
- __test(const volatile unary_function<_Ap, _Rp>*);
+ static __unary_function<_Ap, _Rp>
+ __test(const volatile __unary_function<_Ap, _Rp>*);
+
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
@@ -55,8 +55,9 @@ private:
struct __two {char __lx; char __lxx;};
static __two __test(...);
template <class _A1, class _A2, class _Rp>
- static binary_function<_A1, _A2, _Rp>
- __test(const volatile binary_function<_A1, _A2, _Rp>*);
+ static __binary_function<_A1, _A2, _Rp>
+ __test(const volatile __binary_function<_A1, _A2, _Rp>*);
+
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
@@ -89,7 +90,9 @@ struct __weak_result_type_imp // bool is true
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp>
{
- typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = typename _Tp::result_type;
+#endif
};
template <class _Tp>
@@ -110,62 +113,68 @@ struct __weak_result_type
template <class _Rp>
struct __weak_result_type<_Rp ()>
{
- typedef _LIBCPP_NODEBUG _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Rp>
struct __weak_result_type<_Rp (&)()>
{
- typedef _LIBCPP_NODEBUG _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Rp>
struct __weak_result_type<_Rp (*)()>
{
- typedef _LIBCPP_NODEBUG _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
// 1 argument case
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (_A1)>
- : public unary_function<_A1, _Rp>
+ : public __unary_function<_A1, _Rp>
{
};
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (&)(_A1)>
- : public unary_function<_A1, _Rp>
+ : public __unary_function<_A1, _Rp>
{
};
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (*)(_A1)>
- : public unary_function<_A1, _Rp>
+ : public __unary_function<_A1, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)()>
- : public unary_function<_Cp*, _Rp>
+ : public __unary_function<_Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() const>
- : public unary_function<const _Cp*, _Rp>
+ : public __unary_function<const _Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() volatile>
- : public unary_function<volatile _Cp*, _Rp>
+ : public __unary_function<volatile _Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() const volatile>
- : public unary_function<const volatile _Cp*, _Rp>
+ : public __unary_function<const volatile _Cp*, _Rp>
{
};
@@ -173,90 +182,102 @@ struct __weak_result_type<_Rp (_Cp::*)() const volatile>
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
+ : public __binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (*)(_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
+ : public __binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (&)(_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
+ : public __binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1)>
- : public binary_function<_Cp*, _A1, _Rp>
+ : public __binary_function<_Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
- : public binary_function<const _Cp*, _A1, _Rp>
+ : public __binary_function<const _Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
- : public binary_function<volatile _Cp*, _A1, _Rp>
+ : public __binary_function<volatile _Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
- : public binary_function<const volatile _Cp*, _A1, _Rp>
+ : public __binary_function<const volatile _Cp*, _A1, _Rp>
{
};
-
-#ifndef _LIBCPP_CXX03_LANG
// 3 or more arguments
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
{
- typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
{
- typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
{
- typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
{
- typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
{
- typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
{
- typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
{
- typedef _Rp result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
};
template <class _Tp, class ..._Args>
@@ -265,217 +286,6 @@ struct __invoke_return
typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
};
-#else // defined(_LIBCPP_CXX03_LANG)
-
-template <class _Ret, class _T1, bool _IsFunc, bool _IsBase>
-struct __enable_invoke_imp;
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, true, true> {
- typedef _Ret _Bullet1;
- typedef _Bullet1 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, true, false> {
- typedef _Ret _Bullet2;
- typedef _Bullet2 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, false, true> {
- typedef typename add_lvalue_reference<
- typename __apply_cv<_T1, _Ret>::type
- >::type _Bullet3;
- typedef _Bullet3 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, false, false> {
- typedef typename add_lvalue_reference<
- typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type
- >::type _Bullet4;
- typedef _Bullet4 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1*, false, false> {
- typedef typename add_lvalue_reference<
- typename __apply_cv<_T1, _Ret>::type
- >::type _Bullet4;
- typedef _Bullet4 type;
-};
-
-template <class _Fn, class _T1,
- class _Traits = __member_pointer_traits<_Fn>,
- class _Ret = typename _Traits::_ReturnType,
- class _Class = typename _Traits::_ClassType>
-struct __enable_invoke : __enable_invoke_imp<
- _Ret, _T1,
- is_member_function_pointer<_Fn>::value,
- is_base_of<_Class, typename remove_reference<_T1>::type>::value>
-{
-};
-
-__nat __invoke(__any, ...);
-
-// first bullet
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1) {
- return (__t1.*__f)();
-}
-
-template <class _Fn, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
- return (__t1.*__f)(__a0);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
- return (__t1.*__f)(__a0, __a1);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
- return (__t1.*__f)(__a0, __a1, __a2);
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1) {
- return ((*__t1).*__f)();
-}
-
-template <class _Fn, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
- return ((*__t1).*__f)(__a0);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
- return ((*__t1).*__f)(__a0, __a1);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
- return ((*__t1).*__f)(__a0, __a1, __a2);
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet3
-__invoke(_Fn __f, _T1& __t1) {
- return __t1.*__f;
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet4
-__invoke(_Fn __f, _T1& __t1) {
- return (*__t1).*__f;
-}
-
-// fifth bullet
-
-template <class _Fp>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()())
-__invoke(_Fp& __f)
-{
- return __f();
-}
-
-template <class _Fp, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>()))
-__invoke(_Fp& __f, _A0& __a0)
-{
- return __f(__a0);
-}
-
-template <class _Fp, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>()))
-__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
-{
- return __f(__a0, __a1);
-}
-
-template <class _Fp, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
-__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
-{
- return __f(__a0, __a1, __a2);
-}
-
-template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value>
-struct __invoke_return
-{
- typedef typename __weak_result_type<_Fp>::result_type type;
-};
-
-template <class _Fp>
-struct __invoke_return<_Fp, false>
-{
- typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type;
-};
-
-template <class _Tp, class _A0>
-struct __invoke_return0
-{
- typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type;
-};
-
-template <class _Rp, class _Tp, class _A0>
-struct __invoke_return0<_Rp _Tp::*, _A0>
-{
- typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type;
-};
-
-template <class _Tp, class _A0, class _A1>
-struct __invoke_return1
-{
- typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
- declval<_A1&>())) type;
-};
-
-template <class _Rp, class _Class, class _A0, class _A1>
-struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
- typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type;
-};
-
-template <class _Tp, class _A0, class _A1, class _A2>
-struct __invoke_return2
-{
- typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
- declval<_A1&>(),
- declval<_A2&>())) type;
-};
-
-template <class _Ret, class _Class, class _A0, class _A1, class _A2>
-struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> {
- typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type;
-};
-
-#endif // !defined(_LIBCPP_CXX03_LANG)
-
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H
lib/libcxx/include/__fwd/span.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===---------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FWD_SPAN_H
+#define _LIBCPP_FWD_SPAN_H
+
+#include <__config>
+#include <cstddef>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
+template <typename _Tp, size_t _Extent = dynamic_extent> class span;
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_FWD_SPAN_H
lib/libcxx/include/__fwd/string_view.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===---------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FWD_STRING_VIEW_H
+#define _LIBCPP_FWD_STRING_VIEW_H
+
+#include <__config>
+#include <iosfwd> // char_traits
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _CharT, class _Traits = char_traits<_CharT> >
+class _LIBCPP_TEMPLATE_VIS basic_string_view;
+
+typedef basic_string_view<char> string_view;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+typedef basic_string_view<char8_t> u8string_view;
+#endif
+typedef basic_string_view<char16_t> u16string_view;
+typedef basic_string_view<char32_t> u32string_view;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+typedef basic_string_view<wchar_t> wstring_view;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_FWD_STRING_VIEW_H
lib/libcxx/include/__ios/fpos.h
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___IOS_FPOS_H
+#define _LIBCPP___IOS_FPOS_H
+
+#include <__config>
+#include <iosfwd>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _StateT>
+class _LIBCPP_TEMPLATE_VIS fpos {
+private:
+ _StateT __st_;
+ streamoff __off_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
+
+ _LIBCPP_HIDE_FROM_ABI operator streamoff() const { return __off_; }
+
+ _LIBCPP_HIDE_FROM_ABI _StateT state() const { return __st_; }
+ _LIBCPP_HIDE_FROM_ABI void state(_StateT __st) { __st_ = __st; }
+
+ _LIBCPP_HIDE_FROM_ABI fpos& operator+=(streamoff __off) {
+ __off_ += __off;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const {
+ fpos __t(*this);
+ __t += __off;
+ return __t;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI fpos& operator-=(streamoff __off) {
+ __off_ -= __off;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI fpos operator-(streamoff __off) const {
+ fpos __t(*this);
+ __t -= __off;
+ return __t;
+ }
+};
+
+template <class _StateT>
+inline _LIBCPP_HIDE_FROM_ABI
+streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
+ return streamoff(__x) - streamoff(__y);
+}
+
+template <class _StateT>
+inline _LIBCPP_HIDE_FROM_ABI
+bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
+ return streamoff(__x) == streamoff(__y);
+}
+
+template <class _StateT>
+inline _LIBCPP_HIDE_FROM_ABI
+bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
+ return streamoff(__x) != streamoff(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___IOS_FPOS_H
lib/libcxx/include/__iterator/access.h
@@ -14,7 +14,7 @@
#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/advance.h
@@ -10,19 +10,20 @@
#ifndef _LIBCPP___ITERATOR_ADVANCE_H
#define _LIBCPP___ITERATOR_ADVANCE_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
+#include <__utility/unreachable.h>
#include <concepts>
#include <cstdlib>
#include <limits>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -64,7 +65,7 @@ void advance(_InputIter& __i, _Distance __orig_n) {
_VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
}
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// [range.iter.op.advance]
@@ -116,47 +117,46 @@ public:
}
}
- // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range.
+ // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound_sentinel) denotes a range.
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
- _LIBCPP_HIDE_FROM_ABI
- constexpr void operator()(_Ip& __i, _Sp __bound) const {
- // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`.
+ _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, _Sp __bound_sentinel) const {
+ // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound_sentinel)`.
if constexpr (assignable_from<_Ip&, _Sp>) {
- __i = _VSTD::move(__bound);
+ __i = _VSTD::move(__bound_sentinel);
}
- // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`.
+ // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound_sentinel - i)`.
else if constexpr (sized_sentinel_for<_Sp, _Ip>) {
- (*this)(__i, __bound - __i);
+ (*this)(__i, __bound_sentinel - __i);
}
- // Otherwise, while `bool(i != bound)` is true, increments `i`.
+ // Otherwise, while `bool(i != bound_sentinel)` is true, increments `i`.
else {
- while (__i != __bound) {
+ while (__i != __bound_sentinel) {
++__i;
}
}
}
// Preconditions:
- // * If `n > 0`, [i, bound) denotes a range.
- // * If `n == 0`, [i, bound) or [bound, i) denotes a range.
- // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.
- // Returns: `n - M`, where `M` is the difference between the the ending and starting position.
+ // * If `n > 0`, [i, bound_sentinel) denotes a range.
+ // * If `n == 0`, [i, bound_sentinel) or [bound_sentinel, i) denotes a range.
+ // * If `n < 0`, [bound_sentinel, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.
+ // Returns: `n - M`, where `M` is the difference between the ending and starting position.
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
- _LIBCPP_HIDE_FROM_ABI
- constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound) const {
+ _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n,
+ _Sp __bound_sentinel) const {
_LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>),
"If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true.");
// If `S` and `I` model `sized_sentinel_for<S, I>`:
if constexpr (sized_sentinel_for<_Sp, _Ip>) {
- // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`.
+ // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`.
// __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign.
auto __magnitude_geq = [](auto __a, auto __b) {
return __a == 0 ? __b == 0 :
__a > 0 ? __a >= __b :
__a <= __b;
};
- if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) {
- (*this)(__i, __bound);
+ if (const auto __M = __bound_sentinel - __i; __magnitude_geq(__n, __M)) {
+ (*this)(__i, __bound_sentinel);
return __n - __M;
}
@@ -164,16 +164,16 @@ public:
(*this)(__i, __n);
return 0;
} else {
- // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at
+ // Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at
// most `n` times.
- while (__i != __bound && __n > 0) {
+ while (__i != __bound_sentinel && __n > 0) {
++__i;
--__n;
}
- // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times.
+ // Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times.
if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) {
- while (__i != __bound && __n < 0) {
+ while (__i != __bound_sentinel && __n < 0) {
--__i;
++__n;
}
@@ -181,7 +181,7 @@ public:
return __n;
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
};
@@ -192,7 +192,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/back_insert_iterator.h
@@ -18,7 +18,7 @@
#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -46,15 +46,17 @@ public:
typedef _Container container_type;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_)
- {container->push_back(__value_); return *this;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value)
+ {container->push_back(__value); return *this;}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_)
- {container->push_back(_VSTD::move(__value_)); return *this;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value)
+ {container->push_back(_VSTD::move(__value)); return *this;}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Container* __get_container() const { return container; }
};
template <class _Container>
lib/libcxx/include/__iterator/bounded_iter.h
@@ -0,0 +1,229 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_BOUNDED_ITER_H
+#define _LIBCPP___ITERATOR_BOUNDED_ITER_H
+
+#include <__assert>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__memory/pointer_traits.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Iterator wrapper that carries the valid range it is allowed to access.
+//
+// This is a simple iterator wrapper for contiguous iterators that points
+// within a [begin, end) range and carries these bounds with it. The iterator
+// ensures that it is pointing within that [begin, end) range when it is
+// dereferenced.
+//
+// Arithmetic operations are allowed and the bounds of the resulting iterator
+// are not checked. Hence, it is possible to create an iterator pointing outside
+// its range, but it is not possible to dereference it.
+template <class _Iterator, class = __enable_if_t< __is_cpp17_contiguous_iterator<_Iterator>::value > >
+struct __bounded_iter {
+ using value_type = typename iterator_traits<_Iterator>::value_type;
+ using difference_type = typename iterator_traits<_Iterator>::difference_type;
+ using pointer = typename iterator_traits<_Iterator>::pointer;
+ using reference = typename iterator_traits<_Iterator>::reference;
+ using iterator_category = typename iterator_traits<_Iterator>::iterator_category;
+#if _LIBCPP_STD_VER > 17
+ using iterator_concept = contiguous_iterator_tag;
+#endif
+
+ // Create a singular iterator.
+ //
+ // Such an iterator does not point to any object and is conceptually out of bounds, so it is
+ // not dereferenceable. Observing operations like comparison and assignment are valid.
+ _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default;
+
+ _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default;
+ _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default;
+
+ template <class _OtherIterator, class = __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value > >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT
+ : __current_(__other.__current_),
+ __begin_(__other.__begin_),
+ __end_(__other.__end_) {}
+
+ // Assign a bounded iterator to another one, rebinding the bounds of the iterator as well.
+ _LIBCPP_HIDE_FROM_ABI __bounded_iter& operator=(__bounded_iter const&) = default;
+ _LIBCPP_HIDE_FROM_ABI __bounded_iter& operator=(__bounded_iter&&) = default;
+
+private:
+ // Create an iterator wrapping the given iterator, and whose bounds are described
+ // by the provided [begin, end) range.
+ //
+ // This constructor does not check whether the resulting iterator is within its bounds.
+ // However, it does check that the provided [begin, end) range is a valid range (that
+ // is, begin <= end).
+ //
+ // Since it is non-standard for iterators to have this constructor, __bounded_iter must
+ // be created via `std::__make_bounded_iter`.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __bounded_iter(
+ _Iterator __current, _Iterator __begin, _Iterator __end)
+ : __current_(__current), __begin_(__begin), __end_(__end) {
+ _LIBCPP_ASSERT(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range");
+ }
+
+ template <class _It>
+ friend _LIBCPP_CONSTEXPR __bounded_iter<_It> __make_bounded_iter(_It, _It, _It);
+
+public:
+ // Dereference and indexing operations.
+ //
+ // These operations check that the iterator is dereferenceable, that is within [begin, end).
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT {
+ _LIBCPP_ASSERT(
+ __in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator");
+ return *__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT {
+ _LIBCPP_ASSERT(
+ __in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator");
+ return std::__to_address(__current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT {
+ _LIBCPP_ASSERT(
+ __in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range");
+ return __current_[__n];
+ }
+
+ // Arithmetic operations.
+ //
+ // These operations do not check that the resulting iterator is within the bounds, since that
+ // would make it impossible to create a past-the-end iterator.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator++() _NOEXCEPT {
+ ++__current_;
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator++(int) _NOEXCEPT {
+ __bounded_iter __tmp(*this);
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator--() _NOEXCEPT {
+ --__current_;
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator--(int) _NOEXCEPT {
+ __bounded_iter __tmp(*this);
+ --*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT {
+ __current_ += __n;
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
+ operator+(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
+ __bounded_iter __tmp(__self);
+ __tmp += __n;
+ return __tmp;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
+ operator+(difference_type __n, __bounded_iter const& __self) _NOEXCEPT {
+ __bounded_iter __tmp(__self);
+ __tmp += __n;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT {
+ __current_ -= __n;
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
+ operator-(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
+ __bounded_iter __tmp(__self);
+ __tmp -= __n;
+ return __tmp;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend difference_type
+ operator-(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
+ return __x.__current_ - __y.__current_;
+ }
+
+ // Comparison operations.
+ //
+ // These operations do not check whether the iterators are within their bounds.
+ // The valid range for each iterator is also not considered as part of the comparison,
+ // i.e. two iterators pointing to the same location will be considered equal even
+ // if they have different validity ranges.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
+ operator==(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
+ return __x.__current_ == __y.__current_;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
+ operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
+ return __x.__current_ != __y.__current_;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
+ operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
+ return __x.__current_ < __y.__current_;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
+ operator>(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
+ return __x.__current_ > __y.__current_;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
+ operator<=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
+ return __x.__current_ <= __y.__current_;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
+ operator>=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
+ return __x.__current_ >= __y.__current_;
+ }
+
+private:
+ // Return whether the given iterator is in the bounds of this __bounded_iter.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Iterator const& __iter) const {
+ return __iter >= __begin_ && __iter < __end_;
+ }
+
+ template <class>
+ friend struct pointer_traits;
+ _Iterator __current_; // current iterator
+ _Iterator __begin_, __end_; // valid range represented as [begin, end)
+};
+
+template <class _It>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter<_It> __make_bounded_iter(_It __it, _It __begin, _It __end) {
+ return __bounded_iter<_It>(std::move(__it), std::move(__begin), std::move(__end));
+}
+
+#if _LIBCPP_STD_VER <= 17
+template <class _Iterator>
+struct __is_cpp17_contiguous_iterator<__bounded_iter<_Iterator> > : true_type {};
+#endif
+
+template <class _Iterator>
+struct pointer_traits<__bounded_iter<_Iterator> > {
+ using pointer = __bounded_iter<_Iterator>;
+ using element_type = typename pointer_traits<_Iterator>::element_type;
+ using difference_type = typename pointer_traits<_Iterator>::difference_type;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __it) _NOEXCEPT {
+ return std::__to_address(__it.__current_);
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_BOUNDED_ITER_H
lib/libcxx/include/__iterator/common_iterator.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ITERATOR_COMMON_ITERATOR_H
#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iter_move.h>
@@ -22,12 +22,12 @@
#include <variant>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template<class _Iter>
concept __can_use_postfix_proxy =
@@ -37,31 +37,18 @@ concept __can_use_postfix_proxy =
template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>
requires (!same_as<_Iter, _Sent> && copyable<_Iter>)
class common_iterator {
- class __proxy {
- friend common_iterator;
-
- iter_value_t<_Iter> __value;
- // We can move __x because the only caller verifies that __x is not a reference.
- constexpr __proxy(iter_reference_t<_Iter>&& __x)
- : __value(_VSTD::move(__x)) {}
-
- public:
+ struct __proxy {
constexpr const iter_value_t<_Iter>* operator->() const noexcept {
- return _VSTD::addressof(__value);
+ return _VSTD::addressof(__value_);
}
+ iter_value_t<_Iter> __value_;
};
- class __postfix_proxy {
- friend common_iterator;
-
- iter_value_t<_Iter> __value;
- constexpr __postfix_proxy(iter_reference_t<_Iter>&& __x)
- : __value(_VSTD::forward<iter_reference_t<_Iter>>(__x)) {}
-
- public:
+ struct __postfix_proxy {
constexpr const iter_value_t<_Iter>& operator*() const noexcept {
- return __value;
+ return __value_;
}
+ iter_value_t<_Iter> __value_;
};
public:
@@ -133,7 +120,7 @@ public:
auto&& __tmp = *_VSTD::__unchecked_get<_Iter>(__hold_);
return _VSTD::addressof(__tmp);
} else {
- return __proxy(*_VSTD::__unchecked_get<_Iter>(__hold_));
+ return __proxy{*_VSTD::__unchecked_get<_Iter>(__hold_)};
}
}
@@ -148,11 +135,11 @@ public:
auto __tmp = *this;
++*this;
return __tmp;
- } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } ||
+ } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __can_reference; } ||
!__can_use_postfix_proxy<_Iter>) {
return _VSTD::__unchecked_get<_Iter>(__hold_)++;
} else {
- __postfix_proxy __p(**this);
+ auto __p = __postfix_proxy{**this};
++*this;
return __p;
}
@@ -276,7 +263,7 @@ struct iterator_traits<common_iterator<_Iter, _Sent>> {
using reference = iter_reference_t<_Iter>;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/concepts.h
@@ -21,12 +21,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [iterator.concept.readable]
template<class _In>
@@ -90,7 +90,7 @@ concept incrementable =
template<class _Ip>
concept input_or_output_iterator =
requires(_Ip __i) {
- { *__i } -> __referenceable;
+ { *__i } -> __can_reference;
} &&
weakly_incrementable<_Ip>;
@@ -254,10 +254,26 @@ concept indirectly_movable_storable =
constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>> &&
assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>;
+template<class _In, class _Out>
+concept indirectly_copyable =
+ indirectly_readable<_In> &&
+ indirectly_writable<_Out, iter_reference_t<_In>>;
+
+template<class _In, class _Out>
+concept indirectly_copyable_storable =
+ indirectly_copyable<_In, _Out> &&
+ indirectly_writable<_Out, iter_value_t<_In>&> &&
+ indirectly_writable<_Out, const iter_value_t<_In>&> &&
+ indirectly_writable<_Out, iter_value_t<_In>&&> &&
+ indirectly_writable<_Out, const iter_value_t<_In>&&> &&
+ copyable<iter_value_t<_In>> &&
+ constructible_from<iter_value_t<_In>, iter_reference_t<_In>> &&
+ assignable_from<iter_value_t<_In>&, iter_reference_t<_In>>;
+
// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle
// (both iter_swap and indirectly_swappable require indirectly_readable).
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/counted_iterator.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/default_sentinel.h>
#include <__iterator/incrementable_traits.h>
@@ -25,12 +25,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template<class>
struct __counted_iterator_concept {};
@@ -65,7 +65,7 @@ class counted_iterator
, public __counted_iterator_value_type<_Iter>
{
public:
- [[no_unique_address]] _Iter __current_ = _Iter();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Iter __current_ = _Iter();
iter_difference_t<_Iter> __count_ = 0;
using iterator_type = _Iter;
@@ -296,7 +296,7 @@ struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> {
add_pointer_t<iter_reference_t<_Iter>>, void>;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/data.h
@@ -15,7 +15,7 @@
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/default_sentinel.h
@@ -13,17 +13,17 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
struct default_sentinel_t { };
inline constexpr default_sentinel_t default_sentinel{};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/distance.h
@@ -20,7 +20,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -52,7 +52,7 @@ distance(_InputIter __first, _InputIter __last)
return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
}
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// [range.iter.op.distance]
@@ -100,7 +100,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/empty.h
@@ -15,7 +15,7 @@
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/erase_if_container.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/front_insert_iterator.h
@@ -18,7 +18,7 @@
#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -46,11 +46,11 @@ public:
typedef _Container container_type;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_)
- {container->push_front(__value_); return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value)
+ {container->push_front(__value); return *this;}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_)
- {container->push_front(_VSTD::move(__value_)); return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value)
+ {container->push_front(_VSTD::move(__value)); return *this;}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;}
lib/libcxx/include/__iterator/incrementable_traits.h
@@ -11,16 +11,17 @@
#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
#include <__config>
+#include <__type_traits/is_primary_template.h>
#include <concepts>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [incrementable.traits]
template<class> struct incrementable_traits {};
@@ -65,7 +66,7 @@ using iter_difference_t = typename conditional_t<__is_primary_template<iterator_
incrementable_traits<remove_cvref_t<_Ip> >,
iterator_traits<remove_cvref_t<_Ip> > >::difference_type;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/indirectly_comparable.h
@@ -15,15 +15,19 @@
#include <__iterator/concepts.h>
#include <__iterator/projected.h>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <class _I1, class _I2, class _Rp, class _P1 = identity, class _P2 = identity>
concept indirectly_comparable =
indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/insert_iterator.h
@@ -19,12 +19,12 @@
#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
template <class _Container>
using __insert_iterator_iter_t = ranges::iterator_t<_Container>;
#else
@@ -57,11 +57,11 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i)
: container(_VSTD::addressof(__x)), iter(__i) {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_)
- {iter = container->insert(iter, __value_); ++iter; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value)
+ {iter = container->insert(iter, __value); ++iter; return *this;}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_)
- {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value)
+ {iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;}
lib/libcxx/include/__iterator/istream_iterator.h
@@ -11,13 +11,15 @@
#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H
#include <__config>
+#include <__iterator/default_sentinel.h>
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
+#include <cstddef>
#include <iosfwd> // for forward declarations of char_traits and basic_istream
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -45,6 +47,9 @@ private:
_Tp __value_;
public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_HIDE_FROM_ABI constexpr istream_iterator(default_sentinel_t) : istream_iterator() {}
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
{
if (!(*__in_stream_ >> __value_))
@@ -67,6 +72,12 @@ public:
bool
operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
+
+#if _LIBCPP_STD_VER > 17
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istream_iterator& __i, default_sentinel_t) {
+ return __i.__in_stream_ == nullptr;
+ }
+#endif // _LIBCPP_STD_VER > 17
};
template <class _Tp, class _CharT, class _Traits, class _Distance>
@@ -78,6 +89,7 @@ operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
return __x.__in_stream_ == __y.__in_stream_;
}
+#if _LIBCPP_STD_VER <= 17
template <class _Tp, class _CharT, class _Traits, class _Distance>
inline _LIBCPP_INLINE_VISIBILITY
bool
@@ -86,6 +98,7 @@ operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
{
return !(__x == __y);
}
+#endif // _LIBCPP_STD_VER <= 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/istreambuf_iterator.h
@@ -11,12 +11,13 @@
#define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H
#include <__config>
+#include <__iterator/default_sentinel.h>
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
#include <iosfwd> // for forward declaration of basic_streambuf
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -49,7 +50,8 @@ private:
{
char_type __keep_;
streambuf_type* __sbuf_;
- _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s)
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __proxy(char_type __c, streambuf_type* __s)
: __keep_(__c), __sbuf_(__s) {}
friend class istreambuf_iterator;
public:
@@ -65,6 +67,10 @@ private:
}
public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY constexpr istreambuf_iterator(default_sentinel_t) noexcept
+ : istreambuf_iterator() {}
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
: __sbuf_(__s.rdbuf()) {}
_LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
@@ -86,6 +92,12 @@ public:
_LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const
{return __test_for_eof() == __b.__test_for_eof();}
+
+#if _LIBCPP_STD_VER > 17
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istreambuf_iterator& __i, default_sentinel_t) {
+ return __i.__test_for_eof();
+ }
+#endif // _LIBCPP_STD_VER > 17
};
template <class _CharT, class _Traits>
@@ -94,11 +106,13 @@ bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
const istreambuf_iterator<_CharT,_Traits>& __b)
{return __a.equal(__b);}
+#if _LIBCPP_STD_VER <= 17
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,
const istreambuf_iterator<_CharT,_Traits>& __b)
{return !__a.equal(__b);}
+#endif // _LIBCPP_STD_VER <= 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/iter_move.h
@@ -10,20 +10,20 @@
#ifndef _LIBCPP___ITERATOR_ITER_MOVE_H
#define _LIBCPP___ITERATOR_ITER_MOVE_H
+#include <__concepts/class_or_enum.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/forward.h>
-#include <concepts> // __class_or_enum
+#include <__utility/move.h>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [iterator.cust.move]
@@ -36,44 +36,50 @@ template <class _Tp>
concept __unqualified_iter_move =
__class_or_enum<remove_cvref_t<_Tp>> &&
requires (_Tp&& __t) {
- iter_move(_VSTD::forward<_Tp>(__t));
+ iter_move(std::forward<_Tp>(__t));
};
-// [iterator.cust.move]/1
-// The name ranges::iter_move denotes a customization point object.
-// The expression ranges::iter_move(E) for a subexpression E is
-// expression-equivalent to:
+template<class _Tp>
+concept __move_deref =
+ !__unqualified_iter_move<_Tp> &&
+ requires (_Tp&& __t) {
+ *__t;
+ requires is_lvalue_reference_v<decltype(*__t)>;
+ };
+
+template<class _Tp>
+concept __just_deref =
+ !__unqualified_iter_move<_Tp> &&
+ !__move_deref<_Tp> &&
+ requires (_Tp&& __t) {
+ *__t;
+ requires (!is_lvalue_reference_v<decltype(*__t)>);
+ };
+
+// [iterator.cust.move]
+
struct __fn {
- // [iterator.cust.move]/1.1
- // iter_move(E), if E has class or enumeration type and iter_move(E) is a
- // well-formed expression when treated as an unevaluated operand, [...]
template<class _Ip>
- requires __class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>
+ requires __unqualified_iter_move<_Ip>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
- noexcept(noexcept(iter_move(_VSTD::forward<_Ip>(__i))))
+ noexcept(noexcept(iter_move(std::forward<_Ip>(__i))))
{
- return iter_move(_VSTD::forward<_Ip>(__i));
+ return iter_move(std::forward<_Ip>(__i));
}
- // [iterator.cust.move]/1.2
- // Otherwise, if the expression *E is well-formed:
- // 1.2.1 if *E is an lvalue, std::move(*E);
- // 1.2.2 otherwise, *E.
template<class _Ip>
- requires (!(__class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>)) &&
- requires(_Ip&& __i) { *_VSTD::forward<_Ip>(__i); }
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
- noexcept(noexcept(*_VSTD::forward<_Ip>(__i)))
- {
- if constexpr (is_lvalue_reference_v<decltype(*_VSTD::forward<_Ip>(__i))>) {
- return _VSTD::move(*_VSTD::forward<_Ip>(__i));
- } else {
- return *_VSTD::forward<_Ip>(__i);
- }
- }
+ requires __move_deref<_Ip>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const
+ noexcept(noexcept(std::move(*std::forward<_Ip>(__i))))
+ -> decltype( std::move(*std::forward<_Ip>(__i)))
+ { return std::move(*std::forward<_Ip>(__i)); }
- // [iterator.cust.move]/1.3
- // Otherwise, ranges::iter_move(E) is ill-formed.
+ template<class _Ip>
+ requires __just_deref<_Ip>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const
+ noexcept(noexcept(*std::forward<_Ip>(__i)))
+ -> decltype( *std::forward<_Ip>(__i))
+ { return *std::forward<_Ip>(__i); }
};
} // namespace __iter_move
@@ -83,10 +89,10 @@ inline namespace __cpo {
} // namespace ranges
template<__dereferenceable _Tp>
- requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; }
+ requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; }
using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>()));
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/iter_swap.h
@@ -20,12 +20,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [iter.cust.swap]
@@ -99,7 +99,7 @@ concept indirectly_swappable =
ranges::iter_swap(__i2, __i1);
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/iterator.h
@@ -14,7 +14,7 @@
#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/iterator_traits.h
@@ -17,31 +17,31 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <class _Tp>
using __with_reference = _Tp&;
template <class _Tp>
-concept __referenceable = requires {
+concept __can_reference = requires {
typename __with_reference<_Tp>;
};
template <class _Tp>
concept __dereferenceable = requires(_Tp& __t) {
- { *__t } -> __referenceable; // not required to be equality-preserving
+ { *__t } -> __can_reference; // not required to be equality-preserving
};
// [iterator.traits]
template<__dereferenceable _Tp>
using iter_reference_t = decltype(*declval<_Tp&>());
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
template <class _Iter>
struct _LIBCPP_TEMPLATE_VIS iterator_traits;
@@ -105,15 +105,14 @@ template <class _Tp>
struct __has_iterator_typedefs
{
private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0,
- typename __void_t<typename _Up::difference_type>::type* = 0,
- typename __void_t<typename _Up::value_type>::type* = 0,
- typename __void_t<typename _Up::reference>::type* = 0,
- typename __void_t<typename _Up::pointer>::type* = 0);
+ template <class _Up> static false_type __test(...);
+ template <class _Up> static true_type __test(typename __void_t<typename _Up::iterator_category>::type* = 0,
+ typename __void_t<typename _Up::difference_type>::type* = 0,
+ typename __void_t<typename _Up::value_type>::type* = 0,
+ typename __void_t<typename _Up::reference>::type* = 0,
+ typename __void_t<typename _Up::pointer>::type* = 0);
public:
- static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;
+ static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value;
};
@@ -121,35 +120,34 @@ template <class _Tp>
struct __has_iterator_category
{
private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename _Up::iterator_category* = nullptr);
+ template <class _Up> static false_type __test(...);
+ template <class _Up> static true_type __test(typename _Up::iterator_category* = nullptr);
public:
- static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;
+ static const bool value = decltype(__test<_Tp>(nullptr))::value;
};
template <class _Tp>
struct __has_iterator_concept
{
private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename _Up::iterator_concept* = nullptr);
+ template <class _Up> static false_type __test(...);
+ template <class _Up> static true_type __test(typename _Up::iterator_concept* = nullptr);
public:
- static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;
+ static const bool value = decltype(__test<_Tp>(nullptr))::value;
};
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
-// The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables,
-// so they've been banished to a namespace that makes it obvious they have a niche use-case.
+// The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements
+// from `[iterator.cpp17]`. To avoid confusion between the two, the exposition-only concepts have been banished to
+// a "detail" namespace indicating they have a niche use-case.
namespace __iterator_traits_detail {
template<class _Ip>
concept __cpp17_iterator =
requires(_Ip __i) {
- { *__i } -> __referenceable;
+ { *__i } -> __can_reference;
{ ++__i } -> same_as<_Ip&>;
- { *__i++ } -> __referenceable;
+ { *__i++ } -> __can_reference;
} &&
copyable<_Ip>;
@@ -198,7 +196,7 @@ concept __cpp17_random_access_iterator =
{ __i + __n } -> same_as<_Ip>;
{ __n + __i } -> same_as<_Ip>;
{ __i - __n } -> same_as<_Ip>;
- { __i - __i } -> same_as<decltype(__n)>;
+ { __i - __i } -> same_as<decltype(__n)>; // NOLINT(misc-redundant-expression) ; This is llvm.org/PR54114
{ __i[__n] } -> convertible_to<iter_reference_t<_Ip>>;
};
} // namespace __iterator_traits_detail
@@ -362,7 +360,7 @@ struct iterator_traits : __iterator_traits<_Ip> {
using __primary_template = iterator_traits;
};
-#else // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#else // _LIBCPP_STD_VER > 17
template <class _Iter, bool> struct __iterator_traits {};
@@ -399,10 +397,10 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits
using __primary_template = iterator_traits;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
template<class _Tp>
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
requires is_object_v<_Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
@@ -468,27 +466,46 @@ template <class _Up>
struct __is_cpp17_contiguous_iterator<_Up*> : true_type {};
+template <class _Iter>
+class __wrap_iter;
+
template <class _Tp>
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> {};
-#if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+struct __is_exactly_cpp17_forward_iterator
+ : public integral_constant<bool,
+ __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value &&
+ !__has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value> {};
+
+template <class _Tp>
+struct __is_exactly_cpp17_bidirectional_iterator
+ : public integral_constant<bool,
+ __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value &&
+ !__has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>::value> {};
+
template<class _InputIterator>
using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
template<class _InputIterator>
-using __iter_key_type = remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;
+using __iter_key_type = typename remove_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type;
template<class _InputIterator>
using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;
template<class _InputIterator>
using __iter_to_alloc_type = pair<
- add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>,
+ typename add_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type,
typename iterator_traits<_InputIterator>::value_type::second_type>;
-#endif // _LIBCPP_STD_VER >= 17
+
+template <class _Iter>
+using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category;
+
+template <class _Iter>
+using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer;
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/mergeable.h
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_MERGEABLE_H
+#define _LIBCPP___ITERATOR_MERGEABLE_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _Input1, class _Input2, class _Output,
+ class _Comp = ranges::less, class _Proj1 = identity, class _Proj2 = identity>
+concept mergeable =
+ input_iterator<_Input1> &&
+ input_iterator<_Input2> &&
+ weakly_incrementable<_Output> &&
+ indirectly_copyable<_Input1, _Output> &&
+ indirectly_copyable<_Input2, _Output> &&
+ indirect_strict_weak_order<_Comp, projected<_Input1, _Proj1>, projected<_Input2, _Proj2>>;
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_MERGEABLE_H
lib/libcxx/include/__iterator/move_iterator.h
@@ -10,51 +10,131 @@
#ifndef _LIBCPP___ITERATOR_MOVE_ITERATOR_H
#define _LIBCPP___ITERATOR_MOVE_ITERATOR_H
+#include <__compare/compare_three_way_result.h>
+#include <__compare/three_way_comparable.h>
+#include <__concepts/assignable.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/same_as.h>
#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/move_sentinel.h>
+#include <__iterator/readable_traits.h>
#include <__utility/move.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 17
+template<class _Iter, class = void>
+struct __move_iter_category_base {};
+
+template<class _Iter>
+ requires requires { typename iterator_traits<_Iter>::iterator_category; }
+struct __move_iter_category_base<_Iter> {
+ using iterator_category = _If<
+ derived_from<typename iterator_traits<_Iter>::iterator_category, random_access_iterator_tag>,
+ random_access_iterator_tag,
+ typename iterator_traits<_Iter>::iterator_category
+ >;
+};
+
+template<class _Iter, class _Sent>
+concept __move_iter_comparable = requires {
+ { declval<const _Iter&>() == declval<_Sent>() } -> convertible_to<bool>;
+};
+#endif // _LIBCPP_STD_VER > 17
+
template <class _Iter>
class _LIBCPP_TEMPLATE_VIS move_iterator
+#if _LIBCPP_STD_VER > 17
+ : public __move_iter_category_base<_Iter>
+#endif
{
public:
#if _LIBCPP_STD_VER > 17
- typedef input_iterator_tag iterator_concept;
-#endif
-
+ using iterator_type = _Iter;
+ using iterator_concept = input_iterator_tag;
+ // iterator_category is inherited and not always present
+ using value_type = iter_value_t<_Iter>;
+ using difference_type = iter_difference_t<_Iter>;
+ using pointer = _Iter;
+ using reference = iter_rvalue_reference_t<_Iter>;
+#else
typedef _Iter iterator_type;
typedef _If<
__is_cpp17_random_access_iterator<_Iter>::value,
random_access_iterator_tag,
typename iterator_traits<_Iter>::iterator_category
- > iterator_category;
+ > iterator_category;
typedef typename iterator_traits<iterator_type>::value_type value_type;
typedef typename iterator_traits<iterator_type>::difference_type difference_type;
typedef iterator_type pointer;
-#ifndef _LIBCPP_CXX03_LANG
typedef typename iterator_traits<iterator_type>::reference __reference;
typedef typename conditional<
is_reference<__reference>::value,
typename remove_reference<__reference>::type&&,
__reference
>::type reference;
-#else
- typedef typename iterator_traits<iterator_type>::reference reference;
-#endif
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator() : __current_() {}
+ explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator++() { ++__current_; return *this; }
+
+ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ pointer operator->() const { return __current_; }
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_iterator() requires is_constructible_v<_Iter> : __current_() {}
+
+ template <class _Up>
+ requires (!_IsSame<_Up, _Iter>::value) && convertible_to<const _Up&, _Iter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {}
+
+ template <class _Up>
+ requires (!_IsSame<_Up, _Iter>::value) &&
+ convertible_to<const _Up&, _Iter> &&
+ assignable_from<_Iter&, const _Up&>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_iterator& operator=(const move_iterator<_Up>& __u) {
+ __current_ = __u.base();
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Iter& base() const & noexcept { return __current_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return std::move(__current_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ reference operator*() const { return ranges::iter_move(__current_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ reference operator[](difference_type __n) const { return ranges::iter_move(__current_ + __n); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ auto operator++(int)
+ requires forward_iterator<_Iter>
+ {
+ move_iterator __tmp(*this); ++__current_; return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ void operator++(int) { ++__current_; }
+#else
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- explicit move_iterator(_Iter __i) : __current_(_VSTD::move(__i)) {}
+ move_iterator() : __current_() {}
template <class _Up, class = __enable_if_t<
!is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value
@@ -79,14 +159,12 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
reference operator*() const { return static_cast<reference>(*__current_); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- pointer operator->() const { return __current_; }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator& operator++() { ++__current_; return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator& operator--() { --__current_; return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
@@ -100,7 +178,48 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; }
+#if _LIBCPP_STD_VER > 17
+ template<sentinel_for<_Iter> _Sent>
+ friend _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator==(const move_iterator& __x, const move_sentinel<_Sent>& __y)
+ requires __move_iter_comparable<_Iter, _Sent>
+ {
+ return __x.base() == __y.base();
+ }
+
+ template<sized_sentinel_for<_Iter> _Sent>
+ friend _LIBCPP_HIDE_FROM_ABI constexpr
+ iter_difference_t<_Iter> operator-(const move_sentinel<_Sent>& __x, const move_iterator& __y)
+ {
+ return __x.base() - __y.base();
+ }
+
+ template<sized_sentinel_for<_Iter> _Sent>
+ friend _LIBCPP_HIDE_FROM_ABI constexpr
+ iter_difference_t<_Iter> operator-(const move_iterator& __x, const move_sentinel<_Sent>& __y)
+ {
+ return __x.base() - __y.base();
+ }
+
+ friend _LIBCPP_HIDE_FROM_ABI constexpr
+ iter_rvalue_reference_t<_Iter> iter_move(const move_iterator& __i)
+ noexcept(noexcept(ranges::iter_move(__i.__current_)))
+ {
+ return ranges::iter_move(__i.__current_);
+ }
+
+ template<indirectly_swappable<_Iter> _It2>
+ friend _LIBCPP_HIDE_FROM_ABI constexpr
+ void iter_swap(const move_iterator& __x, const move_iterator<_It2>& __y)
+ noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
+ {
+ return ranges::iter_swap(__x.__current_, __y.__current_);
+ }
+#endif // _LIBCPP_STD_VER > 17
+
private:
+ template<class _It2> friend class move_iterator;
+
_Iter __current_;
};
@@ -111,12 +230,14 @@ bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
return __x.base() == __y.base();
}
+#if _LIBCPP_STD_VER <= 17
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() != __y.base();
}
+#endif // _LIBCPP_STD_VER <= 17
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
@@ -146,6 +267,16 @@ bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
return __x.base() >= __y.base();
}
+#if _LIBCPP_STD_VER > 17
+template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2>
+inline _LIBCPP_HIDE_FROM_ABI constexpr
+auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+ -> compare_three_way_result_t<_Iter1, _Iter2>
+{
+ return __x.base() <=> __y.base();
+}
+#endif // _LIBCPP_STD_VER > 17
+
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
@@ -162,8 +293,17 @@ operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() - __y.base();
}
-#endif
+#endif // !_LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 17
+template <class _Iter>
+inline _LIBCPP_HIDE_FROM_ABI constexpr
+move_iterator<_Iter> operator+(iter_difference_t<_Iter> __n, const move_iterator<_Iter>& __x)
+ requires requires { { __x.base() + __n } -> same_as<_Iter>; }
+{
+ return __x + __n;
+}
+#else
template <class _Iter>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator<_Iter>
@@ -171,13 +311,14 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato
{
return move_iterator<_Iter>(__x.base() + __n);
}
+#endif // _LIBCPP_STD_VER > 17
template <class _Iter>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator<_Iter>
make_move_iterator(_Iter __i)
{
- return move_iterator<_Iter>(_VSTD::move(__i));
+ return move_iterator<_Iter>(std::move(__i));
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/move_sentinel.h
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_MOVE_SENTINEL_H
+#define _LIBCPP___ITERATOR_MOVE_SENTINEL_H
+
+#include <__concepts/assignable.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/semiregular.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <semiregular _Sent>
+class _LIBCPP_TEMPLATE_VIS move_sentinel
+{
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ move_sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit move_sentinel(_Sent __s) : __last_(std::move(__s)) {}
+
+ template <class _S2>
+ requires convertible_to<const _S2&, _Sent>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_sentinel(const move_sentinel<_S2>& __s) : __last_(__s.base()) {}
+
+ template <class _S2>
+ requires assignable_from<_Sent&, const _S2&>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ move_sentinel& operator=(const move_sentinel<_S2>& __s)
+ { __last_ = __s.base(); return *this; }
+
+ constexpr _Sent base() const { return __last_; }
+
+private:
+ _Sent __last_ = _Sent();
+};
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_MOVE_SENTINEL_H
lib/libcxx/include/__iterator/next.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ITERATOR_NEXT_H
#define _LIBCPP___ITERATOR_NEXT_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
@@ -19,7 +19,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
return __x;
}
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// [range.iter.op.next]
@@ -58,16 +58,14 @@ struct __fn {
}
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
- _LIBCPP_HIDE_FROM_ABI
- constexpr _Ip operator()(_Ip __x, _Sp __bound) const {
- ranges::advance(__x, __bound);
+ _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const {
+ ranges::advance(__x, __bound_sentinel);
return __x;
}
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
- _LIBCPP_HIDE_FROM_ABI
- constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound) const {
- ranges::advance(__x, __n, __bound);
+ _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {
+ ranges::advance(__x, __n, __bound_sentinel);
return __x;
}
};
@@ -79,7 +77,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/ostream_iterator.h
@@ -14,10 +14,11 @@
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
+#include <cstddef>
#include <iosfwd> // for forward declarations of char_traits and basic_ostream
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -52,9 +53,9 @@ public:
: __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
- _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
+ _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value)
{
- *__out_stream_ << __value_;
+ *__out_stream_ << __value;
if (__delim_)
*__out_stream_ << __delim_;
return *this;
lib/libcxx/include/__iterator/ostreambuf_iterator.h
@@ -13,10 +13,11 @@
#include <__config>
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
+#include <cstddef>
#include <iosfwd> // for forward declaration of basic_streambuf
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__iterator/permutable.h
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_PERMUTABLE_H
+#define _LIBCPP___ITERATOR_PERMUTABLE_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _Iterator>
+concept permutable =
+ forward_iterator<_Iterator> &&
+ indirectly_movable_storable<_Iterator, _Iterator> &&
+ indirectly_swappable<_Iterator, _Iterator>;
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_PERMUTABLE_H
lib/libcxx/include/__iterator/prev.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ITERATOR_PREV_H
#define _LIBCPP___ITERATOR_PREV_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
@@ -19,7 +19,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
return __x;
}
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// [range.iter.op.prev]
@@ -57,9 +57,8 @@ struct __fn {
}
template <bidirectional_iterator _Ip>
- _LIBCPP_HIDE_FROM_ABI
- constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound) const {
- ranges::advance(__x, -__n, __bound);
+ _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const {
+ ranges::advance(__x, -__n, __bound_iter);
return __x;
}
};
@@ -71,7 +70,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/projected.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj>
struct projected {
@@ -33,7 +33,7 @@ struct incrementable_traits<projected<_It, _Proj>> {
using difference_type = iter_difference_t<_It>;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/readable_traits.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [readable.traits]
template<class> struct __cond_value_type {};
@@ -79,7 +79,7 @@ using iter_value_t = typename conditional_t<__is_primary_template<iterator_trait
indirectly_readable_traits<remove_cvref_t<_Ip> >,
iterator_traits<remove_cvref_t<_Ip> > >::value_type;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/reverse_access.h
@@ -16,13 +16,11 @@
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_CXX03_LANG)
-
#if _LIBCPP_STD_VER > 11
template <class _Tp, size_t _Np>
@@ -95,9 +93,7 @@ auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
return _VSTD::rend(__c);
}
-#endif
-
-#endif // !defined(_LIBCPP_CXX03_LANG)
+#endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/reverse_iterator.h
@@ -10,16 +10,30 @@
#ifndef _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
#define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
+#include <__algorithm/unwrap_iter.h>
#include <__compare/compare_three_way_result.h>
#include <__compare/three_way_comparable.h>
+#include <__concepts/convertible_to.h>
#include <__config>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/prev.h>
+#include <__iterator/readable_traits.h>
#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/subrange.h>
+#include <__utility/move.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -41,22 +55,29 @@ private:
_Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
#endif
+#if _LIBCPP_STD_VER > 17
+ static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value || bidirectional_iterator<_Iter>,
+ "reverse_iterator<It> requires It to be a bidirectional iterator.");
+#endif // _LIBCPP_STD_VER > 17
+
protected:
_Iter current;
public:
- typedef _Iter iterator_type;
- typedef typename iterator_traits<_Iter>::difference_type difference_type;
- typedef typename iterator_traits<_Iter>::reference reference;
- typedef typename iterator_traits<_Iter>::pointer pointer;
- typedef _If<__is_cpp17_random_access_iterator<_Iter>::value,
- random_access_iterator_tag,
- typename iterator_traits<_Iter>::iterator_category> iterator_category;
- typedef typename iterator_traits<_Iter>::value_type value_type;
+ using iterator_type = _Iter;
+ using iterator_category = _If<__is_cpp17_random_access_iterator<_Iter>::value,
+ random_access_iterator_tag,
+ typename iterator_traits<_Iter>::iterator_category>;
+ using pointer = typename iterator_traits<_Iter>::pointer;
#if _LIBCPP_STD_VER > 17
- typedef _If<__is_cpp17_random_access_iterator<_Iter>::value,
- random_access_iterator_tag,
- bidirectional_iterator_tag> iterator_concept;
+ using iterator_concept = _If<random_access_iterator<_Iter>, random_access_iterator_tag, bidirectional_iterator_tag>;
+ using value_type = iter_value_t<_Iter>;
+ using difference_type = iter_difference_t<_Iter>;
+ using reference = iter_reference_t<_Iter>;
+#else
+ using value_type = typename iterator_traits<_Iter>::value_type;
+ using difference_type = typename iterator_traits<_Iter>::difference_type;
+ using reference = typename iterator_traits<_Iter>::reference;
#endif
#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
@@ -114,32 +135,81 @@ public:
_Iter base() const {return current;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reference operator*() const {_Iter __tmp = current; return *--__tmp;}
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr pointer operator->() const
+ requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); }
+ {
+ if constexpr (is_pointer_v<_Iter>) {
+ return std::prev(current);
+ } else {
+ return std::prev(current).operator->();
+ }
+ }
+#else
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- pointer operator->() const {return _VSTD::addressof(operator*());}
+ pointer operator->() const {
+ return std::addressof(operator*());
+ }
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator& operator++() {--current; return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
+ reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator& operator--() {++current; return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
+ reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);}
+ reverse_iterator operator+(difference_type __n) const {return reverse_iterator(current - __n);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);}
+ reverse_iterator operator-(difference_type __n) const {return reverse_iterator(current + __n);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator[](difference_type __n) const {return *(*this + __n);}
+ reference operator[](difference_type __n) const {return *(*this + __n);}
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_HIDE_FROM_ABI friend constexpr
+ iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i)
+ noexcept(is_nothrow_copy_constructible_v<_Iter> &&
+ noexcept(ranges::iter_move(--declval<_Iter&>()))) {
+ auto __tmp = __i.base();
+ return ranges::iter_move(--__tmp);
+ }
+
+ template <indirectly_swappable<_Iter> _Iter2>
+ _LIBCPP_HIDE_FROM_ABI friend constexpr
+ void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y)
+ noexcept(is_nothrow_copy_constructible_v<_Iter> &&
+ is_nothrow_copy_constructible_v<_Iter2> &&
+ noexcept(ranges::iter_swap(--declval<_Iter&>(), --declval<_Iter2&>()))) {
+ auto __xtmp = __x.base();
+ auto __ytmp = __y.base();
+ ranges::iter_swap(--__xtmp, --__ytmp);
+ }
+#endif // _LIBCPP_STD_VER > 17
};
+template <class _Iter>
+struct __is_reverse_iterator : false_type {};
+
+template <class _Iter>
+struct __is_reverse_iterator<reverse_iterator<_Iter> > : true_type {};
+
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
bool
operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+#if _LIBCPP_STD_VER > 17
+ requires requires {
+ { __x.base() == __y.base() } -> convertible_to<bool>;
+ }
+#endif // _LIBCPP_STD_VER > 17
{
return __x.base() == __y.base();
}
@@ -148,6 +218,11 @@ template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
bool
operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+#if _LIBCPP_STD_VER > 17
+ requires requires {
+ { __x.base() > __y.base() } -> convertible_to<bool>;
+ }
+#endif // _LIBCPP_STD_VER > 17
{
return __x.base() > __y.base();
}
@@ -156,6 +231,11 @@ template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
bool
operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+#if _LIBCPP_STD_VER > 17
+ requires requires {
+ { __x.base() != __y.base() } -> convertible_to<bool>;
+ }
+#endif // _LIBCPP_STD_VER > 17
{
return __x.base() != __y.base();
}
@@ -164,6 +244,11 @@ template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
bool
operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+#if _LIBCPP_STD_VER > 17
+ requires requires {
+ { __x.base() < __y.base() } -> convertible_to<bool>;
+ }
+#endif // _LIBCPP_STD_VER > 17
{
return __x.base() < __y.base();
}
@@ -172,6 +257,11 @@ template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
bool
operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+#if _LIBCPP_STD_VER > 17
+ requires requires {
+ { __x.base() <= __y.base() } -> convertible_to<bool>;
+ }
+#endif // _LIBCPP_STD_VER > 17
{
return __x.base() <= __y.base();
}
@@ -180,11 +270,16 @@ template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
bool
operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+#if _LIBCPP_STD_VER > 17
+ requires requires {
+ { __x.base() >= __y.base() } -> convertible_to<bool>;
+ }
+#endif // _LIBCPP_STD_VER > 17
{
return __x.base() >= __y.base();
}
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2>
_LIBCPP_HIDE_FROM_ABI constexpr
compare_three_way_result_t<_Iter1, _Iter2>
@@ -192,7 +287,7 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
{
return __y.base() <=> __x.base();
}
-#endif
+#endif // _LIBCPP_STD_VER > 17
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
@@ -221,6 +316,12 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i
return reverse_iterator<_Iter>(__x.base() - __n);
}
+#if _LIBCPP_STD_VER > 17
+template <class _Iter1, class _Iter2>
+ requires (!sized_sentinel_for<_Iter1, _Iter2>)
+inline constexpr bool disable_sized_sentinel_for<reverse_iterator<_Iter1>, reverse_iterator<_Iter2>> = true;
+#endif // _LIBCPP_STD_VER > 17
+
#if _LIBCPP_STD_VER > 11
template <class _Iter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
@@ -230,6 +331,196 @@ reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
}
#endif
+#if _LIBCPP_STD_VER <= 17
+template <class _Iter>
+using __unconstrained_reverse_iterator = reverse_iterator<_Iter>;
+#else
+
+// __unconstrained_reverse_iterator allows us to use reverse iterators in the implementation of algorithms by working
+// around a language issue in C++20.
+// In C++20, when a reverse iterator wraps certain C++20-hostile iterators, calling comparison operators on it will
+// result in a compilation error. However, calling comparison operators on the pristine hostile iterator is not
+// an error. Thus, we cannot use reverse_iterators in the implementation of an algorithm that accepts a
+// C++20-hostile iterator. This class is an internal workaround -- it is a copy of reverse_iterator with
+// tweaks to make it support hostile iterators.
+//
+// A C++20-hostile iterator is one that defines a comparison operator where one of the arguments is an exact match
+// and the other requires an implicit conversion, for example:
+// friend bool operator==(const BaseIter&, const DerivedIter&);
+//
+// C++20 rules for rewriting equality operators create another overload of this function with parameters reversed:
+// friend bool operator==(const DerivedIter&, const BaseIter&);
+//
+// This creates an ambiguity in overload resolution.
+//
+// Clang treats this ambiguity differently in different contexts. When operator== is actually called in the function
+// body, the code is accepted with a warning. When a concept requires operator== to be a valid expression, however,
+// it evaluates to false. Thus, the implementation of reverse_iterator::operator== can actually call operator== on its
+// base iterators, but the constraints on reverse_iterator::operator== prevent it from being considered during overload
+// resolution. This class simply removes the problematic constraints from comparison functions.
+template <class _Iter>
+class __unconstrained_reverse_iterator {
+ _Iter __iter_;
+
+public:
+ static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value);
+
+ using iterator_type = _Iter;
+ using iterator_category =
+ _If<__is_cpp17_random_access_iterator<_Iter>::value, random_access_iterator_tag, __iterator_category_type<_Iter>>;
+ using pointer = __iterator_pointer_type<_Iter>;
+ using value_type = iter_value_t<_Iter>;
+ using difference_type = iter_difference_t<_Iter>;
+ using reference = iter_reference_t<_Iter>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator() = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator(const __unconstrained_reverse_iterator&) = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __unconstrained_reverse_iterator(_Iter __iter) : __iter_(__iter) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() const { return __iter_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const {
+ auto __tmp = __iter_;
+ return *--__tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const {
+ if constexpr (is_pointer_v<_Iter>) {
+ return std::prev(__iter_);
+ } else {
+ return std::prev(__iter_).operator->();
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() {
+ --__iter_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator++(int) {
+ auto __tmp = *this;
+ --__iter_;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator--() {
+ ++__iter_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator--(int) {
+ auto __tmp = *this;
+ ++__iter_;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator+=(difference_type __n) {
+ __iter_ -= __n;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator-=(difference_type __n) {
+ __iter_ += __n;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator+(difference_type __n) const {
+ return __unconstrained_reverse_iterator(__iter_ - __n);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator-(difference_type __n) const {
+ return __unconstrained_reverse_iterator(__iter_ + __n);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr difference_type operator-(const __unconstrained_reverse_iterator& __other) const {
+ return __other.__iter_ - __iter_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const { return *(*this + __n); }
+
+ // Deliberately unconstrained unlike the comparison functions in `reverse_iterator` -- see the class comment for the
+ // rationale.
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator==(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
+ return __lhs.base() == __rhs.base();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator!=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
+ return __lhs.base() != __rhs.base();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator<(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
+ return __lhs.base() > __rhs.base();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator>(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
+ return __lhs.base() < __rhs.base();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator<=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
+ return __lhs.base() >= __rhs.base();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator>=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
+ return __lhs.base() <= __rhs.base();
+ }
+};
+
+template <class _Iter>
+struct __is_reverse_iterator<__unconstrained_reverse_iterator<_Iter>> : true_type {};
+
+#endif // _LIBCPP_STD_VER <= 17
+
+template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter>
+struct __unwrap_reverse_iter_impl {
+ using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>()));
+ using _ReverseWrapper = _RevIter1<_RevIter2<_Iter> >;
+
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper
+ __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) {
+ return _ReverseWrapper(
+ _RevIter2<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter)));
+ }
+
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper __i) _NOEXCEPT {
+ return __unwrap_iter_impl<_Iter>::__unwrap(__i.base().base());
+ }
+};
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <ranges::bidirectional_range _Range>
+_LIBCPP_HIDE_FROM_ABI constexpr ranges::
+ subrange<reverse_iterator<ranges::iterator_t<_Range>>, reverse_iterator<ranges::iterator_t<_Range>>>
+ __reverse_range(_Range&& __range) {
+ auto __first = ranges::begin(__range);
+ return {std::make_reverse_iterator(ranges::next(__first, ranges::end(__range))), std::make_reverse_iterator(__first)};
+}
+#endif
+
+template <class _Iter, bool __b>
+struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b>
+ : __unwrap_reverse_iter_impl<reverse_iterator, reverse_iterator, _Iter> {};
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _Iter, bool __b>
+struct __unwrap_iter_impl<reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b>
+ : __unwrap_reverse_iter_impl<reverse_iterator, __unconstrained_reverse_iterator, _Iter> {};
+
+template <class _Iter, bool __b>
+struct __unwrap_iter_impl<__unconstrained_reverse_iterator<reverse_iterator<_Iter>>, __b>
+ : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, reverse_iterator, _Iter> {};
+
+template <class _Iter, bool __b>
+struct __unwrap_iter_impl<__unconstrained_reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b>
+ : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, __unconstrained_reverse_iterator, _Iter> {};
+
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
lib/libcxx/include/__iterator/size.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -41,9 +41,14 @@ _NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(
-> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>
{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); }
+// GCC complains about the implicit conversion from ptrdiff_t to size_t in
+// the array bound.
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wsign-conversion")
template <class _Tp, ptrdiff_t _Sz>
_LIBCPP_INLINE_VISIBILITY
constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; }
+_LIBCPP_DIAGNOSTIC_POP
#endif
#endif // _LIBCPP_STD_VER > 14
lib/libcxx/include/__iterator/sortable.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_SORTABLE_H
+#define _LIBCPP___ITERATOR_SORTABLE_H
+
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/permutable.h>
+#include <__iterator/projected.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _Iter, class _Comp = ranges::less, class _Proj = identity>
+concept sortable =
+ permutable<_Iter> &&
+ indirect_strict_weak_order<_Comp, projected<_Iter, _Proj>>;
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ITERATOR_SORTABLE_H
lib/libcxx/include/__iterator/unreachable_sentinel.h
@@ -14,12 +14,12 @@
#include <__iterator/concepts.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
struct unreachable_sentinel_t {
template<weakly_incrementable _Iter>
@@ -31,7 +31,7 @@ struct unreachable_sentinel_t {
inline constexpr unreachable_sentinel_t unreachable_sentinel{};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/wrap_iter.h
@@ -18,7 +18,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -50,12 +50,12 @@ public:
typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
: __i(__u.base())
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__iterator_copy(this, _VSTD::addressof(__u));
#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
__wrap_iter(const __wrap_iter& __x)
: __i(__x.base())
@@ -135,15 +135,15 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;}
private:
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i(__x)
{
+ (void)__p;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__insert_ic(this, __p);
- }
-#else
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
#endif
+ }
template <class _Up> friend class __wrap_iter;
template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
lib/libcxx/include/__memory/addressof.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__memory/allocate_at_least.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
+#define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
+
+#include <__config>
+#include <__memory/allocator_traits.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+template <class _Pointer>
+struct allocation_result {
+ _Pointer ptr;
+ size_t count;
+};
+
+template <class _Alloc>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
+allocation_result<typename allocator_traits<_Alloc>::pointer> allocate_at_least(_Alloc& __alloc, size_t __n) {
+ if constexpr (requires { __alloc.allocate_at_least(__n); }) {
+ return __alloc.allocate_at_least(__n);
+ } else {
+ return {__alloc.allocate(__n), __n};
+ }
+}
+
+template <class _Alloc>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
+auto __allocate_at_least(_Alloc& __alloc, size_t __n) {
+ return std::allocate_at_least(__alloc, __n);
+}
+#else
+template <class _Pointer>
+struct __allocation_result {
+ _Pointer ptr;
+ size_t count;
+};
+
+template <class _Alloc>
+_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+__allocation_result<typename allocator_traits<_Alloc>::pointer> __allocate_at_least(_Alloc& __alloc, size_t __n) {
+ return {__alloc.allocate(__n), __n};
+}
+
+#endif // _LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
lib/libcxx/include/__memory/allocation_guard.h
@@ -12,11 +12,11 @@
#include <__config>
#include <__memory/allocator_traits.h>
+#include <__utility/move.h>
#include <cstddef>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__memory/allocator.h
@@ -11,6 +11,7 @@
#define _LIBCPP___MEMORY_ALLOCATOR_H
#include <__config>
+#include <__memory/allocate_at_least.h>
#include <__memory/allocator_traits.h>
#include <__utility/forward.h>
#include <cstddef>
@@ -19,34 +20,40 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class allocator;
-#if _LIBCPP_STD_VER <= 17
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION)
+// These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17.
+// Specializing allocator<void> is deprecated, but not using it.
template <>
class _LIBCPP_TEMPLATE_VIS allocator<void>
{
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
public:
_LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type;
template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
+#endif
};
template <>
class _LIBCPP_TEMPLATE_VIS allocator<const void>
{
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
public:
_LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type;
template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
+#endif
};
#endif
@@ -106,6 +113,13 @@ public:
}
}
+#if _LIBCPP_STD_VER > 20
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
+ allocation_result<_Tp*> allocate_at_least(size_t __n) {
+ return {allocate(__n), __n};
+ }
+#endif
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
if (__libcpp_is_constant_evaluated()) {
@@ -188,6 +202,13 @@ public:
}
}
+#if _LIBCPP_STD_VER > 20
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
+ allocation_result<const _Tp*> allocate_at_least(size_t __n) {
+ return {allocate(__n), __n};
+ }
+#endif
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void deallocate(const _Tp* __p, size_t __n) {
if (__libcpp_is_constant_evaluated()) {
lib/libcxx/include/__memory/allocator_arg_t.h
@@ -16,7 +16,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -36,7 +36,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor_imp
{
- typedef _LIBCPP_NODEBUG typename __uncvref<_Alloc>::type _RawAlloc;
+ typedef _LIBCPP_NODEBUG __uncvref_t<_Alloc> _RawAlloc;
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
static const bool __ic =
is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
lib/libcxx/include/__memory/allocator_traits.h
@@ -18,7 +18,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__memory/assume_aligned.h
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_ASSUME_ALIGNED_H
+#define _LIBCPP___MEMORY_ASSUME_ALIGNED_H
+
+#include <__assert>
+#include <__config>
+#include <cstddef>
+#include <cstdint>
+#include <type_traits> // for is_constant_evaluated()
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <size_t _Np, class _Tp>
+[[nodiscard]]
+_LIBCPP_HIDE_FROM_ABI
+constexpr _Tp* assume_aligned(_Tp* __ptr) {
+ static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0,
+ "std::assume_aligned<N>(p) requires N to be a power of two");
+
+ if (is_constant_evaluated()) {
+ return __ptr;
+ } else {
+ _LIBCPP_ASSERT(reinterpret_cast<uintptr_t>(__ptr) % _Np == 0, "Alignment assumption is violated");
+ return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Np));
+ }
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_ASSUME_ALIGNED_H
lib/libcxx/include/__memory/auto_ptr.h
@@ -11,12 +11,13 @@
#define _LIBCPP___MEMORY_AUTO_PTR_H
#include <__config>
-#include <__nullptr>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
@@ -78,4 +79,6 @@ public:
_LIBCPP_END_NAMESPACE_STD
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+
#endif // _LIBCPP___MEMORY_AUTO_PTR_H
lib/libcxx/include/__memory/compressed_pair.h
@@ -12,12 +12,12 @@
#include <__config>
#include <__utility/forward.h>
+#include <__utility/move.h>
#include <tuple> // needed in c++03 for some constructors
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -26,40 +26,28 @@ _LIBCPP_BEGIN_NAMESPACE_STD
struct __default_init_tag {};
struct __value_init_tag {};
-template <class _Tp, int _Idx,
- bool _CanBeEmptyBase =
- is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>
+template <class _Tp, int _Idx, bool _CanBeEmptyBase = is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>
struct __compressed_pair_elem {
- typedef _Tp _ParamT;
- typedef _Tp& reference;
- typedef const _Tp& const_reference;
-
- _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
- _LIBCPP_CONSTEXPR explicit
- __compressed_pair_elem(_Up&& __u)
- : __value_(_VSTD::forward<_Up>(__u))
- {
- }
+ using _ParamT = _Tp;
+ using reference = _Tp&;
+ using const_reference = const _Tp&;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {}
+
+ template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ explicit __compressed_pair_elem(_Up&& __u) : __value_(std::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))...) {}
+ template <class... _Args, size_t... _Indices>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ explicit __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
+ : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {}
#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
private:
_Tp __value_;
@@ -67,36 +55,28 @@ private:
template <class _Tp, int _Idx>
struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
- typedef _Tp _ParamT;
- typedef _Tp& reference;
- typedef const _Tp& const_reference;
- typedef _Tp __value_type;
-
- _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
- _LIBCPP_CONSTEXPR explicit
- __compressed_pair_elem(_Up&& __u)
- : __value_type(_VSTD::forward<_Up>(__u))
- {}
+ using _ParamT = _Tp;
+ using reference = _Tp&;
+ using const_reference = const _Tp&;
+ using __value_type = _Tp;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem() = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {}
+
+ template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ explicit __compressed_pair_elem(_Up&& __u) : __value_type(std::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))...) {}
+ template <class... _Args, size_t... _Indices>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
+ : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {}
#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }
};
template <class _T1, class _T2>
@@ -109,72 +89,73 @@ public:
// object and the allocator have the same type).
static_assert((!is_same<_T1, _T2>::value),
"__compressed_pair cannot be instantiated when T1 and T2 are the same type; "
- "The current implementation is NOT ABI-compatible with the previous "
- "implementation for this configuration");
+ "The current implementation is NOT ABI-compatible with the previous implementation for this configuration");
- typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T1, 0> _Base1;
- typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T2, 1> _Base2;
+ using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>;
+ using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>;
- 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
+ template <bool _Dummy = true,
+ class = __enable_if_t<
+ __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
+ __dependent_type<is_default_constructible<_T2>, _Dummy>::value
+ >
>
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ explicit __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
template <class _U1, class _U2>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- __compressed_pair(_U1&& __t1, _U2&& __t2)
- : _Base1(_VSTD::forward<_U1>(__t1)), _Base2(_VSTD::forward<_U2>(__t2)) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ explicit __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,
- tuple<_Args2...> __second_args)
- : _Base1(__pc, _VSTD::move(__first_args),
- typename __make_tuple_indices<sizeof...(_Args1)>::type()),
- _Base2(__pc, _VSTD::move(__second_args),
- typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ explicit __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
+ tuple<_Args2...> __second_args)
+ : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()),
+ _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base1::reference first() _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ typename _Base1::reference first() _NOEXCEPT {
return static_cast<_Base1&>(*this).__get();
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base1::const_reference first() const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ typename _Base1::const_reference first() const _NOEXCEPT {
return static_cast<_Base1 const&>(*this).__get();
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base2::reference second() _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ typename _Base2::reference second() _NOEXCEPT {
return static_cast<_Base2&>(*this).__get();
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base2::const_reference second() const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ typename _Base2::const_reference second() const _NOEXCEPT {
return static_cast<_Base2 const&>(*this).__get();
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+ _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {
return static_cast<_Base1*>(__pair);
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+ _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {
return static_cast<_Base2*>(__pair);
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__compressed_pair& __x)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ void swap(__compressed_pair& __x)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
- using _VSTD::swap;
+ using std::swap;
swap(first(), __x.first());
swap(second(), __x.second());
}
};
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
__x.swap(__y);
lib/libcxx/include/__memory/concepts.h
@@ -20,12 +20,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
@@ -61,7 +61,7 @@ concept __nothrow_forward_range =
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/construct_at.h
@@ -10,17 +10,17 @@
#ifndef _LIBCPP___MEMORY_CONSTRUCT_AT_H
#define _LIBCPP___MEMORY_CONSTRUCT_AT_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <__iterator/access.h>
#include <__memory/addressof.h>
#include <__memory/voidify.h>
#include <__utility/forward.h>
+#include <__utility/move.h>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -29,17 +29,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-template<class _Tp, class ..._Args, class = decltype(
- ::new (declval<void*>()) _Tp(declval<_Args>()...)
-)>
-_LIBCPP_HIDE_FROM_ABI
-constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
- _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
- return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
+template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
+ _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");
+ return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
}
#endif
+template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
+#if _LIBCPP_STD_VER > 17
+ return std::construct_at(__location, std::forward<_Args>(__args)...);
+#else
+ return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"),
+ ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
+#endif
+}
+
// destroy_at
// The internal functions are available regardless of the language version (with the exception of the `__destroy_at`
@@ -52,7 +59,7 @@ _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);
template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __destroy_at(_Tp* __loc) {
- _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
__loc->~_Tp();
}
@@ -60,7 +67,7 @@ void __destroy_at(_Tp* __loc) {
template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __destroy_at(_Tp* __loc) {
- _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
_VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));
}
#endif
lib/libcxx/include/__memory/pointer_traits.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -71,13 +71,12 @@ template <class _Tp, class _Up>
struct __has_rebind
{
private:
- struct __two {char __lx; char __lxx;};
- template <class _Xp> static __two __test(...);
+ template <class _Xp> static false_type __test(...);
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
+ template <class _Xp> static true_type __test(typename _Xp::template rebind<_Up>* = 0);
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
- static const bool value = sizeof(__test<_Tp>(0)) == 1;
+ static const bool value = decltype(__test<_Tp>(0))::value;
};
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
@@ -123,7 +122,7 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
private:
struct __nat {};
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static pointer pointer_to(typename conditional<is_void<element_type>::value,
__nat, element_type>::type& __r)
{return pointer::pointer_to(__r);}
lib/libcxx/include/__memory/ranges_construct_at.h
@@ -24,12 +24,12 @@
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
// construct_at
@@ -117,7 +117,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h
@@ -27,12 +27,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
@@ -311,7 +311,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/raw_storage_iterator.h
@@ -11,13 +11,14 @@
#define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
+#include <__utility/move.h>
#include <cstddef>
-#include <iterator>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__memory/swap_allocator.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_SWAP_ALLOCATOR_H
+#define _LIBCPP___MEMORY_SWAP_ALLOCATOR_H
+
+#include <__config>
+#include <__memory/allocator_traits.h>
+#include <__type_traits/integral_constant.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <typename _Alloc>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type)
+#if _LIBCPP_STD_VER > 11
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
+#endif
+{
+ using _VSTD::swap;
+ swap(__a1, __a2);
+}
+
+template <typename _Alloc>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void
+__swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {}
+
+template <typename _Alloc>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2)
+#if _LIBCPP_STD_VER > 11
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
+#endif
+{
+ _VSTD::__swap_allocator(
+ __a1, __a2, integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_SWAP_ALLOCATOR_H
lib/libcxx/include/__memory/temporary_buffer.h
@@ -11,18 +11,19 @@
#define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
#include <__config>
+#include <__type_traits/alignment_of.h>
+#include <__utility/pair.h>
#include <cstddef>
#include <new>
-#include <utility> // pair
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI
+_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17
pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
{
@@ -67,7 +68,7 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
void return_temporary_buffer(_Tp* __p) _NOEXCEPT
{
_VSTD::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp));
@@ -75,8 +76,10 @@ void return_temporary_buffer(_Tp* __p) _NOEXCEPT
struct __return_temporary_buffer
{
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
};
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/uninitialized_algorithms.h
@@ -10,15 +10,24 @@
#ifndef _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
#define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
+#include <__algorithm/copy.h>
+#include <__algorithm/move.h>
#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
#include <__memory/addressof.h>
+#include <__memory/allocator_traits.h>
#include <__memory/construct_at.h>
+#include <__memory/pointer_traits.h>
#include <__memory/voidify.h>
-#include <iterator>
-#include <utility>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <__utility/transaction.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -343,8 +352,291 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir
__unreachable_sentinel(), __iter_move);
}
+// TODO: Rewrite this to iterate left to right and use reverse_iterators when calling
+// Destroys every element in the range [first, last) FROM RIGHT TO LEFT using allocator
+// destruction. If elements are themselves C-style arrays, they are recursively destroyed
+// in the same manner.
+//
+// This function assumes that destructors do not throw, and that the allocator is bound to
+// the correct type.
+template<class _Alloc, class _BidirIter, class = __enable_if_t<
+ __is_cpp17_bidirectional_iterator<_BidirIter>::value
+>>
+_LIBCPP_HIDE_FROM_ABI
+constexpr void __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept {
+ using _ValueType = typename iterator_traits<_BidirIter>::value_type;
+ static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _ValueType>,
+ "The allocator should already be rebound to the correct type");
+
+ if (__first == __last)
+ return;
+
+ if constexpr (is_array_v<_ValueType>) {
+ static_assert(!__libcpp_is_unbounded_array<_ValueType>::value,
+ "arrays of unbounded arrays don't exist, but if they did we would mess up here");
+
+ using _Element = remove_extent_t<_ValueType>;
+ __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
+ do {
+ --__last;
+ decltype(auto) __array = *__last;
+ std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + extent_v<_ValueType>);
+ } while (__last != __first);
+ } else {
+ do {
+ --__last;
+ allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__last));
+ } while (__last != __first);
+ }
+}
+
+// Constructs the object at the given location using the allocator's construct method.
+//
+// If the object being constructed is an array, each element of the array is allocator-constructed,
+// recursively. If an exception is thrown during the construction of an array, the initialized
+// elements are destroyed in reverse order of initialization using allocator destruction.
+//
+// This function assumes that the allocator is bound to the correct type.
+template<class _Alloc, class _Tp>
+_LIBCPP_HIDE_FROM_ABI
+constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc) {
+ static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,
+ "The allocator should already be rebound to the correct type");
+
+ if constexpr (is_array_v<_Tp>) {
+ using _Element = remove_extent_t<_Tp>;
+ __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
+ size_t __i = 0;
+ _Tp& __array = *__loc;
+
+ // If an exception is thrown, destroy what we have constructed so far in reverse order.
+ __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); });
+ for (; __i != extent_v<_Tp>; ++__i) {
+ std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]));
+ }
+ __guard.__complete();
+ } else {
+ allocator_traits<_Alloc>::construct(__alloc, __loc);
+ }
+}
+
+// Constructs the object at the given location using the allocator's construct method, passing along
+// the provided argument.
+//
+// If the object being constructed is an array, the argument is also assumed to be an array. Each
+// each element of the array being constructed is allocator-constructed from the corresponding
+// element of the argument array. If an exception is thrown during the construction of an array,
+// the initialized elements are destroyed in reverse order of initialization using allocator
+// destruction.
+//
+// This function assumes that the allocator is bound to the correct type.
+template<class _Alloc, class _Tp, class _Arg>
+_LIBCPP_HIDE_FROM_ABI
+constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc, _Arg const& __arg) {
+ static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,
+ "The allocator should already be rebound to the correct type");
+
+ if constexpr (is_array_v<_Tp>) {
+ static_assert(is_array_v<_Arg>,
+ "Provided non-array initialization argument to __allocator_construct_at when "
+ "trying to construct an array.");
+
+ using _Element = remove_extent_t<_Tp>;
+ __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
+ size_t __i = 0;
+ _Tp& __array = *__loc;
+
+ // If an exception is thrown, destroy what we have constructed so far in reverse order.
+ __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); });
+ for (; __i != extent_v<_Tp>; ++__i) {
+ std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);
+ }
+ __guard.__complete();
+ } else {
+ allocator_traits<_Alloc>::construct(__alloc, __loc, __arg);
+ }
+}
+
+// Given a range starting at it and containing n elements, initializes each element in the
+// range from left to right using the construct method of the allocator (rebound to the
+// correct type).
+//
+// If an exception is thrown, the initialized elements are destroyed in reverse order of
+// initialization using allocator_traits destruction. If the elements in the range are C-style
+// arrays, they are initialized element-wise using allocator construction, and recursively so.
+template<class _Alloc, class _BidirIter, class _Tp, class _Size = typename iterator_traits<_BidirIter>::difference_type>
+_LIBCPP_HIDE_FROM_ABI
+constexpr void __uninitialized_allocator_fill_n(_Alloc& __alloc, _BidirIter __it, _Size __n, _Tp const& __value) {
+ using _ValueType = typename iterator_traits<_BidirIter>::value_type;
+ __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);
+ _BidirIter __begin = __it;
+
+ // If an exception is thrown, destroy what we have constructed so far in reverse order.
+ __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
+ for (; __n != 0; --__n, ++__it) {
+ std::__allocator_construct_at(__value_alloc, std::addressof(*__it), __value);
+ }
+ __guard.__complete();
+}
+
+// Same as __uninitialized_allocator_fill_n, but doesn't pass any initialization argument
+// to the allocator's construct method, which results in value initialization.
+template<class _Alloc, class _BidirIter, class _Size = typename iterator_traits<_BidirIter>::difference_type>
+_LIBCPP_HIDE_FROM_ABI
+constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _BidirIter __it, _Size __n) {
+ using _ValueType = typename iterator_traits<_BidirIter>::value_type;
+ __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);
+ _BidirIter __begin = __it;
+
+ // If an exception is thrown, destroy what we have constructed so far in reverse order.
+ __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
+ for (; __n != 0; --__n, ++__it) {
+ std::__allocator_construct_at(__value_alloc, std::addressof(*__it));
+ }
+ __guard.__complete();
+}
+
#endif // _LIBCPP_STD_VER > 14
+// Destroy all elements in [__first, __last) from left to right using allocator destruction.
+template <class _Alloc, class _Iter, class _Sent>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void
+__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
+ for (; __first != __last; ++__first)
+ allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first));
+}
+
+template <class _Alloc, class _Iter>
+class _AllocatorDestroyRangeReverse {
+public:
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
+ : __alloc_(__alloc), __first_(__first), __last_(__last) {}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
+ std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));
+ }
+
+private:
+ _Alloc& __alloc_;
+ _Iter& __first_;
+ _Iter& __last_;
+};
+
+// Copy-construct [__first1, __last1) in [__first2, __first2 + N), where N is distance(__first1, __last1).
+//
+// The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the
+// already copied elements are destroyed in reverse order of their construction.
+template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
+__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ auto __destruct_first = __first2;
+ try {
+#endif
+ while (__first1 != __last1) {
+ allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1);
+ ++__first1;
+ ++__first2;
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
+ throw;
+ }
+#endif
+ return __first2;
+}
+
+template <class _Alloc, class _Type>
+struct __allocator_has_trivial_copy_construct : _Not<__has_construct<_Alloc, _Type*, const _Type&> > {};
+
+template <class _Type>
+struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_type {};
+
+template <class _Alloc,
+ class _Type,
+ class _RawType = typename remove_const<_Type>::type,
+ __enable_if_t<
+ // using _RawType because of the allocator<T const> extension
+ is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value &&
+ __allocator_has_trivial_copy_construct<_Alloc, _RawType>::value>* = nullptr>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Type*
+__uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) {
+ // TODO: Remove the const_cast once we drop support for std::allocator<T const>
+ if (__libcpp_is_constant_evaluated()) {
+ while (__first1 != __last1) {
+ std::__construct_at(std::__to_address(__first2), *__first1);
+ ++__first1;
+ ++__first2;
+ }
+ return __first2;
+ } else {
+ return std::copy(__first1, __last1, const_cast<_RawType*>(__first2));
+ }
+}
+
+// Move-construct the elements [__first1, __last1) into [__first2, __first2 + N)
+// if the move constructor is noexcept, where N is distance(__first1, __last1).
+//
+// Otherwise try to copy all elements. If an exception is thrown the already copied
+// elements are destroyed in reverse order of their construction.
+template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_allocator_move_if_noexcept(
+ _Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
+ static_assert(__is_cpp17_move_insertable<_Alloc>::value,
+ "The specified type does not meet the requirements of Cpp17MoveInsertable");
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ auto __destruct_first = __first2;
+ try {
+#endif
+ while (__first1 != __last1) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1));
+#else
+ allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move(*__first1));
+#endif
+ ++__first1;
+ ++__first2;
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
+ throw;
+ }
+#endif
+ return __first2;
+}
+
+template <class _Alloc, class _Type>
+struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {};
+
+template <class _Type>
+struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {};
+
+#ifndef _LIBCPP_COMPILER_GCC
+template <
+ class _Alloc,
+ class _Iter1,
+ class _Iter2,
+ class _Type = typename iterator_traits<_Iter1>::value_type,
+ class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
+ __allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
+__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
+ if (__libcpp_is_constant_evaluated()) {
+ while (__first1 != __last1) {
+ std::__construct_at(std::__to_address(__first2), std::move(*__first1));
+ ++__first1;
+ ++__first2;
+ }
+ return __first2;
+ } else {
+ return std::move(__first1, __last1, __first2);
+ }
+}
+#endif // _LIBCPP_COMPILER_GCC
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
lib/libcxx/include/__memory/unique_ptr.h
@@ -13,20 +13,16 @@
#include <__config>
#include <__functional/hash.h>
#include <__functional/operations.h>
-#include <__functional_base>
#include <__memory/allocator_traits.h> // __pointer
+#include <__memory/auto_ptr.h>
#include <__memory/compressed_pair.h>
#include <__utility/forward.h>
+#include <__utility/move.h>
#include <cstddef>
#include <type_traits>
-#include <utility>
-
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-# include <__memory/auto_ptr.h>
-#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -47,10 +43,8 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
0) _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT {
- static_assert(sizeof(_Tp) > 0,
- "default_delete can not delete incomplete type");
- static_assert(!is_void<_Tp>::value,
- "default_delete can not delete incomplete type");
+ static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
+ static_assert(!is_void<_Tp>::value, "cannot delete an incomplete type");
delete __ptr;
}
};
@@ -78,10 +72,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
typename _EnableIfConvertible<_Up>::type
operator()(_Up* __ptr) const _NOEXCEPT {
- static_assert(sizeof(_Tp) > 0,
- "default_delete can not delete incomplete type");
- static_assert(!is_void<_Tp>::value,
- "default_delete can not delete void type");
+ static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type");
delete[] __ptr;
}
};
@@ -144,7 +135,7 @@ private:
typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
template <bool _Dummy, class _Deleter = typename __dependent_type<
- __identity<deleter_type>, _Dummy>::type>
+ __type_identity<deleter_type>, _Dummy>::type>
using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
typename enable_if<is_default_constructible<_Deleter>::value &&
!is_pointer<_Deleter>::value>::type;
@@ -264,7 +255,6 @@ public:
unique_ptr& operator=(unique_ptr const&) = delete;
#endif
-
_LIBCPP_INLINE_VISIBILITY
~unique_ptr() { reset(); }
@@ -359,7 +349,7 @@ private:
typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
template <bool _Dummy, class _Deleter = typename __dependent_type<
- __identity<deleter_type>, _Dummy>::type>
+ __type_identity<deleter_type>, _Dummy>::type>
using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
typename enable_if<is_default_constructible<_Deleter>::value &&
!is_pointer<_Deleter>::value>::type;
@@ -486,7 +476,6 @@ public:
unique_ptr(unique_ptr const&) = delete;
unique_ptr& operator=(unique_ptr const&) = delete;
#endif
-
public:
_LIBCPP_INLINE_VISIBILITY
~unique_ptr() { reset(); }
lib/libcxx/include/__memory/uses_allocator.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -24,11 +24,10 @@ template <class _Tp>
struct __has_allocator_type
{
private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename _Up::allocator_type* = 0);
+ template <class _Up> static false_type __test(...);
+ template <class _Up> static true_type __test(typename _Up::allocator_type* = 0);
public:
- static const bool value = sizeof(__test<_Tp>(0)) == 1;
+ static const bool value = decltype(__test<_Tp>(0))::value;
};
template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
lib/libcxx/include/__numeric/accumulate.h
@@ -14,7 +14,7 @@
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__numeric/gcd_lcm.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___NUMERIC_GCD_LCM_H
#define _LIBCPP___NUMERIC_GCD_LCM_H
+#include <__assert>
#include <__config>
-#include <__debug>
#include <limits>
#include <type_traits>
lib/libcxx/include/__numeric/inner_product.h
@@ -14,7 +14,7 @@
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__numeric/iota.h
@@ -21,10 +21,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
-iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
+iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
{
- for (; __first != __last; ++__first, (void) ++__value_)
- *__first = __value_;
+ for (; __first != __last; ++__first, (void) ++__value)
+ *__first = __value;
}
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__random/bernoulli_distribution.h
@@ -10,11 +10,12 @@
#define _LIBCPP___RANDOM_BERNOULLI_DISTRIBUTION_H
#include <__config>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -103,6 +104,7 @@ inline
bernoulli_distribution::result_type
bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
uniform_real_distribution<double> __gen;
return __gen(__g) < __p.p();
}
lib/libcxx/include/__random/binomial_distribution.h
@@ -10,12 +10,13 @@
#define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H
#include <__config>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -26,6 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _IntType = int>
class _LIBCPP_TEMPLATE_VIS binomial_distribution
{
+ static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
public:
// types
typedef _IntType result_type;
@@ -146,6 +148,7 @@ template<class _URNG>
_IntType
binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
if (__pr.__t_ == 0 || __pr.__p_ == 0)
return 0;
if (__pr.__p_ == 1)
lib/libcxx/include/__random/cauchy_distribution.h
@@ -10,13 +10,14 @@
#define _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H
#include <__config>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -116,6 +117,7 @@ inline
_RealType
cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
uniform_real_distribution<result_type> __gen;
// purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite
return __p.a() + __p.b() * _VSTD::tan(3.1415926535897932384626433832795 * __gen(__g));
lib/libcxx/include/__random/chi_squared_distribution.h
@@ -15,7 +15,7 @@
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/clamp_to_integral.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/default_random_engine.h
@@ -13,7 +13,7 @@
#include <__random/linear_congruential_engine.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/discard_block_engine.h
@@ -17,7 +17,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/discrete_distribution.h
@@ -11,6 +11,7 @@
#include <__algorithm/upper_bound.h>
#include <__config>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cstddef>
#include <iosfwd>
@@ -18,7 +19,7 @@
#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -29,6 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _IntType = int>
class _LIBCPP_TEMPLATE_VIS discrete_distribution
{
+ static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
public:
// types
typedef _IntType result_type;
@@ -211,6 +213,7 @@ template<class _URNG>
_IntType
discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
uniform_real_distribution<double> __gen;
return static_cast<_IntType>(
_VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) -
lib/libcxx/include/__random/exponential_distribution.h
@@ -11,13 +11,14 @@
#include <__config>
#include <__random/generate_canonical.h>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -109,6 +110,7 @@ template<class _URNG>
_RealType
exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
return -_VSTD::log
(
result_type(1) -
lib/libcxx/include/__random/extreme_value_distribution.h
@@ -10,13 +10,14 @@
#define _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H
#include <__config>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -116,6 +117,7 @@ template<class _URNG>
_RealType
extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
return __p.a() - __p.b() *
_VSTD::log(-_VSTD::log(1-uniform_real_distribution<result_type>()(__g)));
}
lib/libcxx/include/__random/fisher_f_distribution.h
@@ -11,11 +11,12 @@
#include <__config>
#include <__random/gamma_distribution.h>
+#include <__random/is_valid.h>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -114,6 +115,7 @@ template<class _URNG>
_RealType
fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
gamma_distribution<result_type> __gdm(__p.m() * result_type(.5));
gamma_distribution<result_type> __gdn(__p.n() * result_type(.5));
return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g));
lib/libcxx/include/__random/gamma_distribution.h
@@ -11,13 +11,14 @@
#include <__config>
#include <__random/exponential_distribution.h>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -117,6 +118,7 @@ template<class _URNG>
_RealType
gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
result_type __a = __p.alpha();
uniform_real_distribution<result_type> __gen(0, 1);
exponential_distribution<result_type> __egen;
lib/libcxx/include/__random/generate_canonical.h
@@ -16,7 +16,7 @@
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/geometric_distribution.h
@@ -10,12 +10,13 @@
#define _LIBCPP___RANDOM_GEOMETRIC_DISTRIBUTION_H
#include <__config>
+#include <__random/is_valid.h>
#include <__random/negative_binomial_distribution.h>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -26,6 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _IntType = int>
class _LIBCPP_TEMPLATE_VIS geometric_distribution
{
+ static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
public:
// types
typedef _IntType result_type;
lib/libcxx/include/__random/independent_bits_engine.h
@@ -18,7 +18,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/is_seed_sequence.h
@@ -13,7 +13,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/is_valid.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANDOM_IS_VALID_H
+#define _LIBCPP___RANDOM_IS_VALID_H
+
+#include <__config>
+#include <cstdint>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// [rand.req.genl]/1.5:
+// The effect of instantiating a template that has a template type parameter
+// named IntType is undefined unless the corresponding template argument is
+// cv-unqualified and is one of short, int, long, long long, unsigned short,
+// unsigned int, unsigned long, or unsigned long long.
+
+template<class> struct __libcpp_random_is_valid_inttype : false_type {};
+template<> struct __libcpp_random_is_valid_inttype<int8_t> : true_type {}; // extension
+template<> struct __libcpp_random_is_valid_inttype<short> : true_type {};
+template<> struct __libcpp_random_is_valid_inttype<int> : true_type {};
+template<> struct __libcpp_random_is_valid_inttype<long> : true_type {};
+template<> struct __libcpp_random_is_valid_inttype<long long> : true_type {};
+template<> struct __libcpp_random_is_valid_inttype<uint8_t> : true_type {}; // extension
+template<> struct __libcpp_random_is_valid_inttype<unsigned short> : true_type {};
+template<> struct __libcpp_random_is_valid_inttype<unsigned int> : true_type {};
+template<> struct __libcpp_random_is_valid_inttype<unsigned long> : true_type {};
+template<> struct __libcpp_random_is_valid_inttype<unsigned long long> : true_type {};
+
+#ifndef _LIBCPP_HAS_NO_INT128
+template<> struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension
+template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension
+#endif // _LIBCPP_HAS_NO_INT128
+
+// [rand.req.urng]/3:
+// A class G meets the uniform random bit generator requirements if G models
+// uniform_random_bit_generator, invoke_result_t<G&> is an unsigned integer type,
+// and G provides a nested typedef-name result_type that denotes the same type
+// as invoke_result_t<G&>.
+// (In particular, reject URNGs with signed result_types; our distributions cannot
+// handle such generator types.)
+
+template<class, class = void> struct __libcpp_random_is_valid_urng : false_type {};
+template<class _Gp> struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t<
+ is_unsigned<typename _Gp::result_type>::value &&
+ _IsSame<decltype(declval<_Gp&>()()), typename _Gp::result_type>::value
+> > : true_type {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANDOM_IS_VALID_H
lib/libcxx/include/__random/knuth_b.h
@@ -14,7 +14,7 @@
#include <__random/shuffle_order_engine.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/linear_congruential_engine.h
@@ -16,7 +16,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -218,8 +218,8 @@ private:
static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");
static_assert(is_unsigned<_UIntType>::value, "_UIntType must be unsigned type");
public:
- static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u;
- static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u;
+ static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u : 0u;
+ static _LIBCPP_CONSTEXPR const result_type _Max = __m - _UIntType(1u);
static_assert(_Min < _Max, "linear_congruential_engine invalid parameters");
// engine characteristics
lib/libcxx/include/__random/log2.h
@@ -14,7 +14,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/lognormal_distribution.h
@@ -16,7 +16,7 @@
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/mersenne_twister_engine.h
@@ -20,7 +20,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/negative_binomial_distribution.h
@@ -12,12 +12,13 @@
#include <__config>
#include <__random/bernoulli_distribution.h>
#include <__random/gamma_distribution.h>
+#include <__random/is_valid.h>
#include <__random/poisson_distribution.h>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -28,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _IntType = int>
class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution
{
+ static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
public:
// types
typedef _IntType result_type;
@@ -116,9 +118,12 @@ template<class _URNG>
_IntType
negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
result_type __k = __pr.k();
double __p = __pr.p();
- if (__k <= 21 * __p)
+ // When the number of bits in _IntType is small, we are too likely to
+ // overflow __f below to use this technique.
+ if (__k <= 21 * __p && sizeof(_IntType) > 1)
{
bernoulli_distribution __gen(__p);
result_type __f = 0;
@@ -130,6 +135,8 @@ negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_
else
++__f;
}
+ _LIBCPP_ASSERT(__f >= 0, "std::negative_binomial_distribution should never produce negative values. "
+ "This is almost certainly a signed integer overflow issue on __f.");
return __f;
}
return poisson_distribution<result_type>(gamma_distribution<double>
lib/libcxx/include/__random/normal_distribution.h
@@ -10,13 +10,14 @@
#define _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H
#include <__config>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -131,6 +132,7 @@ template<class _URNG>
_RealType
normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
result_type _Up;
if (_V_hot_)
{
lib/libcxx/include/__random/piecewise_constant_distribution.h
@@ -11,13 +11,14 @@
#include <__algorithm/upper_bound.h>
#include <__config>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <iosfwd>
#include <numeric>
#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -42,8 +43,8 @@ public:
param_type();
template<class _InputIteratorB, class _InputIteratorW>
- param_type(_InputIteratorB __fB, _InputIteratorB __lB,
- _InputIteratorW __fW);
+ param_type(_InputIteratorB __f_b, _InputIteratorB __l_b,
+ _InputIteratorW __f_w);
#ifndef _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
@@ -93,10 +94,10 @@ public:
piecewise_constant_distribution() {}
template<class _InputIteratorB, class _InputIteratorW>
_LIBCPP_INLINE_VISIBILITY
- piecewise_constant_distribution(_InputIteratorB __fB,
- _InputIteratorB __lB,
- _InputIteratorW __fW)
- : __p_(__fB, __lB, __fW) {}
+ piecewise_constant_distribution(_InputIteratorB __f_b,
+ _InputIteratorB __l_b,
+ _InputIteratorW __f_w)
+ : __p_(__f_b, __l_b, __f_w) {}
#ifndef _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
@@ -214,8 +215,8 @@ piecewise_constant_distribution<_RealType>::param_type::param_type()
template<class _RealType>
template<class _InputIteratorB, class _InputIteratorW>
piecewise_constant_distribution<_RealType>::param_type::param_type(
- _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)
- : __b_(__fB, __lB)
+ _InputIteratorB __f_b, _InputIteratorB __l_b, _InputIteratorW __f_w)
+ : __b_(__f_b, __l_b)
{
if (__b_.size() < 2)
{
@@ -228,8 +229,8 @@ piecewise_constant_distribution<_RealType>::param_type::param_type(
else
{
__densities_.reserve(__b_.size() - 1);
- for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW)
- __densities_.push_back(*__fW);
+ for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__f_w)
+ __densities_.push_back(*__f_w);
__init();
}
}
@@ -284,6 +285,7 @@ template<class _URNG>
_RealType
piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
typedef uniform_real_distribution<result_type> _Gen;
result_type __u = _Gen()(__g);
ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),
lib/libcxx/include/__random/piecewise_linear_distribution.h
@@ -11,13 +11,14 @@
#include <__algorithm/upper_bound.h>
#include <__config>
+#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
#include <iosfwd>
#include <numeric>
#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -42,8 +43,8 @@ public:
param_type();
template<class _InputIteratorB, class _InputIteratorW>
- param_type(_InputIteratorB __fB, _InputIteratorB __lB,
- _InputIteratorW __fW);
+ param_type(_InputIteratorB __f_b, _InputIteratorB __l_b,
+ _InputIteratorW __f_w);
#ifndef _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
@@ -93,10 +94,10 @@ public:
piecewise_linear_distribution() {}
template<class _InputIteratorB, class _InputIteratorW>
_LIBCPP_INLINE_VISIBILITY
- piecewise_linear_distribution(_InputIteratorB __fB,
- _InputIteratorB __lB,
- _InputIteratorW __fW)
- : __p_(__fB, __lB, __fW) {}
+ piecewise_linear_distribution(_InputIteratorB __f_b,
+ _InputIteratorB __l_b,
+ _InputIteratorW __f_w)
+ : __p_(__f_b, __l_b, __f_w) {}
#ifndef _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
@@ -218,8 +219,8 @@ piecewise_linear_distribution<_RealType>::param_type::param_type()
template<class _RealType>
template<class _InputIteratorB, class _InputIteratorW>
piecewise_linear_distribution<_RealType>::param_type::param_type(
- _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)
- : __b_(__fB, __lB)
+ _InputIteratorB __f_b, _InputIteratorB __l_b, _InputIteratorW __f_w)
+ : __b_(__f_b, __l_b)
{
if (__b_.size() < 2)
{
@@ -232,8 +233,8 @@ piecewise_linear_distribution<_RealType>::param_type::param_type(
else
{
__densities_.reserve(__b_.size());
- for (size_t __i = 0; __i < __b_.size(); ++__i, ++__fW)
- __densities_.push_back(*__fW);
+ for (size_t __i = 0; __i < __b_.size(); ++__i, ++__f_w)
+ __densities_.push_back(*__f_w);
__init();
}
}
@@ -289,6 +290,7 @@ template<class _URNG>
_RealType
piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
typedef uniform_real_distribution<result_type> _Gen;
result_type __u = _Gen()(__g);
ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),
lib/libcxx/include/__random/poisson_distribution.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__random/clamp_to_integral.h>
#include <__random/exponential_distribution.h>
+#include <__random/is_valid.h>
#include <__random/normal_distribution.h>
#include <__random/uniform_real_distribution.h>
#include <cmath>
@@ -19,7 +20,7 @@
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -30,6 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _IntType = int>
class _LIBCPP_TEMPLATE_VIS poisson_distribution
{
+ static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
public:
// types
typedef _IntType result_type;
@@ -157,6 +159,7 @@ template<class _URNG>
_IntType
poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
double __tx;
uniform_real_distribution<double> __urd;
if (__pr.__mean_ < 10)
lib/libcxx/include/__random/random_device.h
@@ -13,7 +13,7 @@
#include <string>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -28,10 +28,8 @@ class _LIBCPP_TYPE_VIS random_device
#ifdef _LIBCPP_USING_DEV_RANDOM
int __f_;
#elif !defined(_LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT)
-# if defined(__clang__)
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wunused-private-field"
-# endif
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field")
// Apple platforms used to use the `_LIBCPP_USING_DEV_RANDOM` code path, and now
// use `arc4random()` as of this comment. In order to avoid breaking the ABI, we
@@ -42,9 +40,7 @@ class _LIBCPP_TYPE_VIS random_device
// ... vendors can add workarounds here if they switch to a different representation ...
-# if defined(__clang__)
-# pragma clang diagnostic pop
-# endif
+ _LIBCPP_DIAGNOSTIC_POP
#endif
public:
lib/libcxx/include/__random/ranlux.h
@@ -15,7 +15,7 @@
#include <cstdint>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__random/seed_seq.h
@@ -17,7 +17,7 @@
#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -109,39 +109,63 @@ seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last)
__first[__q] += __r;
__first[0] = __r;
}
+ // Initialize indexing terms used with if statements as an optimization to
+ // avoid calculating modulo n on every loop iteration for each term.
+ size_t __kmodn = 0; // __k % __n
+ size_t __k1modn = __n - 1; // (__k - 1) % __n
+ size_t __kpmodn = __p % __n; // (__k + __p) % __n
+ size_t __kqmodn = __q % __n; // (__k + __q) % __n
+
for (size_t __k = 1; __k <= __s; ++__k)
{
- const size_t __kmodn = __k % __n;
- const size_t __kpmodn = (__k + __p) % __n;
- result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn]
- ^ __first[(__k - 1) % __n]);
- __first[__kpmodn] += __r;
- __r += __kmodn + __v_[__k-1];
- __first[(__k + __q) % __n] += __r;
- __first[__kmodn] = __r;
+ if (++__kmodn == __n)
+ __kmodn = 0;
+ if (++__k1modn == __n)
+ __k1modn = 0;
+ if (++__kpmodn == __n)
+ __kpmodn = 0;
+ if (++__kqmodn == __n)
+ __kqmodn = 0;
+
+ result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__k1modn]);
+ __first[__kpmodn] += __r;
+ __r += __kmodn + __v_[__k - 1];
+ __first[__kqmodn] += __r;
+ __first[__kmodn] = __r;
}
for (size_t __k = __s + 1; __k < __m; ++__k)
{
- const size_t __kmodn = __k % __n;
- const size_t __kpmodn = (__k + __p) % __n;
- result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn]
- ^ __first[(__k - 1) % __n]);
- __first[__kpmodn] += __r;
- __r += __kmodn;
- __first[(__k + __q) % __n] += __r;
- __first[__kmodn] = __r;
+ if (++__kmodn == __n)
+ __kmodn = 0;
+ if (++__k1modn == __n)
+ __k1modn = 0;
+ if (++__kpmodn == __n)
+ __kpmodn = 0;
+ if (++__kqmodn == __n)
+ __kqmodn = 0;
+
+ result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__k1modn]);
+ __first[__kpmodn] += __r;
+ __r += __kmodn;
+ __first[__kqmodn] += __r;
+ __first[__kmodn] = __r;
}
for (size_t __k = __m; __k < __m + __n; ++__k)
{
- const size_t __kmodn = __k % __n;
- const size_t __kpmodn = (__k + __p) % __n;
- result_type __r = 1566083941 * _Tp(__first[__kmodn] +
- __first[__kpmodn] +
- __first[(__k - 1) % __n]);
- __first[__kpmodn] ^= __r;
- __r -= __kmodn;
- __first[(__k + __q) % __n] ^= __r;
- __first[__kmodn] = __r;
+ if (++__kmodn == __n)
+ __kmodn = 0;
+ if (++__k1modn == __n)
+ __k1modn = 0;
+ if (++__kpmodn == __n)
+ __kpmodn = 0;
+ if (++__kqmodn == __n)
+ __kqmodn = 0;
+
+ result_type __r = 1566083941 * _Tp(__first[__kmodn] + __first[__kpmodn] + __first[__k1modn]);
+ __first[__kpmodn] ^= __r;
+ __r -= __kmodn;
+ __first[__kqmodn] ^= __r;
+ __first[__kmodn] = __r;
}
}
}
lib/libcxx/include/__random/shuffle_order_engine.h
@@ -18,7 +18,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/student_t_distribution.h
@@ -11,13 +11,14 @@
#include <__config>
#include <__random/gamma_distribution.h>
+#include <__random/is_valid.h>
#include <__random/normal_distribution.h>
#include <cmath>
#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -111,6 +112,7 @@ template<class _URNG>
_RealType
student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
gamma_distribution<result_type> __gd(__p.n() * .5, 2);
return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g));
}
lib/libcxx/include/__random/subtract_with_carry_engine.h
@@ -21,7 +21,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__random/uniform_int_distribution.h
@@ -11,6 +11,7 @@
#include <__bits>
#include <__config>
+#include <__random/is_valid.h>
#include <__random/log2.h>
#include <bit>
#include <cstddef>
@@ -20,7 +21,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -155,9 +156,10 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
return _Sp;
}
-template<class _IntType = int> // __int128_t is also supported as an extension here
+template<class _IntType = int>
class uniform_int_distribution
{
+ static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
public:
// types
typedef _IntType result_type;
@@ -230,6 +232,7 @@ typename uniform_int_distribution<_IntType>::result_type
uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), uint32_t,
typename make_unsigned<result_type>::type>::type _UIntType;
const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);
lib/libcxx/include/__random/uniform_random_bit_generator.h
@@ -16,7 +16,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [rand.req.urng]
template<class _Gen>
@@ -36,7 +36,7 @@ concept uniform_random_bit_generator =
requires bool_constant<(_Gen::min() < _Gen::max())>::value;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__random/uniform_real_distribution.h
@@ -11,12 +11,13 @@
#include <__config>
#include <__random/generate_canonical.h>
+#include <__random/is_valid.h>
#include <iosfwd>
#include <limits>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -115,6 +116,7 @@ inline
typename uniform_real_distribution<_RealType>::result_type
uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
+ static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
return (__p.b() - __p.a())
* _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)
+ __p.a();
lib/libcxx/include/__random/weibull_distribution.h
@@ -16,7 +16,7 @@
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__ranges/access.h
@@ -14,18 +14,16 @@
#include <__iterator/concepts.h>
#include <__iterator/readable_traits.h>
#include <__ranges/enable_borrowed_range.h>
-#include <__utility/as_const.h>
#include <__utility/auto_cast.h>
-#include <concepts>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template <class _Tp>
@@ -60,14 +58,14 @@ namespace __begin {
struct __fn {
template <class _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept
- requires (sizeof(_Tp) != 0) // Disallow incomplete element types.
+ requires (sizeof(_Tp) >= 0) // Disallow incomplete element types.
{
return __t + 0;
}
template <class _Tp, size_t _Np>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
- requires (sizeof(_Tp) != 0) // Disallow incomplete element types.
+ requires (sizeof(_Tp) >= 0) // Disallow incomplete element types.
{
return __t + 0;
}
@@ -130,11 +128,10 @@ namespace __end {
{ _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>;
};
- class __fn {
- public:
+ struct __fn {
template <class _Tp, size_t _Np>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept
- requires (sizeof(_Tp) != 0) // Disallow incomplete element types.
+ requires (sizeof(_Tp) >= 0) // Disallow incomplete element types.
{
return __t + _Np;
}
@@ -220,7 +217,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/all.h
@@ -23,12 +23,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges::views {
@@ -38,30 +38,31 @@ namespace __all {
requires ranges::view<decay_t<_Tp>>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t))))
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))
+ -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))
{
- return _LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t));
+ return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t));
}
template<class _Tp>
requires (!ranges::view<decay_t<_Tp>>) &&
- requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; }
+ requires (_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(ranges::ref_view{_VSTD::forward<_Tp>(__t)}))
+ noexcept(noexcept(ranges::ref_view{std::forward<_Tp>(__t)}))
{
- return ranges::ref_view{_VSTD::forward<_Tp>(__t)};
+ return ranges::ref_view{std::forward<_Tp>(__t)};
}
template<class _Tp>
requires (!ranges::view<decay_t<_Tp>> &&
- !requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } &&
- requires (_Tp&& __t) { ranges::owning_view{_VSTD::forward<_Tp>(__t)}; })
+ !requires (_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; } &&
+ requires (_Tp&& __t) { ranges::owning_view{std::forward<_Tp>(__t)}; })
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(ranges::owning_view{_VSTD::forward<_Tp>(__t)}))
+ noexcept(noexcept(ranges::owning_view{std::forward<_Tp>(__t)}))
{
- return ranges::owning_view{_VSTD::forward<_Tp>(__t)};
+ return ranges::owning_view{std::forward<_Tp>(__t)};
}
};
} // namespace __all
@@ -75,7 +76,7 @@ using all_t = decltype(views::all(declval<_Range>()));
} // namespace ranges::views
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/common_view.h
@@ -25,12 +25,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
@@ -44,13 +44,13 @@ public:
common_view() requires default_initializable<_View> = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit common_view(_View __v) : __base_(_VSTD::move(__v)) { }
+ constexpr explicit common_view(_View __v) : __base_(std::move(__v)) { }
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
_LIBCPP_HIDE_FROM_ABI
- constexpr _View base() && { return _VSTD::move(__base_); }
+ constexpr _View base() && { return std::move(__base_); }
_LIBCPP_HIDE_FROM_ABI
constexpr auto begin() {
@@ -109,16 +109,16 @@ namespace __common {
requires common_range<_Range>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range) const
- noexcept(noexcept(views::all(_VSTD::forward<_Range>(__range))))
- -> decltype( views::all(_VSTD::forward<_Range>(__range)))
- { return views::all(_VSTD::forward<_Range>(__range)); }
+ noexcept(noexcept(views::all(std::forward<_Range>(__range))))
+ -> decltype( views::all(std::forward<_Range>(__range)))
+ { return views::all(std::forward<_Range>(__range)); }
template<class _Range>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range) const
- noexcept(noexcept(common_view{_VSTD::forward<_Range>(__range)}))
- -> decltype( common_view{_VSTD::forward<_Range>(__range)})
- { return common_view{_VSTD::forward<_Range>(__range)}; }
+ noexcept(noexcept(common_view{std::forward<_Range>(__range)}))
+ -> decltype( common_view{std::forward<_Range>(__range)})
+ { return common_view{std::forward<_Range>(__range)}; }
};
} // namespace __common
@@ -128,7 +128,7 @@ inline namespace __cpo {
} // namespace views
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/concepts.h
@@ -27,12 +27,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -135,7 +135,7 @@ namespace ranges {
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/copyable_box.h
@@ -19,12 +19,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into
// a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state
@@ -41,7 +41,7 @@ namespace ranges {
// Primary template - uses std::optional and introduces an empty state in case assignment fails.
template<__copy_constructible_object _Tp>
class __copyable_box {
- [[no_unique_address]] optional<_Tp> __val_;
+ _LIBCPP_NO_UNIQUE_ADDRESS optional<_Tp> __val_;
public:
template<class ..._Args>
@@ -49,7 +49,7 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr explicit __copyable_box(in_place_t, _Args&& ...__args)
noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
- : __val_(in_place, _VSTD::forward<_Args>(__args)...)
+ : __val_(in_place, std::forward<_Args>(__args)...)
{ }
_LIBCPP_HIDE_FROM_ABI
@@ -65,7 +65,7 @@ namespace ranges {
constexpr __copyable_box& operator=(__copyable_box const& __other)
noexcept(is_nothrow_copy_constructible_v<_Tp>)
{
- if (this != _VSTD::addressof(__other)) {
+ if (this != std::addressof(__other)) {
if (__other.__has_value()) __val_.emplace(*__other);
else __val_.reset();
}
@@ -79,8 +79,8 @@ namespace ranges {
constexpr __copyable_box& operator=(__copyable_box&& __other)
noexcept(is_nothrow_move_constructible_v<_Tp>)
{
- if (this != _VSTD::addressof(__other)) {
- if (__other.__has_value()) __val_.emplace(_VSTD::move(*__other));
+ if (this != std::addressof(__other)) {
+ if (__other.__has_value()) __val_.emplace(std::move(*__other));
else __val_.reset();
}
return *this;
@@ -116,7 +116,7 @@ namespace ranges {
template<__copy_constructible_object _Tp>
requires __doesnt_need_empty_state_for_copy<_Tp> && __doesnt_need_empty_state_for_move<_Tp>
class __copyable_box<_Tp> {
- [[no_unique_address]] _Tp __val_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Tp __val_;
public:
template<class ..._Args>
@@ -124,7 +124,7 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr explicit __copyable_box(in_place_t, _Args&& ...__args)
noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
- : __val_(_VSTD::forward<_Args>(__args)...)
+ : __val_(std::forward<_Args>(__args)...)
{ }
_LIBCPP_HIDE_FROM_ABI
@@ -144,9 +144,9 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr __copyable_box& operator=(__copyable_box const& __other) noexcept {
static_assert(is_nothrow_copy_constructible_v<_Tp>);
- if (this != _VSTD::addressof(__other)) {
- _VSTD::destroy_at(_VSTD::addressof(__val_));
- _VSTD::construct_at(_VSTD::addressof(__val_), __other.__val_);
+ if (this != std::addressof(__other)) {
+ std::destroy_at(std::addressof(__val_));
+ std::construct_at(std::addressof(__val_), __other.__val_);
}
return *this;
}
@@ -154,9 +154,9 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr __copyable_box& operator=(__copyable_box&& __other) noexcept {
static_assert(is_nothrow_move_constructible_v<_Tp>);
- if (this != _VSTD::addressof(__other)) {
- _VSTD::destroy_at(_VSTD::addressof(__val_));
- _VSTD::construct_at(_VSTD::addressof(__val_), _VSTD::move(__other.__val_));
+ if (this != std::addressof(__other)) {
+ std::destroy_at(std::addressof(__val_));
+ std::construct_at(std::addressof(__val_), std::move(__other.__val_));
}
return *this;
}
@@ -164,14 +164,14 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const noexcept { return __val_; }
_LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() noexcept { return __val_; }
- _LIBCPP_HIDE_FROM_ABI constexpr const _Tp *operator->() const noexcept { return _VSTD::addressof(__val_); }
- _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return _VSTD::addressof(__val_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Tp *operator->() const noexcept { return std::addressof(__val_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return std::addressof(__val_); }
_LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return true; }
};
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/counted.h
@@ -24,12 +24,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges::views {
@@ -39,9 +39,9 @@ namespace __counted {
template<contiguous_iterator _It>
_LIBCPP_HIDE_FROM_ABI
static constexpr auto __go(_It __it, iter_difference_t<_It> __count)
- noexcept(noexcept(span(_VSTD::to_address(__it), static_cast<size_t>(__count))))
+ noexcept(noexcept(span(std::to_address(__it), static_cast<size_t>(__count))))
// Deliberately omit return-type SFINAE, because to_address is not SFINAE-friendly
- { return span(_VSTD::to_address(__it), static_cast<size_t>(__count)); }
+ { return span(std::to_address(__it), static_cast<size_t>(__count)); }
template<random_access_iterator _It>
_LIBCPP_HIDE_FROM_ABI
@@ -53,17 +53,17 @@ namespace __counted {
template<class _It>
_LIBCPP_HIDE_FROM_ABI
static constexpr auto __go(_It __it, iter_difference_t<_It> __count)
- noexcept(noexcept(subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel)))
- -> decltype( subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel))
- { return subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel); }
+ noexcept(noexcept(subrange(counted_iterator(std::move(__it), __count), default_sentinel)))
+ -> decltype( subrange(counted_iterator(std::move(__it), __count), default_sentinel))
+ { return subrange(counted_iterator(std::move(__it), __count), default_sentinel); }
template<class _It, convertible_to<iter_difference_t<_It>> _Diff>
requires input_or_output_iterator<decay_t<_It>>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_It&& __it, _Diff&& __count) const
- noexcept(noexcept(__go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count))))
- -> decltype( __go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count)))
- { return __go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count)); }
+ noexcept(noexcept(__go(std::forward<_It>(__it), std::forward<_Diff>(__count))))
+ -> decltype( __go(std::forward<_It>(__it), std::forward<_Diff>(__count)))
+ { return __go(std::forward<_It>(__it), std::forward<_Diff>(__count)); }
};
} // namespace __counted
@@ -74,7 +74,7 @@ inline namespace __cpo {
} // namespace ranges::views
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/dangling.h
@@ -16,12 +16,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
struct dangling {
@@ -35,7 +35,7 @@ using borrowed_iterator_t = _If<borrowed_range<_Rp>, iterator_t<_Rp>, dangling>;
// borrowed_subrange_t defined in <__ranges/subrange.h>
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/data.h
@@ -19,12 +19,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// [range.prim.data]
@@ -60,8 +60,8 @@ namespace __data {
template<__ranges_begin_invocable _Tp>
_LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_VSTD::to_address(ranges::begin(__t)))) {
- return _VSTD::to_address(ranges::begin(__t));
+ noexcept(noexcept(std::to_address(ranges::begin(__t)))) {
+ return std::to_address(ranges::begin(__t));
}
};
} // namespace __data
@@ -99,7 +99,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/drop_view.h
@@ -9,29 +9,43 @@
#ifndef _LIBCPP___RANGES_DROP_VIEW_H
#define _LIBCPP___RANGES_DROP_VIEW_H
+#include <__algorithm/min.h>
+#include <__assert>
#include <__config>
-#include <__debug>
+#include <__functional/bind_back.h>
+#include <__fwd/span.h>
+#include <__fwd/string_view.h>
#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
#include <__ranges/access.h>
#include <__ranges/all.h>
#include <__ranges/concepts.h>
+#include <__ranges/empty_view.h>
#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/iota_view.h>
#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
#include <__ranges/size.h>
+#include <__ranges/subrange.h>
#include <__ranges/view_interface.h>
+#include <__utility/auto_cast.h>
+#include <__utility/forward.h>
#include <__utility/move.h>
#include <concepts>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<view _View>
@@ -45,7 +59,7 @@ namespace ranges {
// one can't call begin() on it more than once.
static constexpr bool _UseCache = forward_range<_View> && !(random_access_range<_View> && sized_range<_View>);
using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
- [[no_unique_address]] _Cache __cached_begin_ = _Cache();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
range_difference_t<_View> __count_ = 0;
_View __base_ = _View();
@@ -55,13 +69,13 @@ public:
_LIBCPP_HIDE_FROM_ABI
constexpr drop_view(_View __base, range_difference_t<_View> __count)
: __count_(__count)
- , __base_(_VSTD::move(__base))
+ , __base_(std::move(__base))
{
_LIBCPP_ASSERT(__count_ >= 0, "count must be greater than or equal to zero.");
}
_LIBCPP_HIDE_FROM_ABI constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
- _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return _VSTD::move(__base_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
_LIBCPP_HIDE_FROM_ABI
constexpr auto begin()
@@ -113,15 +127,180 @@ public:
{ return __size(*this); }
};
- template<class _Range>
- drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>;
+template<class _Range>
+drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>;
+
+template<class _Tp>
+inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>;
+
+namespace views {
+namespace __drop {
+
+template <class _Tp>
+inline constexpr bool __is_empty_view = false;
+
+template <class _Tp>
+inline constexpr bool __is_empty_view<empty_view<_Tp>> = true;
+
+template <class _Tp>
+inline constexpr bool __is_passthrough_specialization = false;
+
+template <class _Tp, size_t _Extent>
+inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true;
+
+template <class _CharT, class _Traits>
+inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true;
+
+template <class _Np, class _Bound>
+inline constexpr bool __is_passthrough_specialization<iota_view<_Np, _Bound>> = true;
+
+template <class _Iter, class _Sent, subrange_kind _Kind>
+inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> =
+ !subrange<_Iter, _Sent, _Kind>::_StoreSize;
+
+template <class _Tp>
+inline constexpr bool __is_subrange_specialization_with_store_size = false;
+
+template <class _Iter, class _Sent, subrange_kind _Kind>
+inline constexpr bool __is_subrange_specialization_with_store_size<subrange<_Iter, _Sent, _Kind>> =
+ subrange<_Iter, _Sent, _Kind>::_StoreSize;
+
+template <class _Tp>
+struct __passthrough_type;
+
+template <class _Tp, size_t _Extent>
+struct __passthrough_type<span<_Tp, _Extent>> {
+ using type = span<_Tp>;
+};
+
+template <class _CharT, class _Traits>
+struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
+ using type = basic_string_view<_CharT, _Traits>;
+};
+
+template <class _Np, class _Bound>
+struct __passthrough_type<iota_view<_Np, _Bound>> {
+ using type = iota_view<_Np, _Bound>;
+};
+
+template <class _Iter, class _Sent, subrange_kind _Kind>
+struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
+ using type = subrange<_Iter, _Sent, _Kind>;
+};
+
+template <class _Tp>
+using __passthrough_type_t = typename __passthrough_type<_Tp>::type;
+
+struct __fn {
+ // [range.drop.overview]: the `empty_view` case.
+ template <class _Range, convertible_to<range_difference_t<_Range>> _Np>
+ requires __is_empty_view<remove_cvref_t<_Range>>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range, _Np&&) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
+ -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
+ { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
+
+ // [range.drop.overview]: the `span | basic_string_view | iota_view | subrange (StoreSize == false)` case.
+ template <class _Range,
+ convertible_to<range_difference_t<_Range>> _Np,
+ class _RawRange = remove_cvref_t<_Range>,
+ class _Dist = range_difference_t<_Range>>
+ requires (!__is_empty_view<_RawRange> &&
+ random_access_range<_RawRange> &&
+ sized_range<_RawRange> &&
+ __is_passthrough_specialization<_RawRange>)
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __rng, _Np&& __n) const
+ noexcept(noexcept(__passthrough_type_t<_RawRange>(
+ ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
+ ranges::end(__rng)
+ )))
+ -> decltype( __passthrough_type_t<_RawRange>(
+ // Note: deliberately not forwarding `__rng` to guard against double moves.
+ ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
+ ranges::end(__rng)
+ ))
+ { return __passthrough_type_t<_RawRange>(
+ ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
+ ranges::end(__rng)
+ ); }
+
+ // [range.drop.overview]: the `subrange (StoreSize == true)` case.
+ template <class _Range,
+ convertible_to<range_difference_t<_Range>> _Np,
+ class _RawRange = remove_cvref_t<_Range>,
+ class _Dist = range_difference_t<_Range>>
+ requires (!__is_empty_view<_RawRange> &&
+ random_access_range<_RawRange> &&
+ sized_range<_RawRange> &&
+ __is_subrange_specialization_with_store_size<_RawRange>)
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __rng, _Np&& __n) const
+ noexcept(noexcept(_RawRange(
+ ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
+ ranges::end(__rng),
+ std::__to_unsigned_like(ranges::distance(__rng) -
+ std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)))
+ )))
+ -> decltype( _RawRange(
+ // Note: deliberately not forwarding `__rng` to guard against double moves.
+ ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)),
+ ranges::end(__rng),
+ std::__to_unsigned_like(ranges::distance(__rng) -
+ std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)))
+ ))
+ {
+ // Introducing local variables avoids calculating `min` and `distance` twice (at the cost of diverging from the
+ // expression used in the `noexcept` clause and the return statement).
+ auto dist = ranges::distance(__rng);
+ auto clamped = std::min<_Dist>(dist, std::forward<_Np>(__n));
+ return _RawRange(
+ ranges::begin(__rng) + clamped,
+ ranges::end(__rng),
+ std::__to_unsigned_like(dist - clamped)
+ );}
+
+ // [range.drop.overview]: the "otherwise" case.
+ template <class _Range, convertible_to<range_difference_t<_Range>> _Np,
+ class _RawRange = remove_cvref_t<_Range>>
+ // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other
+ // overloads.
+ requires (!(__is_empty_view<_RawRange> ||
+ (__is_subrange_specialization_with_store_size<_RawRange> &&
+ sized_range<_RawRange> &&
+ random_access_range<_RawRange>) ||
+ (__is_passthrough_specialization<_RawRange> &&
+ sized_range<_RawRange> &&
+ random_access_range<_RawRange>)
+ ))
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range, _Np&& __n) const
+ noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))))
+ -> decltype( drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))
+ { return drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); }
+
+ template <class _Np>
+ requires constructible_from<decay_t<_Np>, _Np>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Np&& __n) const
+ noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>)
+ { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); }
+};
+
+} // namespace __drop
+
+inline namespace __cpo {
+ inline constexpr auto drop = __drop::__fn{};
+} // namespace __cpo
+} // namespace views
- template<class _Tp>
- inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>;
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___RANGES_DROP_VIEW_H
lib/libcxx/include/__ranges/empty.h
@@ -17,12 +17,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// [range.prim.empty]
@@ -75,7 +75,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/empty_view.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<class _Tp>
@@ -36,9 +36,16 @@ namespace ranges {
template<class _Tp>
inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true;
+
+ namespace views {
+
+ template <class _Tp>
+ inline constexpr empty_view<_Tp> empty{};
+
+ } // namespace views
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/enable_borrowed_range.h
@@ -17,12 +17,12 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -33,7 +33,7 @@ inline constexpr bool enable_borrowed_range = false;
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/enable_view.h
@@ -15,12 +15,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -40,7 +40,7 @@ inline constexpr bool enable_view = derived_from<_Tp, view_base> ||
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/filter_view.h
@@ -0,0 +1,259 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_FILTER_VIEW_H
+#define _LIBCPP___RANGES_FILTER_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__config>
+#include <__debug>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/copyable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/view_interface.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+ template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
+ requires view<_View> && is_object_v<_Pred>
+ class filter_view : public view_interface<filter_view<_View, _Pred>> {
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+ _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_;
+
+ // We cache the result of begin() to allow providing an amortized O(1) begin() whenever
+ // the underlying range is at least a forward_range.
+ static constexpr bool _UseCache = forward_range<_View>;
+ using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
+
+ class __iterator;
+ class __sentinel;
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ filter_view() requires default_initializable<_View> && default_initializable<_Pred> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr filter_view(_View __base, _Pred __pred)
+ : __base_(std::move(__base)), __pred_(in_place, std::move(__pred))
+ { }
+
+ template<class _Vp = _View>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_Vp> { return __base_; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return std::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Pred const& pred() const { return *__pred_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator begin() {
+ _LIBCPP_ASSERT(__pred_.__has_value(), "Trying to call begin() on a filter_view that does not have a valid predicate.");
+ if constexpr (_UseCache) {
+ if (!__cached_begin_.__has_value()) {
+ __cached_begin_.__emplace(ranges::find_if(__base_, std::ref(*__pred_)));
+ }
+ return {*this, *__cached_begin_};
+ } else {
+ return {*this, ranges::find_if(__base_, std::ref(*__pred_))};
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() {
+ if constexpr (common_range<_View>)
+ return __iterator{*this, ranges::end(__base_)};
+ else
+ return __sentinel{*this};
+ }
+ };
+
+ template<class _Range, class _Pred>
+ filter_view(_Range&&, _Pred) -> filter_view<views::all_t<_Range>, _Pred>;
+
+ template<class _View>
+ struct __filter_iterator_category { };
+
+ template<forward_range _View>
+ struct __filter_iterator_category<_View> {
+ using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category;
+ using iterator_category =
+ _If<derived_from<_Cat, bidirectional_iterator_tag>, bidirectional_iterator_tag,
+ _If<derived_from<_Cat, forward_iterator_tag>, forward_iterator_tag,
+ /* else */ _Cat
+ >>;
+ };
+
+ template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
+ requires view<_View> && is_object_v<_Pred>
+ class filter_view<_View, _Pred>::__iterator : public __filter_iterator_category<_View> {
+ public:
+ _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __current_ = iterator_t<_View>();
+ _LIBCPP_NO_UNIQUE_ADDRESS filter_view* __parent_ = nullptr;
+
+ using iterator_concept =
+ _If<bidirectional_range<_View>, bidirectional_iterator_tag,
+ _If<forward_range<_View>, forward_iterator_tag,
+ /* else */ input_iterator_tag
+ >>;
+ // using iterator_category = inherited;
+ using value_type = range_value_t<_View>;
+ using difference_type = range_difference_t<_View>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ __iterator() requires default_initializable<iterator_t<_View>> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator(filter_view& __parent, iterator_t<_View> __current)
+ : __current_(std::move(__current)), __parent_(std::addressof(__parent))
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iterator_t<_View> const& base() const& noexcept { return __current_; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iterator_t<_View> base() && { return std::move(__current_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr range_reference_t<_View> operator*() const { return *__current_; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iterator_t<_View> operator->() const
+ requires __has_arrow<iterator_t<_View>> && copyable<iterator_t<_View>>
+ {
+ return __current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator++() {
+ __current_ = ranges::find_if(std::move(++__current_), ranges::end(__parent_->__base_),
+ std::ref(*__parent_->__pred_));
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator++(int) { ++*this; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator++(int) requires forward_range<_View> {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator--() requires bidirectional_range<_View> {
+ do {
+ --__current_;
+ } while (!std::invoke(*__parent_->__pred_, *__current_));
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator--(int) requires bidirectional_range<_View> {
+ auto tmp = *this;
+ --*this;
+ return tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(__iterator const& __x, __iterator const& __y)
+ requires equality_comparable<iterator_t<_View>>
+ {
+ return __x.__current_ == __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr range_rvalue_reference_t<_View> iter_move(__iterator const& __it)
+ noexcept(noexcept(ranges::iter_move(__it.__current_)))
+ {
+ return ranges::iter_move(__it.__current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr void iter_swap(__iterator const& __x, __iterator const& __y)
+ noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
+ requires indirectly_swappable<iterator_t<_View>>
+ {
+ return ranges::iter_swap(__x.__current_, __y.__current_);
+ }
+ };
+
+ template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
+ requires view<_View> && is_object_v<_Pred>
+ class filter_view<_View, _Pred>::__sentinel {
+ public:
+ sentinel_t<_View> __end_ = sentinel_t<_View>();
+
+ _LIBCPP_HIDE_FROM_ABI
+ __sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __sentinel(filter_view& __parent)
+ : __end_(ranges::end(__parent.__base_))
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr sentinel_t<_View> base() const { return __end_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(__iterator const& __x, __sentinel const& __y) {
+ return __x.__current_ == __y.__end_;
+ }
+ };
+
+namespace views {
+namespace __filter {
+ struct __fn {
+ template<class _Range, class _Pred>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
+ noexcept(noexcept(filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
+ -> decltype( filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)))
+ { return filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)); }
+
+ template<class _Pred>
+ requires constructible_from<decay_t<_Pred>, _Pred>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Pred&& __pred) const
+ noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>)
+ { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); }
+ };
+} // namespace __filter
+
+inline namespace __cpo {
+ inline constexpr auto filter = __filter::__fn{};
+} // namespace __cpo
+} // namespace views
+
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_FILTER_VIEW_H
lib/libcxx/include/__ranges/iota_view.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___RANGES_IOTA_VIEW_H
#define _LIBCPP___RANGES_IOTA_VIEW_H
+#include <__assert>
#include <__compare/three_way_comparable.h>
#include <__concepts/arithmetic.h>
#include <__concepts/constructible.h>
@@ -20,7 +21,6 @@
#include <__concepts/semiregular.h>
#include <__concepts/totally_ordered.h>
#include <__config>
-#include <__debug>
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
@@ -34,12 +34,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<class _Int>
@@ -90,9 +90,9 @@ namespace ranges {
using iterator_category = input_iterator_tag;
};
- template<weakly_incrementable _Start, semiregular _Bound = unreachable_sentinel_t>
- requires __weakly_equality_comparable_with<_Start, _Bound> && copyable<_Start>
- class iota_view : public view_interface<iota_view<_Start, _Bound>> {
+ template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t>
+ requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
+ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
struct __iterator : public __iota_iterator_category<_Start> {
friend class iota_view;
@@ -111,7 +111,7 @@ namespace ranges {
__iterator() requires default_initializable<_Start> = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit __iterator(_Start __value) : __value_(_VSTD::move(__value)) {}
+ constexpr explicit __iterator(_Start __value) : __value_(std::move(__value)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) {
@@ -271,127 +271,127 @@ namespace ranges {
friend class iota_view;
private:
- _Bound __bound_ = _Bound();
+ _BoundSentinel __bound_sentinel_ = _BoundSentinel();
public:
_LIBCPP_HIDE_FROM_ABI
__sentinel() = default;
- constexpr explicit __sentinel(_Bound __bound) : __bound_(_VSTD::move(__bound)) {}
+ constexpr explicit __sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {}
_LIBCPP_HIDE_FROM_ABI
friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) {
- return __x.__value_ == __y.__bound_;
+ return __x.__value_ == __y.__bound_sentinel_;
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y)
- requires sized_sentinel_for<_Bound, _Start>
+ requires sized_sentinel_for<_BoundSentinel, _Start>
{
- return __x.__value_ - __y.__bound_;
+ return __x.__value_ - __y.__bound_sentinel_;
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y)
- requires sized_sentinel_for<_Bound, _Start>
+ requires sized_sentinel_for<_BoundSentinel, _Start>
{
return -(__y - __x);
}
};
_Start __value_ = _Start();
- _Bound __bound_ = _Bound();
+ _BoundSentinel __bound_sentinel_ = _BoundSentinel();
public:
_LIBCPP_HIDE_FROM_ABI
iota_view() requires default_initializable<_Start> = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit iota_view(_Start __value) : __value_(_VSTD::move(__value)) { }
+ constexpr explicit iota_view(_Start __value) : __value_(std::move(__value)) { }
_LIBCPP_HIDE_FROM_ABI
- constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_Bound> __bound)
- : __value_(_VSTD::move(__value)), __bound_(_VSTD::move(__bound)) {
+ constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_BoundSentinel> __bound_sentinel)
+ : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) {
// Validate the precondition if possible.
- if constexpr (totally_ordered_with<_Start, _Bound>) {
- _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_),
+ if constexpr (totally_ordered_with<_Start, _BoundSentinel>) {
+ _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_sentinel_),
"Precondition violated: value is greater than bound.");
}
}
_LIBCPP_HIDE_FROM_ABI
constexpr iota_view(__iterator __first, __iterator __last)
- requires same_as<_Start, _Bound>
- : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last.__value_)) {}
+ requires same_as<_Start, _BoundSentinel>
+ : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {}
_LIBCPP_HIDE_FROM_ABI
- constexpr iota_view(__iterator __first, _Bound __last)
- requires same_as<_Bound, unreachable_sentinel_t>
- : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last)) {}
+ constexpr iota_view(__iterator __first, _BoundSentinel __last)
+ requires same_as<_BoundSentinel, unreachable_sentinel_t>
+ : iota_view(std::move(__first.__value_), std::move(__last)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr iota_view(__iterator __first, __sentinel __last)
- requires (!same_as<_Start, _Bound> && !same_as<_Start, unreachable_sentinel_t>)
- : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last.__bound_)) {}
+ requires(!same_as<_Start, _BoundSentinel> && !same_as<_Start, unreachable_sentinel_t>)
+ : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr __iterator begin() const { return __iterator{__value_}; }
_LIBCPP_HIDE_FROM_ABI
constexpr auto end() const {
- if constexpr (same_as<_Bound, unreachable_sentinel_t>)
+ if constexpr (same_as<_BoundSentinel, unreachable_sentinel_t>)
return unreachable_sentinel;
else
- return __sentinel{__bound_};
+ return __sentinel{__bound_sentinel_};
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator end() const requires same_as<_Start, _Bound> {
- return __iterator{__bound_};
+ constexpr __iterator end() const
+ requires same_as<_Start, _BoundSentinel>
+ {
+ return __iterator{__bound_sentinel_};
}
_LIBCPP_HIDE_FROM_ABI
constexpr auto size() const
- requires (same_as<_Start, _Bound> && __advanceable<_Start>) ||
- (integral<_Start> && integral<_Bound>) ||
- sized_sentinel_for<_Bound, _Start>
+ requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) ||
+ (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
{
- if constexpr (__integer_like<_Start> && __integer_like<_Bound>) {
+ if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) {
if (__value_ < 0) {
- if (__bound_ < 0) {
- return _VSTD::__to_unsigned_like(-__value_) - _VSTD::__to_unsigned_like(-__bound_);
+ if (__bound_sentinel_ < 0) {
+ return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_sentinel_);
}
- return _VSTD::__to_unsigned_like(__bound_) + _VSTD::__to_unsigned_like(-__value_);
+ return std::__to_unsigned_like(__bound_sentinel_) + std::__to_unsigned_like(-__value_);
}
- return _VSTD::__to_unsigned_like(__bound_) - _VSTD::__to_unsigned_like(__value_);
+ return std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_);
}
- return _VSTD::__to_unsigned_like(__bound_ - __value_);
+ return std::__to_unsigned_like(__bound_sentinel_ - __value_);
}
};
- template<class _Start, class _Bound>
- requires (!__integer_like<_Start> || !__integer_like<_Bound> ||
- (__signed_integer_like<_Start> == __signed_integer_like<_Bound>))
- iota_view(_Start, _Bound) -> iota_view<_Start, _Bound>;
+ template <class _Start, class _BoundSentinel>
+ requires(!__integer_like<_Start> || !__integer_like<_BoundSentinel> ||
+ (__signed_integer_like<_Start> == __signed_integer_like<_BoundSentinel>))
+ iota_view(_Start, _BoundSentinel) -> iota_view<_Start, _BoundSentinel>;
- template<class _Start, class _Bound>
- inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true;
+ template <class _Start, class _BoundSentinel>
+ inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true;
-namespace views {
-namespace __iota {
+ namespace views {
+ namespace __iota {
struct __fn {
template<class _Start>
_LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Start&& __start) const
- noexcept(noexcept(ranges::iota_view(_VSTD::forward<_Start>(__start))))
- -> decltype( ranges::iota_view(_VSTD::forward<_Start>(__start)))
- { return ranges::iota_view(_VSTD::forward<_Start>(__start)); }
-
- template<class _Start, class _Bound>
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()(_Start&& __start, _Bound&& __bound) const
- noexcept(noexcept(ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound))))
- -> decltype( ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound)))
- { return ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound)); }
+ noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start))))
+ -> decltype( ranges::iota_view(std::forward<_Start>(__start)))
+ { return ranges::iota_view(std::forward<_Start>(__start)); }
+
+ template <class _Start, class _BoundSentinel>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start, _BoundSentinel&& __bound_sentinel) const
+ noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))))
+ -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)))
+ { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)); }
};
} // namespace __iota
@@ -401,7 +401,7 @@ inline namespace __cpo {
} // namespace views
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/join_view.h
@@ -9,28 +9,33 @@
#ifndef _LIBCPP___RANGES_JOIN_VIEW_H
#define _LIBCPP___RANGES_JOIN_VIEW_H
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
#include <__config>
#include <__iterator/concepts.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
#include <__iterator/iterator_traits.h>
#include <__ranges/access.h>
#include <__ranges/all.h>
#include <__ranges/concepts.h>
#include <__ranges/non_propagating_cache.h>
-#include <__ranges/ref_view.h>
-#include <__ranges/subrange.h>
+#include <__ranges/range_adaptor.h>
#include <__ranges/view_interface.h>
-#include <__utility/declval.h>
#include <__utility/forward.h>
#include <optional>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<class>
@@ -45,7 +50,8 @@ namespace ranges {
using _InnerC = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category;
using iterator_category = _If<
- derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag>,
+ derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag> &&
+ common_range<range_reference_t<_View>>,
bidirectional_iterator_tag,
_If<
derived_from<_OuterC, forward_iterator_tag> && derived_from<_InnerC, forward_iterator_tag>,
@@ -67,8 +73,8 @@ namespace ranges {
static constexpr bool _UseCache = !is_reference_v<_InnerRange>;
using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;
- [[no_unique_address]] _Cache __cache_;
- _View __base_ = _View(); // TODO: [[no_unique_address]] makes clang crash! File a bug :)
+ _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cache_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
public:
_LIBCPP_HIDE_FROM_ABI
@@ -76,13 +82,13 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr explicit join_view(_View __base)
- : __base_(_VSTD::move(__base)) {}
+ : __base_(std::move(__base)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
_LIBCPP_HIDE_FROM_ABI
- constexpr _View base() && { return _VSTD::move(__base_); }
+ constexpr _View base() && { return std::move(__base_); }
_LIBCPP_HIDE_FROM_ABI
constexpr auto begin() {
@@ -152,7 +158,7 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr __sentinel(__sentinel<!_Const> __s)
requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
- : __end_(_VSTD::move(__s.__end_)) {}
+ : __end_(std::move(__s.__end_)) {}
template<bool _OtherConst>
requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
@@ -204,7 +210,8 @@ namespace ranges {
public:
using iterator_concept = _If<
- __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>>,
+ __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> &&
+ common_range<range_reference_t<_Base>>,
bidirectional_iterator_tag,
_If<
__ref_is_glvalue && forward_range<_Base> && forward_range<range_reference_t<_Base>>,
@@ -223,8 +230,8 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr __iterator(_Parent& __parent, _Outer __outer)
- : __outer_(_VSTD::move(__outer))
- , __parent_(_VSTD::addressof(__parent)) {
+ : __outer_(std::move(__outer))
+ , __parent_(std::addressof(__parent)) {
__satisfy();
}
@@ -233,8 +240,8 @@ namespace ranges {
requires _Const &&
convertible_to<iterator_t<_View>, _Outer> &&
convertible_to<iterator_t<_InnerRange>, _Inner>
- : __outer_(_VSTD::move(__i.__outer_))
- , __inner_(_VSTD::move(__i.__inner_))
+ : __outer_(std::move(__i.__outer_))
+ , __inner_(std::move(__i.__inner_))
, __parent_(__i.__parent_) {}
_LIBCPP_HIDE_FROM_ABI
@@ -338,12 +345,25 @@ namespace ranges {
template<class _Range>
explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;
-
+
+namespace views {
+namespace __join_view {
+struct __fn : __range_adaptor_closure<__fn> {
+ template<class _Range>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(join_view<all_t<_Range&&>>(std::forward<_Range>(__range))))
+ -> decltype( join_view<all_t<_Range&&>>(std::forward<_Range>(__range)))
+ { return join_view<all_t<_Range&&>>(std::forward<_Range>(__range)); }
+};
+} // namespace __join_view
+inline namespace __cpo {
+ inline constexpr auto join = __join_view::__fn{};
+} // namespace __cpo
+} // namespace views
} // namespace ranges
-#undef _CONSTEXPR_TERNARY
-
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/lazy_split_view.h
@@ -0,0 +1,465 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
+#define _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__algorithm/ranges_mismatch.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/derived_from.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/single_view.h>
+#include <__ranges/subrange.h>
+#include <__ranges/view_interface.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template <auto> struct __require_constant;
+
+template <class _Range>
+concept __tiny_range =
+ sized_range<_Range> &&
+ requires { typename __require_constant<remove_reference_t<_Range>::size()>; } &&
+ (remove_reference_t<_Range>::size() <= 1);
+
+template <input_range _View, forward_range _Pattern>
+ requires view<_View> && view<_Pattern> &&
+ indirectly_comparable<iterator_t<_View>, iterator_t<_Pattern>, ranges::equal_to> &&
+ (forward_range<_View> || __tiny_range<_Pattern>)
+class lazy_split_view : public view_interface<lazy_split_view<_View, _Pattern>> {
+
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();
+
+ using _MaybeCurrent = _If<!forward_range<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
+ _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();
+
+ template <bool> struct __outer_iterator;
+ template <bool> struct __inner_iterator;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ lazy_split_view()
+ requires default_initializable<_View> && default_initializable<_Pattern> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr lazy_split_view(_View __base, _Pattern __pattern)
+ : __base_(std::move(__base)), __pattern_(std::move(__pattern)) {}
+
+ template <input_range _Range>
+ requires constructible_from<_View, views::all_t<_Range>> &&
+ constructible_from<_Pattern, single_view<range_value_t<_Range>>>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr lazy_split_view(_Range&& __r, range_value_t<_Range> __e)
+ : __base_(views::all(std::forward<_Range>(__r)))
+ , __pattern_(views::single(std::move(__e))) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return std::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() {
+ if constexpr (forward_range<_View>) {
+ return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::begin(__base_)};
+ } else {
+ __current_.__emplace(ranges::begin(__base_));
+ return __outer_iterator<false>{*this};
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() const requires forward_range<_View> && forward_range<const _View> {
+ return __outer_iterator<true>{*this, ranges::begin(__base_)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() requires forward_range<_View> && common_range<_View> {
+ return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::end(__base_)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const {
+ if constexpr (forward_range<_View> && forward_range<const _View> && common_range<const _View>) {
+ return __outer_iterator<true>{*this, ranges::end(__base_)};
+ } else {
+ return default_sentinel;
+ }
+ }
+
+private:
+
+ template <class>
+ struct __outer_iterator_category {};
+
+ template <forward_range _Tp>
+ struct __outer_iterator_category<_Tp> {
+ using iterator_category = input_iterator_tag;
+ };
+
+ template <bool _Const>
+ struct __outer_iterator : __outer_iterator_category<__maybe_const<_Const, _View>> {
+ private:
+ template <bool>
+ friend struct __inner_iterator;
+ friend __outer_iterator<true>;
+
+ using _Parent = __maybe_const<_Const, lazy_split_view>;
+ using _Base = __maybe_const<_Const, _View>;
+
+ _Parent* __parent_ = nullptr;
+ using _MaybeCurrent = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>;
+ _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();
+ bool __trailing_empty_ = false;
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto& __current() noexcept {
+ if constexpr (forward_range<_View>) {
+ return __current_;
+ } else {
+ return *__parent_->__current_;
+ }
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr const auto& __current() const noexcept {
+ if constexpr (forward_range<_View>) {
+ return __current_;
+ } else {
+ return *__parent_->__current_;
+ }
+ }
+
+ // Workaround for the GCC issue that doesn't allow calling `__parent_->__base_` from friend functions (because
+ // `__base_` is private).
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto& __parent_base() const noexcept {
+ return __parent_->__base_;
+ }
+
+ public:
+ // using iterator_category = inherited;
+ using iterator_concept = conditional_t<forward_range<_Base>, forward_iterator_tag, input_iterator_tag>;
+ using difference_type = range_difference_t<_Base>;
+
+ struct value_type : view_interface<value_type> {
+ private:
+ __outer_iterator __i_ = __outer_iterator();
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ value_type() = default;
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit value_type(__outer_iterator __i)
+ : __i_(std::move(__i)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __inner_iterator<_Const> begin() const { return __inner_iterator<_Const>{__i_}; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
+ };
+
+ _LIBCPP_HIDE_FROM_ABI
+ __outer_iterator() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __outer_iterator(_Parent& __parent)
+ requires (!forward_range<_Base>)
+ : __parent_(std::addressof(__parent)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __outer_iterator(_Parent& __parent, iterator_t<_Base> __current)
+ requires forward_range<_Base>
+ : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __outer_iterator(__outer_iterator<!_Const> __i)
+ requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
+ : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr value_type operator*() const { return value_type{*this}; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __outer_iterator& operator++() {
+ const auto __end = ranges::end(__parent_->__base_);
+ if (__current() == __end) {
+ __trailing_empty_ = false;
+ return *this;
+ }
+
+ const auto [__pbegin, __pend] = ranges::subrange{__parent_->__pattern_};
+ if (__pbegin == __pend) {
+ // Empty pattern: split on every element in the input range
+ ++__current();
+
+ } else if constexpr (__tiny_range<_Pattern>) {
+ // One-element pattern: we can use `ranges::find`.
+ __current() = ranges::find(std::move(__current()), __end, *__pbegin);
+ if (__current() != __end) {
+ // Make sure we point to after the separator we just found.
+ ++__current();
+ if (__current() == __end)
+ __trailing_empty_ = true;
+ }
+
+ } else {
+ // General case for n-element pattern.
+ do {
+ const auto [__b, __p] = ranges::mismatch(__current(), __end, __pbegin, __pend);
+ if (__p == __pend) {
+ __current() = __b;
+ if (__current() == __end) {
+ __trailing_empty_ = true;
+ }
+ break; // The pattern matched; skip it.
+ }
+ } while (++__current() != __end);
+ }
+
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator++(int) {
+ if constexpr (forward_range<_Base>) {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+
+ } else {
+ ++*this;
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __outer_iterator& __x, const __outer_iterator& __y)
+ requires forward_range<_Base> {
+ return __x.__current_ == __y.__current_ && __x.__trailing_empty_ == __y.__trailing_empty_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __outer_iterator& __x, default_sentinel_t) {
+ _LIBCPP_ASSERT(__x.__parent_, "Cannot call comparison on a default-constructed iterator.");
+ return __x.__current() == ranges::end(__x.__parent_base()) && !__x.__trailing_empty_;
+ }
+ };
+
+ template <class>
+ struct __inner_iterator_category {};
+
+ template <forward_range _Tp>
+ struct __inner_iterator_category<_Tp> {
+ using iterator_category = _If<
+ derived_from<typename iterator_traits<iterator_t<_Tp>>::iterator_category, forward_iterator_tag>,
+ forward_iterator_tag,
+ typename iterator_traits<iterator_t<_Tp>>::iterator_category
+ >;
+ };
+
+ template <bool _Const>
+ struct __inner_iterator : __inner_iterator_category<__maybe_const<_Const, _View>> {
+ private:
+ using _Base = __maybe_const<_Const, _View>;
+ // Workaround for a GCC issue.
+ static constexpr bool _OuterConst = _Const;
+ __outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>();
+ bool __incremented_ = false;
+
+ // Note: these private functions are necessary because GCC doesn't allow calls to private members of `__i_` from
+ // free functions that are friends of `inner-iterator`.
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr bool __is_done() const {
+ _LIBCPP_ASSERT(__i_.__parent_, "Cannot call comparison on a default-constructed iterator.");
+
+ auto [__pcur, __pend] = ranges::subrange{__i_.__parent_->__pattern_};
+ auto __end = ranges::end(__i_.__parent_->__base_);
+
+ if constexpr (__tiny_range<_Pattern>) {
+ const auto& __cur = __i_.__current();
+ if (__cur == __end)
+ return true;
+ if (__pcur == __pend)
+ return __incremented_;
+
+ return *__cur == *__pcur;
+
+ } else {
+ auto __cur = __i_.__current();
+ if (__cur == __end)
+ return true;
+ if (__pcur == __pend)
+ return __incremented_;
+
+ do {
+ if (*__cur != *__pcur)
+ return false;
+ if (++__pcur == __pend)
+ return true;
+ } while (++__cur != __end);
+
+ return false;
+ }
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto& __outer_current() noexcept {
+ return __i_.__current();
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr const auto& __outer_current() const noexcept {
+ return __i_.__current();
+ }
+
+ public:
+ // using iterator_category = inherited;
+ using iterator_concept = typename __outer_iterator<_Const>::iterator_concept;
+ using value_type = range_value_t<_Base>;
+ using difference_type = range_difference_t<_Base>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ __inner_iterator() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __inner_iterator(__outer_iterator<_Const> __i)
+ : __i_(std::move(__i)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr const iterator_t<_Base>& base() const& noexcept { return __i_.__current(); }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iterator_t<_Base> base() &&
+ requires forward_range<_View> { return std::move(__i_.__current()); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator*() const { return *__i_.__current(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __inner_iterator& operator++() {
+ __incremented_ = true;
+
+ if constexpr (!forward_range<_Base>) {
+ if constexpr (_Pattern::size() == 0) {
+ return *this;
+ }
+ }
+
+ ++__i_.__current();
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator++(int) {
+ if constexpr (forward_range<_Base>) {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+
+ } else {
+ ++*this;
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __inner_iterator& __x, const __inner_iterator& __y)
+ requires forward_range<_Base> {
+ return __x.__outer_current() == __y.__outer_current();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __inner_iterator& __x, default_sentinel_t) {
+ return __x.__is_done();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr decltype(auto) iter_move(const __inner_iterator& __i)
+ noexcept(noexcept(ranges::iter_move(__i.__outer_current()))) {
+ return ranges::iter_move(__i.__outer_current());
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr void iter_swap(const __inner_iterator& __x, const __inner_iterator& __y)
+ noexcept(noexcept(ranges::iter_swap(__x.__outer_current(), __y.__outer_current())))
+ requires indirectly_swappable<iterator_t<_Base>> {
+ ranges::iter_swap(__x.__outer_current(), __y.__outer_current());
+ }
+ };
+
+};
+
+template <class _Range, class _Pattern>
+lazy_split_view(_Range&&, _Pattern&&) -> lazy_split_view<views::all_t<_Range>, views::all_t<_Pattern>>;
+
+template <input_range _Range>
+lazy_split_view(_Range&&, range_value_t<_Range>)
+ -> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>;
+
+namespace views {
+namespace __lazy_split_view {
+struct __fn : __range_adaptor_closure<__fn> {
+ template <class _Range, class _Pattern>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const
+ noexcept(noexcept(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))))
+ -> decltype( lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))
+ { return lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); }
+
+ template <class _Pattern>
+ requires constructible_from<decay_t<_Pattern>, _Pattern>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Pattern&& __pattern) const
+ noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
+ return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
+ }
+};
+} // namespace __lazy_split_view
+
+inline namespace __cpo {
+ inline constexpr auto lazy_split = __lazy_split_view::__fn{};
+} // namespace __cpo
+} // namespace views
+
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
lib/libcxx/include/__ranges/non_propagating_cache.h
@@ -19,12 +19,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
// __non_propagating_cache is a helper type that allows storing an optional value in it,
@@ -45,7 +45,7 @@ namespace ranges {
// constructing the contained type from an iterator.
struct __wrapper {
template<class ..._Args>
- constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(_VSTD::forward<_Args>(__args)...) { }
+ constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(std::forward<_Args>(__args)...) { }
template<class _Fn>
constexpr explicit __wrapper(__from_tag, _Fn const& __f) : __t_(__f()) { }
_Tp __t_;
@@ -70,7 +70,7 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr __non_propagating_cache& operator=(__non_propagating_cache const& __other) noexcept {
- if (this != _VSTD::addressof(__other)) {
+ if (this != std::addressof(__other)) {
__value_.reset();
}
return *this;
@@ -100,14 +100,14 @@ namespace ranges {
template<class ..._Args>
_LIBCPP_HIDE_FROM_ABI
constexpr _Tp& __emplace(_Args&& ...__args) {
- return __value_.emplace(__forward_tag{}, _VSTD::forward<_Args>(__args)...).__t_;
+ return __value_.emplace(__forward_tag{}, std::forward<_Args>(__args)...).__t_;
}
};
struct __empty_cache { };
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/owning_view.h
@@ -23,12 +23,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<range _Rp>
@@ -38,15 +38,15 @@ namespace ranges {
public:
owning_view() requires default_initializable<_Rp> = default;
- _LIBCPP_HIDE_FROM_ABI constexpr owning_view(_Rp&& __r) : __r_(_VSTD::move(__r)) {}
+ _LIBCPP_HIDE_FROM_ABI constexpr owning_view(_Rp&& __r) : __r_(std::move(__r)) {}
owning_view(owning_view&&) = default;
owning_view& operator=(owning_view&&) = default;
_LIBCPP_HIDE_FROM_ABI constexpr _Rp& base() & noexcept { return __r_; }
_LIBCPP_HIDE_FROM_ABI constexpr const _Rp& base() const& noexcept { return __r_; }
- _LIBCPP_HIDE_FROM_ABI constexpr _Rp&& base() && noexcept { return _VSTD::move(__r_); }
- _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return _VSTD::move(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Rp&& base() && noexcept { return std::move(__r_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return std::move(__r_); }
_LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Rp> begin() { return ranges::begin(__r_); }
_LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Rp> end() { return ranges::end(__r_); }
@@ -74,7 +74,7 @@ public:
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/range_adaptor.h
@@ -20,12 +20,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// CRTP base that one can derive from in order to be considered a range adaptor closure
// by the library. When deriving from this class, a pipe operator will be provided to
@@ -39,7 +39,7 @@ struct __range_adaptor_closure;
// i.e. something that can be called via the `x | f` notation.
template <class _Fn>
struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {
- constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(_VSTD::move(__f)) { }
+ constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) { }
};
template <class _Tp>
@@ -53,7 +53,7 @@ struct __range_adaptor_closure {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
friend constexpr decltype(auto) operator|(_View&& __view, _Closure&& __closure)
noexcept(is_nothrow_invocable_v<_Closure, _View>)
- { return _VSTD::invoke(_VSTD::forward<_Closure>(__closure), _VSTD::forward<_View>(__view)); }
+ { return std::invoke(std::forward<_Closure>(__closure), std::forward<_View>(__view)); }
template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
requires same_as<_Tp, remove_cvref_t<_Closure>> &&
@@ -63,10 +63,10 @@ struct __range_adaptor_closure {
friend constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2)
noexcept(is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&
is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>)
- { return __range_adaptor_closure_t(_VSTD::__compose(_VSTD::forward<_OtherClosure>(__c2), _VSTD::forward<_Closure>(__c1))); }
+ { return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); }
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/rbegin.h
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_RBEGIN_H
+#define _LIBCPP___RANGES_RBEGIN_H
+
+#include <__concepts/class_or_enum.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/readable_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__utility/auto_cast.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [ranges.access.rbegin]
+
+namespace ranges {
+namespace __rbegin {
+template <class _Tp>
+concept __member_rbegin =
+ __can_borrow<_Tp> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
+ };
+
+void rbegin(auto&) = delete;
+void rbegin(const auto&) = delete;
+
+template <class _Tp>
+concept __unqualified_rbegin =
+ !__member_rbegin<_Tp> &&
+ __can_borrow<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(rbegin(__t)) } -> input_or_output_iterator;
+ };
+
+template <class _Tp>
+concept __can_reverse =
+ __can_borrow<_Tp> &&
+ !__member_rbegin<_Tp> &&
+ !__unqualified_rbegin<_Tp> &&
+ requires(_Tp&& __t) {
+ { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>;
+ { ranges::begin(__t) } -> bidirectional_iterator;
+ };
+
+struct __fn {
+ template <class _Tp>
+ requires __member_rbegin<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rbegin())))
+ {
+ return _LIBCPP_AUTO_CAST(__t.rbegin());
+ }
+
+ template <class _Tp>
+ requires __unqualified_rbegin<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(rbegin(__t))))
+ {
+ return _LIBCPP_AUTO_CAST(rbegin(__t));
+ }
+
+ template <class _Tp>
+ requires __can_reverse<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::end(__t)))
+ {
+ return std::make_reverse_iterator(ranges::end(__t));
+ }
+
+ void operator()(auto&&) const = delete;
+};
+} // namespace __rbegin
+
+inline namespace __cpo {
+ inline constexpr auto rbegin = __rbegin::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.access.crbegin]
+
+namespace ranges {
+namespace __crbegin {
+struct __fn {
+ template <class _Tp>
+ requires is_lvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t))))
+ -> decltype( ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t)))
+ { return ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t)); }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::rbegin(static_cast<const _Tp&&>(__t))))
+ -> decltype( ranges::rbegin(static_cast<const _Tp&&>(__t)))
+ { return ranges::rbegin(static_cast<const _Tp&&>(__t)); }
+};
+} // namespace __crbegin
+
+inline namespace __cpo {
+ inline constexpr auto crbegin = __crbegin::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_RBEGIN_H
lib/libcxx/include/__ranges/ref_view.h
@@ -26,12 +26,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<range _Range>
@@ -48,7 +48,7 @@ public:
convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); }
_LIBCPP_HIDE_FROM_ABI
constexpr ref_view(_Tp&& __t)
- : __range_(_VSTD::addressof(static_cast<_Range&>(_VSTD::forward<_Tp>(__t))))
+ : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t))))
{}
_LIBCPP_HIDE_FROM_ABI constexpr _Range& base() const { return *__range_; }
@@ -79,7 +79,7 @@ public:
inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/rend.h
@@ -0,0 +1,134 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_REND_H
+#define _LIBCPP___RANGES_REND_H
+
+#include <__concepts/class_or_enum.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/readable_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__ranges/rbegin.h>
+#include <__utility/auto_cast.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+// [range.access.rend]
+
+namespace ranges {
+namespace __rend {
+template <class _Tp>
+concept __member_rend =
+ __can_borrow<_Tp> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ ranges::rbegin(__t);
+ { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
+ };
+
+void rend(auto&) = delete;
+void rend(const auto&) = delete;
+
+template <class _Tp>
+concept __unqualified_rend =
+ !__member_rend<_Tp> &&
+ __can_borrow<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires(_Tp&& __t) {
+ ranges::rbegin(__t);
+ { _LIBCPP_AUTO_CAST(rend(__t)) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
+ };
+
+template <class _Tp>
+concept __can_reverse =
+ __can_borrow<_Tp> &&
+ !__member_rend<_Tp> &&
+ !__unqualified_rend<_Tp> &&
+ requires(_Tp&& __t) {
+ { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>;
+ { ranges::begin(__t) } -> bidirectional_iterator;
+ };
+
+class __fn {
+public:
+ template <class _Tp>
+ requires __member_rend<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rend())))
+ {
+ return _LIBCPP_AUTO_CAST(__t.rend());
+ }
+
+ template <class _Tp>
+ requires __unqualified_rend<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(rend(__t))))
+ {
+ return _LIBCPP_AUTO_CAST(rend(__t));
+ }
+
+ template <class _Tp>
+ requires __can_reverse<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::begin(__t)))
+ {
+ return std::make_reverse_iterator(ranges::begin(__t));
+ }
+
+ void operator()(auto&&) const = delete;
+};
+} // namespace __rend
+
+inline namespace __cpo {
+ inline constexpr auto rend = __rend::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// [range.access.crend]
+
+namespace ranges {
+namespace __crend {
+struct __fn {
+ template <class _Tp>
+ requires is_lvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t))))
+ -> decltype( ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t)))
+ { return ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t)); }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::rend(static_cast<const _Tp&&>(__t))))
+ -> decltype( ranges::rend(static_cast<const _Tp&&>(__t)))
+ { return ranges::rend(static_cast<const _Tp&&>(__t)); }
+};
+} // namespace __crend
+
+inline namespace __cpo {
+ inline constexpr auto crend = __crend::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_REND_H
lib/libcxx/include/__ranges/reverse_view.h
@@ -28,12 +28,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<view _View>
@@ -43,21 +43,21 @@ namespace ranges {
// amortized O(1) begin() method.
static constexpr bool _UseCache = !random_access_range<_View> && !common_range<_View>;
using _Cache = _If<_UseCache, __non_propagating_cache<reverse_iterator<iterator_t<_View>>>, __empty_cache>;
- [[no_unique_address]] _Cache __cached_begin_ = _Cache();
- [[no_unique_address]] _View __base_ = _View();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
public:
_LIBCPP_HIDE_FROM_ABI
reverse_view() requires default_initializable<_View> = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit reverse_view(_View __view) : __base_(_VSTD::move(__view)) {}
+ constexpr explicit reverse_view(_View __view) : __base_(std::move(__view)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
_LIBCPP_HIDE_FROM_ABI
- constexpr _View base() && { return _VSTD::move(__base_); }
+ constexpr _View base() && { return std::move(__base_); }
_LIBCPP_HIDE_FROM_ABI
constexpr reverse_iterator<iterator_t<_View>> begin() {
@@ -65,7 +65,7 @@ namespace ranges {
if (__cached_begin_.__has_value())
return *__cached_begin_;
- auto __tmp = _VSTD::make_reverse_iterator(ranges::next(ranges::begin(__base_), ranges::end(__base_)));
+ auto __tmp = std::make_reverse_iterator(ranges::next(ranges::begin(__base_), ranges::end(__base_)));
if constexpr (_UseCache)
__cached_begin_.__emplace(__tmp);
return __tmp;
@@ -73,22 +73,22 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr reverse_iterator<iterator_t<_View>> begin() requires common_range<_View> {
- return _VSTD::make_reverse_iterator(ranges::end(__base_));
+ return std::make_reverse_iterator(ranges::end(__base_));
}
_LIBCPP_HIDE_FROM_ABI
constexpr auto begin() const requires common_range<const _View> {
- return _VSTD::make_reverse_iterator(ranges::end(__base_));
+ return std::make_reverse_iterator(ranges::end(__base_));
}
_LIBCPP_HIDE_FROM_ABI
constexpr reverse_iterator<iterator_t<_View>> end() {
- return _VSTD::make_reverse_iterator(ranges::begin(__base_));
+ return std::make_reverse_iterator(ranges::begin(__base_));
}
_LIBCPP_HIDE_FROM_ABI
constexpr auto end() const requires common_range<const _View> {
- return _VSTD::make_reverse_iterator(ranges::begin(__base_));
+ return std::make_reverse_iterator(ranges::begin(__base_));
}
_LIBCPP_HIDE_FROM_ABI
@@ -111,22 +111,22 @@ namespace ranges {
namespace views {
namespace __reverse {
template<class _Tp>
- constexpr bool __is_reverse_view = false;
+ inline constexpr bool __is_reverse_view = false;
template<class _Tp>
- constexpr bool __is_reverse_view<reverse_view<_Tp>> = true;
+ inline constexpr bool __is_reverse_view<reverse_view<_Tp>> = true;
template<class _Tp>
- constexpr bool __is_sized_reverse_subrange = false;
+ inline constexpr bool __is_sized_reverse_subrange = false;
template<class _Iter>
- constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true;
+ inline constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true;
template<class _Tp>
- constexpr bool __is_unsized_reverse_subrange = false;
+ inline constexpr bool __is_unsized_reverse_subrange = false;
template<class _Iter, subrange_kind _Kind>
- constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = _Kind == subrange_kind::unsized;
+ inline constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = _Kind == subrange_kind::unsized;
template<class _Tp>
struct __unwrapped_reverse_subrange {
@@ -143,9 +143,9 @@ namespace ranges {
requires __is_reverse_view<remove_cvref_t<_Range>>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range) const
- noexcept(noexcept(_VSTD::forward<_Range>(__range).base()))
- -> decltype( _VSTD::forward<_Range>(__range).base())
- { return _VSTD::forward<_Range>(__range).base(); }
+ noexcept(noexcept(std::forward<_Range>(__range).base()))
+ -> decltype( std::forward<_Range>(__range).base())
+ { return std::forward<_Range>(__range).base(); }
template<class _Range,
class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type>
@@ -171,9 +171,9 @@ namespace ranges {
!__is_unsized_reverse_subrange<remove_cvref_t<_Range>>)
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range) const
- noexcept(noexcept(reverse_view{_VSTD::forward<_Range>(__range)}))
- -> decltype( reverse_view{_VSTD::forward<_Range>(__range)})
- { return reverse_view{_VSTD::forward<_Range>(__range)}; }
+ noexcept(noexcept(reverse_view{std::forward<_Range>(__range)}))
+ -> decltype( reverse_view{std::forward<_Range>(__range)})
+ { return reverse_view{std::forward<_Range>(__range)}; }
};
} // namespace __reverse
@@ -183,7 +183,7 @@ namespace ranges {
} // namespace views
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/single_view.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__ranges/copyable_box.h>
+#include <__ranges/range_adaptor.h>
#include <__ranges/view_interface.h>
#include <__utility/forward.h>
#include <__utility/in_place.h>
@@ -19,12 +20,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<copy_constructible _Tp>
@@ -40,13 +41,13 @@ namespace ranges {
constexpr explicit single_view(const _Tp& __t) : __value_(in_place, __t) {}
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit single_view(_Tp&& __t) : __value_(in_place, _VSTD::move(__t)) {}
+ constexpr explicit single_view(_Tp&& __t) : __value_(in_place, std::move(__t)) {}
template<class... _Args>
requires constructible_from<_Tp, _Args...>
_LIBCPP_HIDE_FROM_ABI
constexpr explicit single_view(in_place_t, _Args&&... __args)
- : __value_{in_place, _VSTD::forward<_Args>(__args)...} {}
+ : __value_{in_place, std::forward<_Args>(__args)...} {}
_LIBCPP_HIDE_FROM_ABI
constexpr _Tp* begin() noexcept { return data(); }
@@ -70,11 +71,30 @@ namespace ranges {
constexpr const _Tp* data() const noexcept { return __value_.operator->(); }
};
- template<class _Tp>
- single_view(_Tp) -> single_view<_Tp>;
+template<class _Tp>
+single_view(_Tp) -> single_view<_Tp>;
+
+namespace views {
+namespace __single_view {
+
+struct __fn : __range_adaptor_closure<__fn> {
+ template<class _Range>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(single_view<decay_t<_Range&&>>(std::forward<_Range>(__range))))
+ -> decltype( single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)))
+ { return single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)); }
+};
+} // namespace __single_view
+
+inline namespace __cpo {
+ inline constexpr auto single = __single_view::__fn{};
+} // namespace __cpo
+
+} // namespace views
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/size.h
@@ -19,12 +19,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<class>
@@ -35,68 +35,76 @@ namespace ranges {
namespace ranges {
namespace __size {
- void size(auto&) = delete;
- void size(const auto&) = delete;
-
- template <class _Tp>
- concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;
-
- template <class _Tp>
- concept __member_size =
- __size_enabled<_Tp> &&
- __workaround_52970<_Tp> &&
- requires(_Tp&& __t) {
- { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
- };
-
- template <class _Tp>
- concept __unqualified_size =
- __size_enabled<_Tp> &&
- !__member_size<_Tp> &&
- __class_or_enum<remove_cvref_t<_Tp>> &&
- requires(_Tp&& __t) {
- { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like;
- };
-
- template <class _Tp>
- concept __difference =
- !__member_size<_Tp> &&
- !__unqualified_size<_Tp> &&
- __class_or_enum<remove_cvref_t<_Tp>> &&
- requires(_Tp&& __t) {
- { ranges::begin(__t) } -> forward_iterator;
- { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>;
- };
-
- struct __fn {
- template <class _Tp, size_t _Sz>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept {
- return _Sz;
- }
-
- template <class _Tp, size_t _Sz>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept {
- return _Sz;
- }
-
- template <__member_size _Tp>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) {
- return _LIBCPP_AUTO_CAST(__t.size());
- }
-
- template <__unqualified_size _Tp>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) {
- return _LIBCPP_AUTO_CAST(size(__t));
- }
-
- template<__difference _Tp>
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
- noexcept(noexcept(ranges::end(__t) - ranges::begin(__t))) {
- return _VSTD::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t));
- }
+void size(auto&) = delete;
+void size(const auto&) = delete;
+
+template <class _Tp>
+concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;
+
+template <class _Tp>
+concept __member_size =
+ __size_enabled<_Tp> &&
+ __workaround_52970<_Tp> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
};
+
+template <class _Tp>
+concept __unqualified_size =
+ __size_enabled<_Tp> &&
+ !__member_size<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires(_Tp&& __t) {
+ { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like;
+ };
+
+template <class _Tp>
+concept __difference =
+ !__member_size<_Tp> &&
+ !__unqualified_size<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires(_Tp&& __t) {
+ { ranges::begin(__t) } -> forward_iterator;
+ { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>;
+ };
+
+struct __fn {
+
+ // `[range.prim.size]`: the array case (for rvalues).
+ template <class _Tp, size_t _Sz>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept {
+ return _Sz;
+ }
+
+ // `[range.prim.size]`: the array case (for lvalues).
+ template <class _Tp, size_t _Sz>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept {
+ return _Sz;
+ }
+
+ // `[range.prim.size]`: `auto(t.size())` is a valid expression.
+ template <__member_size _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) {
+ return _LIBCPP_AUTO_CAST(__t.size());
+ }
+
+ // `[range.prim.size]`: `auto(size(t))` is a valid expression.
+ template <__unqualified_size _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) {
+ return _LIBCPP_AUTO_CAST(size(__t));
+ }
+
+ // [range.prim.size]: the `to-unsigned-like` case.
+ template <__difference _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t))))
+ -> decltype( std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)))
+ { return std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t));
+ }
+};
+
} // namespace __size
inline namespace __cpo {
@@ -108,19 +116,18 @@ inline namespace __cpo {
namespace ranges {
namespace __ssize {
- struct __fn {
- template<class _Tp>
- requires requires (_Tp&& __t) { ranges::size(__t); }
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const
- noexcept(noexcept(ranges::size(__t)))
- {
- using _Signed = make_signed_t<decltype(ranges::size(__t))>;
- if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed))
- return static_cast<ptrdiff_t>(ranges::size(__t));
- else
- return static_cast<_Signed>(ranges::size(__t));
- }
- };
+struct __fn {
+ template<class _Tp>
+ requires requires (_Tp&& __t) { ranges::size(__t); }
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::size(__t))) {
+ using _Signed = make_signed_t<decltype(ranges::size(__t))>;
+ if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed))
+ return static_cast<ptrdiff_t>(ranges::size(__t));
+ else
+ return static_cast<_Signed>(ranges::size(__t));
+ }
+};
} // namespace __ssize
inline namespace __cpo {
@@ -128,7 +135,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/subrange.h
@@ -9,13 +9,13 @@
#ifndef _LIBCPP___RANGES_SUBRANGE_H
#define _LIBCPP___RANGES_SUBRANGE_H
+#include <__assert>
#include <__concepts/constructible.h>
#include <__concepts/convertible_to.h>
#include <__concepts/copyable.h>
#include <__concepts/derived_from.h>
#include <__concepts/different_from.h>
#include <__config>
-#include <__debug>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
@@ -31,12 +31,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
template<class _From, class _To>
@@ -56,8 +56,8 @@ namespace ranges {
requires derived_from<tuple_size<_Tp>, integral_constant<size_t, 2>>;
typename tuple_element_t<0, remove_const_t<_Tp>>;
typename tuple_element_t<1, remove_const_t<_Tp>>;
- { _VSTD::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>;
- { _VSTD::get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>;
+ { std::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>;
+ { std::get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>;
};
template<class _Pair, class _Iter, class _Sent>
@@ -77,14 +77,17 @@ namespace ranges {
class _LIBCPP_TEMPLATE_VIS subrange
: public view_interface<subrange<_Iter, _Sent, _Kind>>
{
- private:
+ public:
+ // Note: this is an internal implementation detail that is public only for internal usage.
static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>);
+
+ private:
static constexpr bool _MustProvideSizeAtConstruction = !_StoreSize; // just to improve compiler diagnostics
struct _Empty { constexpr _Empty(auto) noexcept { } };
using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>;
- [[no_unique_address]] _Iter __begin_ = _Iter();
- [[no_unique_address]] _Sent __end_ = _Sent();
- [[no_unique_address]] _Size __size_ = 0;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Iter __begin_ = _Iter();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Sent __end_ = _Sent();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Size __size_ = 0;
public:
_LIBCPP_HIDE_FROM_ABI
@@ -93,14 +96,14 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent)
requires _MustProvideSizeAtConstruction
- : __begin_(_VSTD::move(__iter)), __end_(_VSTD::move(__sent))
+ : __begin_(std::move(__iter)), __end_(std::move(__sent))
{ }
_LIBCPP_HIDE_FROM_ABI
constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent,
make_unsigned_t<iter_difference_t<_Iter>> __n)
requires (_Kind == subrange_kind::sized)
- : __begin_(_VSTD::move(__iter)), __end_(_VSTD::move(__sent)), __size_(__n)
+ : __begin_(std::move(__iter)), __end_(std::move(__sent)), __size_(__n)
{
if constexpr (sized_sentinel_for<_Sent, _Iter>)
_LIBCPP_ASSERT((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n),
@@ -149,7 +152,7 @@ namespace ranges {
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() requires (!copyable<_Iter>) {
- return _VSTD::move(__begin_);
+ return std::move(__begin_);
}
_LIBCPP_HIDE_FROM_ABI
@@ -168,7 +171,7 @@ namespace ranges {
if constexpr (_StoreSize)
return __size_;
else
- return _VSTD::__to_unsigned_like(__end_ - __begin_);
+ return std::__to_unsigned_like(__end_ - __begin_);
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) const&
@@ -181,7 +184,7 @@ namespace ranges {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) && {
advance(__n);
- return _VSTD::move(*this);
+ return std::move(*this);
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange prev(iter_difference_t<_Iter> __n = 1) const
@@ -198,14 +201,14 @@ namespace ranges {
if (__n < 0) {
ranges::advance(__begin_, __n);
if constexpr (_StoreSize)
- __size_ += _VSTD::__to_unsigned_like(-__n);
+ __size_ += std::__to_unsigned_like(-__n);
return *this;
}
}
auto __d = __n - ranges::advance(__begin_, __n, __end_);
if constexpr (_StoreSize)
- __size_ -= _VSTD::__to_unsigned_like(__d);
+ __size_ -= std::__to_unsigned_like(__d);
return *this;
}
};
@@ -282,7 +285,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
using type = _Sp;
};
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/take_view.h
@@ -10,23 +10,34 @@
#define _LIBCPP___RANGES_TAKE_VIEW_H
#include <__algorithm/min.h>
+#include <__algorithm/ranges_min.h>
#include <__config>
+#include <__functional/bind_back.h>
+#include <__fwd/span.h>
+#include <__fwd/string_view.h>
#include <__iterator/concepts.h>
#include <__iterator/counted_iterator.h>
#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__ranges/access.h>
#include <__ranges/all.h>
#include <__ranges/concepts.h>
+#include <__ranges/empty_view.h>
#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/iota_view.h>
+#include <__ranges/range_adaptor.h>
#include <__ranges/size.h>
+#include <__ranges/subrange.h>
#include <__ranges/view_interface.h>
+#include <__utility/auto_cast.h>
+#include <__utility/forward.h>
#include <__utility/move.h>
#include <concepts>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -34,149 +45,290 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
- template<view _View>
- class take_view : public view_interface<take_view<_View>> {
- [[no_unique_address]] _View __base_ = _View();
- range_difference_t<_View> __count_ = 0;
-
- template<bool> class __sentinel;
-
- public:
- _LIBCPP_HIDE_FROM_ABI
- take_view() requires default_initializable<_View> = default;
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr take_view(_View __base, range_difference_t<_View> __count)
- : __base_(_VSTD::move(__base)), __count_(__count) {}
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr _View base() && { return _VSTD::move(__base_); }
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto begin() requires (!__simple_view<_View>) {
- if constexpr (sized_range<_View>) {
- if constexpr (random_access_range<_View>) {
- return ranges::begin(__base_);
- } else {
- using _DifferenceT = range_difference_t<_View>;
- auto __size = size();
- return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
- }
+
+template<view _View>
+class take_view : public view_interface<take_view<_View>> {
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+ range_difference_t<_View> __count_ = 0;
+
+ template<bool> class __sentinel;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ take_view() requires default_initializable<_View> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr take_view(_View __base, range_difference_t<_View> __count)
+ : __base_(std::move(__base)), __count_(__count) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return std::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() requires (!__simple_view<_View>) {
+ if constexpr (sized_range<_View>) {
+ if constexpr (random_access_range<_View>) {
+ return ranges::begin(__base_);
} else {
- return counted_iterator(ranges::begin(__base_), __count_);
+ using _DifferenceT = range_difference_t<_View>;
+ auto __size = size();
+ return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
}
+ } else {
+ return counted_iterator(ranges::begin(__base_), __count_);
}
+ }
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto begin() const requires range<const _View> {
- if constexpr (sized_range<const _View>) {
- if constexpr (random_access_range<const _View>) {
- return ranges::begin(__base_);
- } else {
- using _DifferenceT = range_difference_t<const _View>;
- auto __size = size();
- return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
- }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() const requires range<const _View> {
+ if constexpr (sized_range<const _View>) {
+ if constexpr (random_access_range<const _View>) {
+ return ranges::begin(__base_);
} else {
- return counted_iterator(ranges::begin(__base_), __count_);
+ using _DifferenceT = range_difference_t<const _View>;
+ auto __size = size();
+ return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size));
}
+ } else {
+ return counted_iterator(ranges::begin(__base_), __count_);
}
+ }
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto end() requires (!__simple_view<_View>) {
- if constexpr (sized_range<_View>) {
- if constexpr (random_access_range<_View>) {
- return ranges::begin(__base_) + size();
- } else {
- return default_sentinel;
- }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() requires (!__simple_view<_View>) {
+ if constexpr (sized_range<_View>) {
+ if constexpr (random_access_range<_View>) {
+ return ranges::begin(__base_) + size();
} else {
- return __sentinel<false>{ranges::end(__base_)};
+ return default_sentinel;
}
+ } else {
+ return __sentinel<false>{ranges::end(__base_)};
}
+ }
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto end() const requires range<const _View> {
- if constexpr (sized_range<const _View>) {
- if constexpr (random_access_range<const _View>) {
- return ranges::begin(__base_) + size();
- } else {
- return default_sentinel;
- }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const requires range<const _View> {
+ if constexpr (sized_range<const _View>) {
+ if constexpr (random_access_range<const _View>) {
+ return ranges::begin(__base_) + size();
} else {
- return __sentinel<true>{ranges::end(__base_)};
+ return default_sentinel;
}
+ } else {
+ return __sentinel<true>{ranges::end(__base_)};
}
-
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto size() requires sized_range<_View> {
- auto __n = ranges::size(__base_);
- // TODO: use ranges::min here.
- return _VSTD::min(__n, static_cast<decltype(__n)>(__count_));
- }
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto size() const requires sized_range<const _View> {
- auto __n = ranges::size(__base_);
- // TODO: use ranges::min here.
- return _VSTD::min(__n, static_cast<decltype(__n)>(__count_));
- }
- };
-
- template<view _View>
- template<bool _Const>
- class take_view<_View>::__sentinel {
- using _Base = __maybe_const<_Const, _View>;
- template<bool _OtherConst>
- using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;
- [[no_unique_address]] sentinel_t<_Base> __end_ = sentinel_t<_Base>();
-
- template<bool>
- friend class take_view<_View>::__sentinel;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() requires sized_range<_View> {
+ auto __n = ranges::size(__base_);
+ return ranges::min(__n, static_cast<decltype(__n)>(__count_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const requires sized_range<const _View> {
+ auto __n = ranges::size(__base_);
+ return ranges::min(__n, static_cast<decltype(__n)>(__count_));
+ }
+};
+
+template<view _View>
+template<bool _Const>
+class take_view<_View>::__sentinel {
+ using _Base = __maybe_const<_Const, _View>;
+ template<bool _OtherConst>
+ using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;
+ _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
+
+ template<bool>
+ friend class take_view<_View>::__sentinel;
public:
- _LIBCPP_HIDE_FROM_ABI
- __sentinel() = default;
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(_VSTD::move(__end)) {}
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr __sentinel(__sentinel<!_Const> __s)
- requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
- : __end_(_VSTD::move(__s.__end_)) {}
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr sentinel_t<_Base> base() const { return __end_; }
-
- _LIBCPP_HIDE_FROM_ABI
- friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
- return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
- }
-
- template<bool _OtherConst = !_Const>
- requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
- _LIBCPP_HIDE_FROM_ABI
- friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
- return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
- }
- };
-
- template<class _Range>
- take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>;
+ _LIBCPP_HIDE_FROM_ABI
+ __sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(std::move(__end)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __sentinel(__sentinel<!_Const> __s)
+ requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
+ : __end_(std::move(__s.__end_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr sentinel_t<_Base> base() const { return __end_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
+ return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
+ }
+
+ template<bool _OtherConst = !_Const>
+ requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) {
+ return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
+ }
+};
+
+template<class _Range>
+take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>;
+
+template<class _Tp>
+inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>;
+
+namespace views {
+namespace __take {
+
+template <class _Tp>
+inline constexpr bool __is_empty_view = false;
+
+template <class _Tp>
+inline constexpr bool __is_empty_view<empty_view<_Tp>> = true;
+
+template <class _Tp>
+inline constexpr bool __is_passthrough_specialization = false;
+
+template <class _Tp, size_t _Extent>
+inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true;
+
+template <class _CharT, class _Traits>
+inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true;
+
+template <class _Iter, class _Sent, subrange_kind _Kind>
+inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> = true;
+
+template <class _Tp>
+inline constexpr bool __is_iota_specialization = false;
+
+template <class _Np, class _Bound>
+inline constexpr bool __is_iota_specialization<iota_view<_Np, _Bound>> = true;
+
+template <class _Tp>
+struct __passthrough_type;
+
+template <class _Tp, size_t _Extent>
+struct __passthrough_type<span<_Tp, _Extent>> {
+ using type = span<_Tp>;
+};
+
+template <class _CharT, class _Traits>
+struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
+ using type = basic_string_view<_CharT, _Traits>;
+};
+
+template <class _Iter, class _Sent, subrange_kind _Kind>
+struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
+ using type = subrange<_Iter>;
+};
+
+template <class _Tp>
+using __passthrough_type_t = typename __passthrough_type<_Tp>::type;
+
+struct __fn {
+ // [range.take.overview]: the `empty_view` case.
+ template <class _Range, convertible_to<range_difference_t<_Range>> _Np>
+ requires __is_empty_view<remove_cvref_t<_Range>>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range, _Np&&) const
+ noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
+ -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
+ { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
+
+ // [range.take.overview]: the `span | basic_string_view | subrange` case.
+ template <class _Range,
+ convertible_to<range_difference_t<_Range>> _Np,
+ class _RawRange = remove_cvref_t<_Range>,
+ class _Dist = range_difference_t<_Range>>
+ requires (!__is_empty_view<_RawRange> &&
+ random_access_range<_RawRange> &&
+ sized_range<_RawRange> &&
+ __is_passthrough_specialization<_RawRange>)
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __rng, _Np&& __n) const
+ noexcept(noexcept(__passthrough_type_t<_RawRange>(
+ ranges::begin(__rng),
+ ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
+ )))
+ -> decltype( __passthrough_type_t<_RawRange>(
+ // Note: deliberately not forwarding `__rng` to guard against double moves.
+ ranges::begin(__rng),
+ ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
+ ))
+ { return __passthrough_type_t<_RawRange>(
+ ranges::begin(__rng),
+ ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
+ ); }
+
+ // [range.take.overview]: the `iota_view` case.
+ template <class _Range,
+ convertible_to<range_difference_t<_Range>> _Np,
+ class _RawRange = remove_cvref_t<_Range>,
+ class _Dist = range_difference_t<_Range>>
+ requires (!__is_empty_view<_RawRange> &&
+ random_access_range<_RawRange> &&
+ sized_range<_RawRange> &&
+ __is_iota_specialization<_RawRange>)
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __rng, _Np&& __n) const
+ noexcept(noexcept(ranges::iota_view(
+ *ranges::begin(__rng),
+ *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
+ )))
+ -> decltype( ranges::iota_view(
+ // Note: deliberately not forwarding `__rng` to guard against double moves.
+ *ranges::begin(__rng),
+ *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
+ ))
+ { return ranges::iota_view(
+ *ranges::begin(__rng),
+ *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))
+ ); }
+
+ // [range.take.overview]: the "otherwise" case.
+ template <class _Range, convertible_to<range_difference_t<_Range>> _Np,
+ class _RawRange = remove_cvref_t<_Range>>
+ // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other
+ // overloads.
+ requires (!(__is_empty_view<_RawRange> ||
+ (__is_iota_specialization<_RawRange> &&
+ sized_range<_RawRange> &&
+ random_access_range<_RawRange>) ||
+ (__is_passthrough_specialization<_RawRange> &&
+ sized_range<_RawRange> &&
+ random_access_range<_RawRange>)
+ ))
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range, _Np&& __n) const
+ noexcept(noexcept(take_view(std::forward<_Range>(__range), std::forward<_Np>(__n))))
+ -> decltype( take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))
+ { return take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); }
+
+ template <class _Np>
+ requires constructible_from<decay_t<_Np>, _Np>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Np&& __n) const
+ noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>)
+ { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); }
+};
+
+} // namespace __take
+
+inline namespace __cpo {
+ inline constexpr auto take = __take::__fn{};
+} // namespace __cpo
+} // namespace views
- template<class _Tp>
- inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>;
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/transform_view.h
@@ -36,12 +36,12 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
@@ -53,7 +53,7 @@ template<class _View, class _Fn>
concept __transform_view_constraints =
view<_View> && is_object_v<_Fn> &&
regular_invocable<_Fn&, range_reference_t<_View>> &&
- __referenceable<invoke_result_t<_Fn&, range_reference_t<_View>>>;
+ __can_reference<invoke_result_t<_Fn&, range_reference_t<_View>>>;
template<input_range _View, copy_constructible _Fn>
requires __transform_view_constraints<_View, _Fn>
@@ -61,8 +61,8 @@ class transform_view : public view_interface<transform_view<_View, _Fn>> {
template<bool> class __iterator;
template<bool> class __sentinel;
- [[no_unique_address]] __copyable_box<_Fn> __func_;
- [[no_unique_address]] _View __base_ = _View();
+ _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Fn> __func_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
public:
_LIBCPP_HIDE_FROM_ABI
@@ -71,12 +71,12 @@ public:
_LIBCPP_HIDE_FROM_ABI
constexpr transform_view(_View __base, _Fn __func)
- : __func_(_VSTD::in_place, _VSTD::move(__func)), __base_(_VSTD::move(__base)) {}
+ : __func_(std::in_place, std::move(__func)), __base_(std::move(__base)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
_LIBCPP_HIDE_FROM_ABI
- constexpr _View base() && { return _VSTD::move(__base_); }
+ constexpr _View base() && { return std::move(__base_); }
_LIBCPP_HIDE_FROM_ABI
constexpr __iterator<false> begin() {
@@ -183,7 +183,7 @@ public:
_LIBCPP_HIDE_FROM_ABI
constexpr __iterator(_Parent& __parent, iterator_t<_Base> __current)
- : __parent_(_VSTD::addressof(__parent)), __current_(_VSTD::move(__current)) {}
+ : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}
// Note: `__i` should always be `__iterator<false>`, but directly using
// `__iterator<false>` is ill-formed when `_Const` is false
@@ -191,7 +191,7 @@ public:
_LIBCPP_HIDE_FROM_ABI
constexpr __iterator(__iterator<!_Const> __i)
requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
- : __parent_(__i.__parent_), __current_(_VSTD::move(__i.__current_)) {}
+ : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr const iterator_t<_Base>& base() const& noexcept {
@@ -200,14 +200,14 @@ public:
_LIBCPP_HIDE_FROM_ABI
constexpr iterator_t<_Base> base() && {
- return _VSTD::move(__current_);
+ return std::move(__current_);
}
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) operator*() const
- noexcept(noexcept(_VSTD::invoke(*__parent_->__func_, *__current_)))
+ noexcept(noexcept(std::invoke(*__parent_->__func_, *__current_)))
{
- return _VSTD::invoke(*__parent_->__func_, *__current_);
+ return std::invoke(*__parent_->__func_, *__current_);
}
_LIBCPP_HIDE_FROM_ABI
@@ -263,10 +263,10 @@ public:
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) operator[](difference_type __n) const
- noexcept(noexcept(_VSTD::invoke(*__parent_->__func_, __current_[__n])))
+ noexcept(noexcept(std::invoke(*__parent_->__func_, __current_[__n])))
requires random_access_range<_Base>
{
- return _VSTD::invoke(*__parent_->__func_, __current_[__n]);
+ return std::invoke(*__parent_->__func_, __current_[__n]);
}
_LIBCPP_HIDE_FROM_ABI
@@ -344,7 +344,7 @@ public:
noexcept(noexcept(*__i))
{
if constexpr (is_lvalue_reference_v<decltype(*__i)>)
- return _VSTD::move(*__i);
+ return std::move(*__i);
else
return *__i;
}
@@ -378,7 +378,7 @@ public:
_LIBCPP_HIDE_FROM_ABI
constexpr __sentinel(__sentinel<!_Const> __i)
requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
- : __end_(_VSTD::move(__i.__end_)) {}
+ : __end_(std::move(__i.__end_)) {}
_LIBCPP_HIDE_FROM_ABI
constexpr sentinel_t<_Base> base() const { return __end_; }
@@ -413,16 +413,16 @@ namespace __transform {
template<class _Range, class _Fn>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range, _Fn&& __f) const
- noexcept(noexcept(transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f))))
- -> decltype( transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)))
- { return transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)); }
+ noexcept(noexcept(transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f))))
+ -> decltype( transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f)))
+ { return transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f)); }
template<class _Fn>
requires constructible_from<decay_t<_Fn>, _Fn>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Fn&& __f) const
noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>)
- { return __range_adaptor_closure_t(_VSTD::__bind_back(*this, _VSTD::forward<_Fn>(__f))); }
+ { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Fn>(__f))); }
};
} // namespace __transform
@@ -433,7 +433,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/view_interface.h
@@ -9,8 +9,10 @@
#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H
#define _LIBCPP___RANGES_VIEW_INTERFACE_H
+#include <__assert>
+#include <__concepts/derived_from.h>
+#include <__concepts/same_as.h>
#include <__config>
-#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/prev.h>
@@ -18,25 +20,18 @@
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/empty.h>
-#include <concepts>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
namespace ranges {
-template<class _Tp>
-concept __can_empty = requires(_Tp __t) { ranges::empty(__t); };
-
-template<class _Tp>
-void __implicitly_convert_to(type_identity_t<_Tp>) noexcept;
-
template<class _Derived>
requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
class view_interface {
@@ -55,7 +50,6 @@ class view_interface {
public:
template<class _D2 = _Derived>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty()
- noexcept(noexcept(__implicitly_convert_to<bool>(ranges::begin(__derived()) == ranges::end(__derived()))))
requires forward_range<_D2>
{
return ranges::begin(__derived()) == ranges::end(__derived());
@@ -63,7 +57,6 @@ public:
template<class _D2 = _Derived>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const
- noexcept(noexcept(__implicitly_convert_to<bool>(ranges::begin(__derived()) == ranges::end(__derived()))))
requires forward_range<const _D2>
{
return ranges::begin(__derived()) == ranges::end(__derived());
@@ -72,8 +65,7 @@ public:
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr explicit operator bool()
- noexcept(noexcept(ranges::empty(declval<_D2>())))
- requires __can_empty<_D2>
+ requires requires (_D2& __t) { ranges::empty(__t); }
{
return !ranges::empty(__derived());
}
@@ -81,8 +73,7 @@ public:
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr explicit operator bool() const
- noexcept(noexcept(ranges::empty(declval<const _D2>())))
- requires __can_empty<const _D2>
+ requires requires (const _D2& __t) { ranges::empty(__t); }
{
return !ranges::empty(__derived());
}
@@ -90,27 +81,23 @@ public:
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr auto data()
- noexcept(noexcept(_VSTD::to_address(ranges::begin(__derived()))))
requires contiguous_iterator<iterator_t<_D2>>
{
- return _VSTD::to_address(ranges::begin(__derived()));
+ return std::to_address(ranges::begin(__derived()));
}
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr auto data() const
- noexcept(noexcept(_VSTD::to_address(ranges::begin(__derived()))))
requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>>
{
- return _VSTD::to_address(ranges::begin(__derived()));
+ return std::to_address(ranges::begin(__derived()));
}
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr auto size()
- noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived())))
- requires forward_range<_D2>
- && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
+ requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
{
return ranges::end(__derived()) - ranges::begin(__derived());
}
@@ -118,9 +105,7 @@ public:
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr auto size() const
- noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived())))
- requires forward_range<const _D2>
- && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>
+ requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>
{
return ranges::end(__derived()) - ranges::begin(__derived());
}
@@ -128,7 +113,6 @@ public:
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) front()
- noexcept(noexcept(*ranges::begin(__derived())))
requires forward_range<_D2>
{
_LIBCPP_ASSERT(!empty(),
@@ -139,7 +123,6 @@ public:
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) front() const
- noexcept(noexcept(*ranges::begin(__derived())))
requires forward_range<const _D2>
{
_LIBCPP_ASSERT(!empty(),
@@ -150,7 +133,6 @@ public:
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) back()
- noexcept(noexcept(*ranges::prev(ranges::end(__derived()))))
requires bidirectional_range<_D2> && common_range<_D2>
{
_LIBCPP_ASSERT(!empty(),
@@ -161,7 +143,6 @@ public:
template<class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) back() const
- noexcept(noexcept(*ranges::prev(ranges::end(__derived()))))
requires bidirectional_range<const _D2> && common_range<const _D2>
{
_LIBCPP_ASSERT(!empty(),
@@ -172,7 +153,6 @@ public:
template<random_access_range _RARange = _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) operator[](range_difference_t<_RARange> __index)
- noexcept(noexcept(ranges::begin(__derived())[__index]))
{
return ranges::begin(__derived())[__index];
}
@@ -180,7 +160,6 @@ public:
template<random_access_range _RARange = const _Derived>
_LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const
- noexcept(noexcept(ranges::begin(__derived())[__index]))
{
return ranges::begin(__derived())[__index];
}
@@ -188,7 +167,7 @@ public:
} // namespace ranges
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/zip_view.h
@@ -0,0 +1,511 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_ZIP_VIEW_H
+#define _LIBCPP___RANGES_ZIP_VIEW_H
+
+#include <__config>
+
+#include <__algorithm/ranges_min.h>
+#include <__compare/three_way_comparable.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/equality_comparable.h>
+#include <__functional/invoke.h>
+#include <__functional/operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/empty_view.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__utility/forward.h>
+#include <__utility/integer_sequence.h>
+#include <__utility/move.h>
+#include <tuple>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template <class... _Ranges>
+concept __zip_is_common = (sizeof...(_Ranges) == 1 && (common_range<_Ranges> && ...)) ||
+ (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) ||
+ ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...));
+
+template <typename _Tp, typename _Up>
+auto __tuple_or_pair_test() -> pair<_Tp, _Up>;
+
+template <typename... _Types>
+ requires(sizeof...(_Types) != 2)
+auto __tuple_or_pair_test() -> tuple<_Types...>;
+
+template <class... _Types>
+using __tuple_or_pair = decltype(__tuple_or_pair_test<_Types...>());
+
+template <class _Fun, class _Tuple>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) {
+ return std::apply(
+ [&]<class... _Types>(_Types&&... __elements) {
+ return __tuple_or_pair<invoke_result_t<_Fun&, _Types>...>(
+ std::invoke(__f, std::forward<_Types>(__elements))...);
+ },
+ std::forward<_Tuple>(__tuple));
+}
+
+template <class _Fun, class _Tuple>
+_LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tuple) {
+ std::apply(
+ [&]<class... _Types>(_Types&&... __elements) { (std::invoke(__f, std::forward<_Types>(__elements)), ...); },
+ std::forward<_Tuple>(__tuple));
+}
+
+template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices>
+_LIBCPP_HIDE_FROM_ABI constexpr __tuple_or_pair<
+ invoke_result_t<_Fun&, typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type,
+ typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...>
+__tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2, index_sequence<_Indices...>) {
+ return {std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)),
+ std::get<_Indices>(std::forward<_Tuple2>(__tuple2)))...};
+}
+
+template <class _Fun, class _Tuple1, class _Tuple2>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) {
+ return ranges::__tuple_zip_transform(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2),
+ std::make_index_sequence<tuple_size<remove_cvref_t<_Tuple1>>::value>());
+}
+
+template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices>
+_LIBCPP_HIDE_FROM_ABI constexpr void __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2,
+ index_sequence<_Indices...>) {
+ (std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)),
+ std::get<_Indices>(std::forward<_Tuple2>(__tuple2))),
+ ...);
+}
+
+template <class _Fun, class _Tuple1, class _Tuple2>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) {
+ return ranges::__tuple_zip_for_each(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2),
+ std::make_index_sequence<tuple_size<remove_cvref_t<_Tuple1>>::value>());
+}
+
+template <class _Tuple1, class _Tuple2>
+_LIBCPP_HIDE_FROM_ABI constexpr bool __tuple_any_equals(const _Tuple1& __tuple1, const _Tuple2& __tuple2) {
+ const auto __equals = ranges::__tuple_zip_transform(std::equal_to<>(), __tuple1, __tuple2);
+ return std::apply([](auto... __bools) { return (__bools || ...); }, __equals);
+}
+
+// abs in cstdlib is not constexpr
+// TODO : remove __abs once P0533R9 is implemented.
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __abs(_Tp __t) {
+ return __t < 0 ? -__t : __t;
+}
+
+template <input_range... _Views>
+ requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
+class zip_view : public view_interface<zip_view<_Views...>> {
+
+ _LIBCPP_NO_UNIQUE_ADDRESS tuple<_Views...> __views_;
+
+ template <bool>
+ class __iterator;
+
+ template <bool>
+ class __sentinel;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ zip_view() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit zip_view(_Views... __views) : __views_(std::move(__views)...) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin()
+ requires(!(__simple_view<_Views> && ...)) {
+ return __iterator<false>(ranges::__tuple_transform(ranges::begin, __views_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() const
+ requires(range<const _Views> && ...) {
+ return __iterator<true>(ranges::__tuple_transform(ranges::begin, __views_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end()
+ requires(!(__simple_view<_Views> && ...)) {
+ if constexpr (!__zip_is_common<_Views...>) {
+ return __sentinel<false>(ranges::__tuple_transform(ranges::end, __views_));
+ } else if constexpr ((random_access_range<_Views> && ...)) {
+ return begin() + iter_difference_t<__iterator<false>>(size());
+ } else {
+ return __iterator<false>(ranges::__tuple_transform(ranges::end, __views_));
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const
+ requires(range<const _Views> && ...) {
+ if constexpr (!__zip_is_common<const _Views...>) {
+ return __sentinel<true>(ranges::__tuple_transform(ranges::end, __views_));
+ } else if constexpr ((random_access_range<const _Views> && ...)) {
+ return begin() + iter_difference_t<__iterator<true>>(size());
+ } else {
+ return __iterator<true>(ranges::__tuple_transform(ranges::end, __views_));
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size()
+ requires(sized_range<_Views> && ...) {
+ return std::apply(
+ [](auto... __sizes) {
+ using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>;
+ return ranges::min({_CT(__sizes)...});
+ },
+ ranges::__tuple_transform(ranges::size, __views_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const
+ requires(sized_range<const _Views> && ...) {
+ return std::apply(
+ [](auto... __sizes) {
+ using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>;
+ return ranges::min({_CT(__sizes)...});
+ },
+ ranges::__tuple_transform(ranges::size, __views_));
+ }
+};
+
+template <class... _Ranges>
+zip_view(_Ranges&&...) -> zip_view<views::all_t<_Ranges>...>;
+
+template <bool _Const, class... _Views>
+concept __zip_all_random_access = (random_access_range<__maybe_const<_Const, _Views>> && ...);
+
+template <bool _Const, class... _Views>
+concept __zip_all_bidirectional = (bidirectional_range<__maybe_const<_Const, _Views>> && ...);
+
+template <bool _Const, class... _Views>
+concept __zip_all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
+
+template <bool _Const, class... _Views>
+consteval auto __get_zip_view_iterator_tag() {
+ if constexpr (__zip_all_random_access<_Const, _Views...>) {
+ return random_access_iterator_tag();
+ } else if constexpr (__zip_all_bidirectional<_Const, _Views...>) {
+ return bidirectional_iterator_tag();
+ } else if constexpr (__zip_all_forward<_Const, _Views...>) {
+ return forward_iterator_tag();
+ } else {
+ return input_iterator_tag();
+ }
+}
+
+template <bool _Const, class... _Views>
+struct __zip_view_iterator_category_base {};
+
+template <bool _Const, class... _Views>
+ requires __zip_all_forward<_Const, _Views...>
+struct __zip_view_iterator_category_base<_Const, _Views...> {
+ using iterator_category = input_iterator_tag;
+};
+
+template <input_range... _Views>
+ requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
+template <bool _Const>
+class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base<_Const, _Views...> {
+
+ __tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current_;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __iterator(__tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current)
+ : __current_(std::move(__current)) {}
+
+ template <bool>
+ friend class zip_view<_Views...>::__iterator;
+
+ template <bool>
+ friend class zip_view<_Views...>::__sentinel;
+
+ friend class zip_view<_Views...>;
+
+public:
+ using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>());
+ using value_type = __tuple_or_pair<range_value_t<__maybe_const<_Const, _Views>>...>;
+ using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ __iterator() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator(__iterator<!_Const> __i)
+ requires _Const && (convertible_to<iterator_t<_Views>, iterator_t<__maybe_const<_Const, _Views>>> && ...)
+ : __current_(std::move(__i.__current_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator*() const {
+ return ranges::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator++() {
+ ranges::__tuple_for_each([](auto& __i) { ++__i; }, __current_);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator++(int) { ++*this; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator++(int)
+ requires __zip_all_forward<_Const, _Views...> {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator--()
+ requires __zip_all_bidirectional<_Const, _Views...> {
+ ranges::__tuple_for_each([](auto& __i) { --__i; }, __current_);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator--(int)
+ requires __zip_all_bidirectional<_Const, _Views...> {
+ auto __tmp = *this;
+ --*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator+=(difference_type __x)
+ requires __zip_all_random_access<_Const, _Views...> {
+ ranges::__tuple_for_each([&]<class _Iter>(_Iter& __i) { __i += iter_difference_t<_Iter>(__x); }, __current_);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator-=(difference_type __x)
+ requires __zip_all_random_access<_Const, _Views...> {
+ ranges::__tuple_for_each([&]<class _Iter>(_Iter& __i) { __i -= iter_difference_t<_Iter>(__x); }, __current_);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator[](difference_type __n) const
+ requires __zip_all_random_access<_Const, _Views...> {
+ return ranges::__tuple_transform(
+ [&]<class _Iter>(_Iter& __i) -> decltype(auto) { return __i[iter_difference_t<_Iter>(__n)]; }, __current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
+ requires(equality_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
+ if constexpr (__zip_all_bidirectional<_Const, _Views...>) {
+ return __x.__current_ == __y.__current_;
+ } else {
+ return ranges::__tuple_any_equals(__x.__current_, __y.__current_);
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
+ requires __zip_all_random_access<_Const, _Views...> {
+ return __x.__current_ < __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
+ requires __zip_all_random_access<_Const, _Views...> {
+ return __y < __x;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
+ requires __zip_all_random_access<_Const, _Views...> {
+ return !(__y < __x);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
+ requires __zip_all_random_access<_Const, _Views...> {
+ return !(__x < __y);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
+ requires __zip_all_random_access<_Const, _Views...> &&
+ (three_way_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
+ return __x.__current_ <=> __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
+ requires __zip_all_random_access<_Const, _Views...> {
+ auto __r = __i;
+ __r += __n;
+ return __r;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
+ requires __zip_all_random_access<_Const, _Views...> {
+ return __i + __n;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
+ requires __zip_all_random_access<_Const, _Views...> {
+ auto __r = __i;
+ __r -= __n;
+ return __r;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
+ requires(sized_sentinel_for<iterator_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_Const, _Views>>> &&
+ ...) {
+ const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __x.__current_, __y.__current_);
+ return std::apply(
+ [](auto... __ds) {
+ return ranges::min({difference_type(__ds)...},
+ [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); });
+ },
+ __diffs);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr auto iter_move(const __iterator& __i) noexcept(
+ (noexcept(ranges::iter_move(declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
+ (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {
+ return ranges::__tuple_transform(ranges::iter_move, __i.__current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept(
+ (noexcept(ranges::iter_swap(declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
+ declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
+ ...))
+ requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
+ ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_);
+ }
+};
+
+template <input_range... _Views>
+ requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
+template <bool _Const>
+class zip_view<_Views...>::__sentinel {
+
+ __tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end_;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __sentinel(__tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end) : __end_(__end) {}
+
+ friend class zip_view<_Views...>;
+
+ // hidden friend cannot access private member of iterator because they are friends of friends
+ template <bool _OtherConst>
+ _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto)
+ __iter_current(zip_view<_Views...>::__iterator<_OtherConst> const& __it) {
+ return (__it.__current_);
+ }
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ __sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __sentinel(__sentinel<!_Const> __i)
+ requires _Const && (convertible_to<sentinel_t<_Views>, sentinel_t<__maybe_const<_Const, _Views>>> && ...)
+ : __end_(std::move(__i.__end_)) {}
+
+ template <bool _OtherConst>
+ requires(sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
+ ...)
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
+ return ranges::__tuple_any_equals(__iter_current(__x), __y.__end_);
+ }
+
+ template <bool _OtherConst>
+ requires(
+ sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
+ ...)
+ _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>
+ operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
+ const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __iter_current(__x), __y.__end_);
+ return std::apply(
+ [](auto... __ds) {
+ using _Diff = common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>;
+ return ranges::min({_Diff(__ds)...},
+ [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); });
+ },
+ __diffs);
+ }
+
+ template <bool _OtherConst>
+ requires(
+ sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
+ ...)
+ _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>
+ operator-(const __sentinel& __y, const __iterator<_OtherConst>& __x) {
+ return -(__x - __y);
+ }
+};
+
+template <class... _Views>
+inline constexpr bool enable_borrowed_range<zip_view<_Views...>> = (enable_borrowed_range<_Views> && ...);
+
+namespace views {
+namespace __zip {
+
+struct __fn {
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view<tuple<>>{}; }
+
+ template <class... _Ranges>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ranges&&... __rs) const
+ noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)))
+ -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) {
+ return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...);
+ }
+};
+
+} // namespace __zip
+inline namespace __cpo {
+ inline constexpr auto zip = __zip::__fn{};
+} // namespace __cpo
+} // namespace views
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_ZIP_VIEW_H
lib/libcxx/include/__string โ lib/libcxx/include/__string/char_traits.h
@@ -1,4 +1,3 @@
-// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -7,157 +6,36 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP___STRING
-#define _LIBCPP___STRING
+#ifndef _LIBCPP___STRING_CHAR_TRAITS_H
+#define _LIBCPP___STRING_CHAR_TRAITS_H
-#include <__algorithm/copy.h>
-#include <__algorithm/copy_backward.h>
#include <__algorithm/copy_n.h>
#include <__algorithm/fill_n.h>
#include <__algorithm/find_end.h>
#include <__algorithm/find_first_of.h>
#include <__algorithm/min.h>
#include <__config>
-#include <__functional/hash.h> // for __murmur2_or_cityhash
+#include <__functional/hash.h>
#include <__iterator/iterator_traits.h>
-#include <cstdint> // for uint_least16_t
-#include <cstdio> // for EOF
-#include <cstring> // for memcpy
-#include <iosfwd> // for streampos & friends
-#include <type_traits> // for __libcpp_is_constant_evaluated
+#include <cstdint>
+#include <cstdio>
+#include <cstring>
+#include <iosfwd>
+#include <type_traits>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
# include <cwchar> // for wmemcpy
#endif
-#include <__debug>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
-// The extern template ABI lists are kept outside of <string> to improve the
-// readability of that header. We maintain 2 ABI lists:
-// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST
-// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST
-// As the name implies, the ABI lists define the V1 (Stable) and unstable ABI.
-//
-// For unstable, we may explicitly remove function that are external in V1,
-// and add (new) external functions to better control inlining and compiler
-// optimization opportunities.
-//
-// For stable, the ABI list should rarely change, except for adding new
-// functions supporting new c++ version / API changes. Typically entries
-// must never be removed from the stable list.
-#define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \
- _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
- _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
-
-#define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \
- _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
- _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
- _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
- _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
-
-
-// char_traits
-
template <class _CharT>
struct _LIBCPP_TEMPLATE_VIS char_traits
{
@@ -286,40 +164,25 @@ 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
-_CharT* __copy_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
+_CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
{
- _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__copy_constexpr() should always be constant evaluated");
- _VSTD::copy_n(__source, __n, __dest);
- return __dest;
-}
-
-template <class _CharT>
-static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-_CharT* __move_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
-{
- _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__move_constexpr() should always be constant evaluated");
- if (__n == 0)
+#ifdef _LIBCPP_COMPILER_GCC
+ if (__libcpp_is_constant_evaluated()) {
+ if (__n == 0)
+ return __dest;
+ _CharT* __allocation = new _CharT[__n];
+ std::copy_n(__source, __n, __allocation);
+ std::copy_n(static_cast<const _CharT*>(__allocation), __n, __dest);
+ delete[] __allocation;
return __dest;
- _CharT* __allocation = new _CharT[__n];
- _VSTD::__copy_constexpr(__allocation, __source, __n);
- _VSTD::__copy_constexpr(__dest, static_cast<const _CharT*>(__allocation), __n);
- delete[] __allocation;
+ }
+#endif
+ ::__builtin_memmove(__dest, __source, __n * sizeof(_CharT));
return __dest;
}
-template <class _CharT>
-static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-_CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT
-{
- _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__assign_constexpr() should always be constant evaluated");
- _VSTD::fill_n(__s, __n, __a);
- return __s;
-}
-
// char_traits<char>
template <>
@@ -357,30 +220,25 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
+
static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__move_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
- }
+ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ return std::__char_traits_move(__s1, __s2, __n);
+ }
+
static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {
- if (!__libcpp_is_constant_evaluated()) {
- _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
- }
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__copy_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
- }
+ char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ if (!__libcpp_is_constant_evaluated())
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ std::copy_n(__s2, __n, __s1);
+ return __s1;
+ }
+
static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
- {
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__assign_constexpr(__s, __n, __a)
- : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
- }
+ char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
+ std::fill_n(__s, __n, __a);
+ return __s;
+ }
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -463,30 +321,26 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
size_t length(const char_type* __s) _NOEXCEPT;
static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
+
static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__move_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n);
- }
+ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ return std::__char_traits_move(__s1, __s2, __n);
+ }
+
static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {
- if (!__libcpp_is_constant_evaluated()) {
- _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
- }
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__copy_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n);
- }
+ char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ if (!__libcpp_is_constant_evaluated())
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ std::copy_n(__s2, __n, __s1);
+ return __s1;
+ }
+
static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
- {
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__assign_constexpr(__s, __n, __a)
- : __n == 0 ? __s : _VSTD::wmemset(__s, __a, __n);
- }
+ char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
+ std::fill_n(__s, __n, __a);
+ return __s;
+ }
+
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
@@ -559,17 +413,6 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template <class _Traits>
-_LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR
-inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT {
-#if _LIBCPP_DEBUG_LEVEL >= 1
- return __s ? _Traits::length(__s) : (_VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, "p == nullptr", "null pointer pass to non-null argument of char_traits<...>::length")), 0);
-#else
- return _Traits::length(__s);
-#endif
-}
-
#ifndef _LIBCPP_HAS_NO_CHAR8_T
template <>
@@ -598,31 +441,23 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
static _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__move_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n);
- }
+ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ return std::__char_traits_move(__s1, __s2, __n);
+ }
static _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
- {
- if (!__libcpp_is_constant_evaluated()) {
- _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
- }
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__copy_constexpr(__s1, __s2, __n)
- : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
- }
+ char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ if (!__libcpp_is_constant_evaluated())
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ std::copy_n(__s2, __n, __s1);
+ return __s1;
+ }
static _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
- {
- return __libcpp_is_constant_evaluated()
- ? _VSTD::__assign_constexpr(__s, __n, __a)
- : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n);
- }
+ char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
+ std::fill_n(__s, __n, __a);
+ return __s;
+ }
static inline constexpr int_type not_eof(int_type __c) noexcept
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -679,9 +514,7 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __
return nullptr;
}
-#endif // #_LIBCPP_HAS_NO_CHAR8_T
-
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#endif // _LIBCPP_HAS_NO_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
@@ -705,12 +538,25 @@ 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_CONSTEXPR_AFTER_CXX17
- static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ return std::__char_traits_move(__s1, __s2, __n);
+ }
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ if (!__libcpp_is_constant_evaluated())
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ std::copy_n(__s2, __n, __s1);
+ return __s1;
+ }
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
+ static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
+ std::fill_n(__s, __n, __a);
+ return __s;
+ }
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -761,50 +607,6 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
return nullptr;
}
-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)
- {
- for (; __n; --__n, ++__s1, ++__s2)
- assign(*__s1, *__s2);
- }
- else if (__s2 < __s1)
- {
- __s1 += __n;
- __s2 += __n;
- for (; __n; --__n)
- assign(*--__s1, *--__s2);
- }
- return __r;
-}
-
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-char16_t*
-char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
-{
- if (!__libcpp_is_constant_evaluated()) {
- _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
- }
- char_type* __r = __s1;
- for (; __n; --__n, ++__s1, ++__s2)
- assign(*__s1, *__s2);
- return __r;
-}
-
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-char16_t*
-char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
-{
- char_type* __r = __s;
- for (; __n; --__n, ++__s)
- assign(*__s, __a);
- return __r;
-}
-
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
{
@@ -827,12 +629,23 @@ 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_CONSTEXPR_AFTER_CXX17
- static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ return std::__char_traits_move(__s1, __s2, __n);
+ }
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
+ static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ std::copy_n(__s2, __n, __s1);
+ return __s1;
+ }
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
+ static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
+ std::fill_n(__s, __n, __a);
+ return __s;
+ }
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -883,52 +696,6 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
return nullptr;
}
-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)
- {
- for (; __n; --__n, ++__s1, ++__s2)
- assign(*__s1, *__s2);
- }
- else if (__s2 < __s1)
- {
- __s1 += __n;
- __s2 += __n;
- for (; __n; --__n)
- assign(*--__s1, *--__s2);
- }
- return __r;
-}
-
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-char32_t*
-char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
-{
- if (!__libcpp_is_constant_evaluated()) {
- _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
- }
- char_type* __r = __s1;
- for (; __n; --__n, ++__s1, ++__s2)
- assign(*__s1, *__s2);
- return __r;
-}
-
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-char32_t*
-char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
-{
- char_type* __r = __s;
- for (; __n; --__n, ++__s)
- assign(*__s, __a);
- return __r;
-}
-
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
-
// helper fns for basic_string and string_view
// __str_find
@@ -1035,9 +802,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
__pos += __n;
else
__pos = __sz;
- const _CharT* __r = _VSTD::__find_end(
- __p, __p + __pos, __s, __s + __n, _Traits::eq,
- random_access_iterator_tag(), random_access_iterator_tag());
+ const _CharT* __r = std::__find_end_classic(__p, __p + __pos, __s, __s + __n, _Traits::eq);
if (__n > 0 && __r == __p + __pos)
return __npos;
return static_cast<_SizeT>(__r - __p);
@@ -1155,21 +920,8 @@ size_t __do_string_hash(_Ptr __p, _Ptr __e)
return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type));
}
-template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> >
-struct __quoted_output_proxy
-{
- _Iter __first;
- _Iter __last;
- _CharT __delim;
- _CharT __escape;
-
- __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
-};
-
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___STRING
+#endif // _LIBCPP___STRING_CHAR_TRAITS_H
lib/libcxx/include/__string/extern_template_lists.h
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H
+#define _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// We maintain 2 ABI lists:
+// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST
+// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST
+// As the name implies, the ABI lists define the V1 (Stable) and unstable ABI.
+//
+// For unstable, we may explicitly remove function that are external in V1,
+// and add (new) external functions to better control inlining and compiler
+// optimization opportunities.
+//
+// For stable, the ABI list should rarely change, except for adding new
+// functions supporting new c++ version / API changes. Typically entries
+// must never be removed from the stable list.
+#define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
+ _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
+
+#define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
+ _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \
+ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
+
+
+#endif // _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H
lib/libcxx/include/__support/android/locale_bionic.h
@@ -26,10 +26,15 @@ extern "C" {
#if defined(__ANDROID__)
#include <android/api-level.h>
-#include <android/ndk-version.h>
#if __ANDROID_API__ < 21
#include <__support/xlocale/__posix_l_fallback.h>
#endif
+
+// If we do not have this header, we are in a platform build rather than an NDK
+// build, which will always be at least as new as the ToT NDK, in which case we
+// don't need any of the inlines below since libc provides them.
+#if __has_include(<android/ndk-version.h>)
+#include <android/ndk-version.h>
// In NDK versions later than 16, locale-aware functions are provided by
// legacy_stdlib_inlines.h
#if __NDK_MAJOR__ <= 16
@@ -41,18 +46,18 @@ extern "C" {
extern "C" {
#endif
-inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char* __nptr, char** __endptr,
- locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI float
+strtof_l(const char* __nptr, char** __endptr, locale_t) {
return ::strtof(__nptr, __endptr);
}
-inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char* __nptr,
- char** __endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI double
+strtod_l(const char* __nptr, char** __endptr, locale_t) {
return ::strtod(__nptr, __endptr);
}
-inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endptr,
- int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI long
+strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtol(__nptr, __endptr, __base);
}
@@ -63,6 +68,7 @@ inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endp
#endif // __ANDROID_API__ < 26
#endif // __NDK_MAJOR__ <= 16
+#endif // __has_include(<android/ndk-version.h>)
#endif // defined(__ANDROID__)
#endif // defined(__BIONIC__)
lib/libcxx/include/__support/ibm/gettod_zos.h
@@ -12,7 +12,8 @@
#include <time.h>
-static inline int gettimeofdayMonotonic(struct timespec64* Output) {
+inline _LIBCPP_HIDE_FROM_ABI int
+gettimeofdayMonotonic(struct timespec64* Output) {
// The POSIX gettimeofday() function is not available on z/OS. Therefore,
// we will call stcke and other hardware instructions in implement equivalent.
lib/libcxx/include/__support/ibm/limits.h
@@ -1,98 +0,0 @@
-// -*- C++ -*-
-//===-----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_IBM_LIMITS_H
-#define _LIBCPP_SUPPORT_IBM_LIMITS_H
-
-#if !defined(_AIX) // Linux
-#include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN
-
-static const unsigned int _QNAN_F = 0x7fc00000;
-#define NANF (*((float *)(&_QNAN_F)))
-static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0};
-#define NANL (*((long double *)(&_QNAN_LDBL128)))
-static const unsigned int _SNAN_F= 0x7f855555;
-#define NANSF (*((float *)(&_SNAN_F)))
-static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555};
-#define NANS (*((double *)(&_SNAN_D)))
-static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0};
-#define NANSL (*((long double *)(&_SNAN_LDBL128)))
-
-#define __builtin_huge_val() HUGE_VAL
-#define __builtin_huge_valf() HUGE_VALF
-#define __builtin_huge_vall() HUGE_VALL
-#define __builtin_nan(__dummy) NAN
-#define __builtin_nanf(__dummy) NANF
-#define __builtin_nanl(__dummy) NANL
-#define __builtin_nans(__dummy) NANS
-#define __builtin_nansf(__dummy) NANSF
-#define __builtin_nansl(__dummy) NANSL
-
-#else
-
-#include <math.h>
-#include <float.h> // limit constants
-
-#define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000
-#define __builtin_huge_valf() HUGE_VALF //0x7f800000
-#define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000
-#define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000
-#define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000
-#define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000
-#define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555
-#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555
-#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555
-
-#define __FLT_MANT_DIG__ FLT_MANT_DIG
-#define __FLT_DIG__ FLT_DIG
-#define __FLT_RADIX__ FLT_RADIX
-#define __FLT_MIN_EXP__ FLT_MIN_EXP
-#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
-#define __FLT_MAX_EXP__ FLT_MAX_EXP
-#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
-#define __FLT_MIN__ FLT_MIN
-#define __FLT_MAX__ FLT_MAX
-#define __FLT_EPSILON__ FLT_EPSILON
-// predefined by XLC on LoP
-#define __FLT_DENORM_MIN__ 1.40129846e-45F
-
-#define __DBL_MANT_DIG__ DBL_MANT_DIG
-#define __DBL_DIG__ DBL_DIG
-#define __DBL_MIN_EXP__ DBL_MIN_EXP
-#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
-#define __DBL_MAX_EXP__ DBL_MAX_EXP
-#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
-#define __DBL_MIN__ DBL_MIN
-#define __DBL_MAX__ DBL_MAX
-#define __DBL_EPSILON__ DBL_EPSILON
-// predefined by XLC on LoP
-#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-
-#define __LDBL_MANT_DIG__ LDBL_MANT_DIG
-#define __LDBL_DIG__ LDBL_DIG
-#define __LDBL_MIN_EXP__ LDBL_MIN_EXP
-#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
-#define __LDBL_MAX_EXP__ LDBL_MAX_EXP
-#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
-#define __LDBL_MIN__ LDBL_MIN
-#define __LDBL_MAX__ LDBL_MAX
-#define __LDBL_EPSILON__ LDBL_EPSILON
-// predefined by XLC on LoP
-#if __LONGDOUBLE128
-#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
-#else
-#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
-#endif
-
-// predefined by XLC on LoP
-#define __CHAR_BIT__ 8
-
-#endif // _AIX
-
-#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H
lib/libcxx/include/__support/ibm/support.h
@@ -1,53 +0,0 @@
-// -*- C++ -*-
-//===-----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H
-#define _LIBCPP_SUPPORT_IBM_SUPPORT_H
-
-extern "builtin" int __popcnt4(unsigned int);
-extern "builtin" int __popcnt8(unsigned long long);
-extern "builtin" unsigned int __cnttz4(unsigned int);
-extern "builtin" unsigned int __cnttz8(unsigned long long);
-extern "builtin" unsigned int __cntlz4(unsigned int);
-extern "builtin" unsigned int __cntlz8(unsigned long long);
-
-// Builtin functions for counting population
-#define __builtin_popcount(x) __popcnt4(x)
-#define __builtin_popcountll(x) __popcnt8(x)
-#if defined(__64BIT__)
-#define __builtin_popcountl(x) __builtin_popcountll(x)
-#else
-#define __builtin_popcountl(x) __builtin_popcount(x)
-#endif
-
-// Builtin functions for counting trailing zeros
-#define __builtin_ctz(x) __cnttz4(x)
-#define __builtin_ctzll(x) __cnttz8(x)
-#if defined(__64BIT__)
-#define __builtin_ctzl(x) __builtin_ctzll(x)
-#else
-#define __builtin_ctzl(x) __builtin_ctz(x)
-#endif
-
-// Builtin functions for counting leading zeros
-#define __builtin_clz(x) __cntlz4(x)
-#define __builtin_clzll(x) __cntlz8(x)
-#if defined(__64BIT__)
-#define __builtin_clzl(x) __builtin_clzll(x)
-#else
-#define __builtin_clzl(x) __builtin_clz(x)
-#endif
-
-#if defined(__64BIT__)
-#define __SIZE_WIDTH__ 64
-#else
-#define __SIZE_WIDTH__ 32
-#endif
-
-#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H
lib/libcxx/include/__support/ibm/xlocale.h
@@ -10,7 +10,10 @@
#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
#define _LIBCPP_SUPPORT_IBM_XLOCALE_H
+#if defined(__MVS__)
#include <__support/ibm/locale_mgmt_zos.h>
+#endif // defined(__MVS__)
+
#include <stdarg.h>
#include "cstdlib"
@@ -52,57 +55,50 @@ private:
// The following are not POSIX routines. These are quick-and-dirty hacks
// to make things pretend to work
-static inline
-long long strtoll_l(const char *__nptr, char **__endptr,
- int __base, locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI long long
+strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t locale) {
__setAndRestore __newloc(locale);
- return strtoll(__nptr, __endptr, __base);
+ return ::strtoll(__nptr, __endptr, __base);
}
-static inline
-long strtol_l(const char *__nptr, char **__endptr,
- int __base, locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI long
+strtol_l(const char *__nptr, char **__endptr, int __base, locale_t locale) {
__setAndRestore __newloc(locale);
- return strtol(__nptr, __endptr, __base);
+ return ::strtol(__nptr, __endptr, __base);
}
-static inline
-double strtod_l(const char *__nptr, char **__endptr,
- locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI double
+strtod_l(const char *__nptr, char **__endptr, locale_t locale) {
__setAndRestore __newloc(locale);
- return strtod(__nptr, __endptr);
+ return ::strtod(__nptr, __endptr);
}
-static inline
-float strtof_l(const char *__nptr, char **__endptr,
- locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI float
+strtof_l(const char *__nptr, char **__endptr, locale_t locale) {
__setAndRestore __newloc(locale);
- return strtof(__nptr, __endptr);
+ return ::strtof(__nptr, __endptr);
}
-static inline
-long double strtold_l(const char *__nptr, char **__endptr,
- locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI long double
+strtold_l(const char *__nptr, char **__endptr, locale_t locale) {
__setAndRestore __newloc(locale);
- return strtold(__nptr, __endptr);
+ return ::strtold(__nptr, __endptr);
}
-static inline
-unsigned long long strtoull_l(const char *__nptr, char **__endptr,
- int __base, locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI unsigned long long
+strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t locale) {
__setAndRestore __newloc(locale);
- return strtoull(__nptr, __endptr, __base);
+ return ::strtoull(__nptr, __endptr, __base);
}
-static inline
-unsigned long strtoul_l(const char *__nptr, char **__endptr,
- int __base, locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI unsigned long
+strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t locale) {
__setAndRestore __newloc(locale);
- return strtoul(__nptr, __endptr, __base);
+ return ::strtoul(__nptr, __endptr, __base);
}
-static inline
-int vasprintf(char **strp, const char *fmt, va_list ap) {
+inline _LIBCPP_HIDE_FROM_ABI int
+vasprintf(char **strp, const char *fmt, va_list ap) {
const size_t buff_size = 256;
if ((*strp = (char *)malloc(buff_size)) == NULL) {
return -1;
lib/libcxx/include/__support/musl/xlocale.h
@@ -24,30 +24,29 @@
extern "C" {
#endif
-static inline long long strtoll_l(const char *nptr, char **endptr, int base,
- locale_t) {
- return strtoll(nptr, endptr, base);
+inline _LIBCPP_HIDE_FROM_ABI long long
+strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+ return ::strtoll(__nptr, __endptr, __base);
}
-static inline unsigned long long strtoull_l(const char *nptr, char **endptr,
- int base, locale_t) {
- return strtoull(nptr, endptr, base);
+inline _LIBCPP_HIDE_FROM_ABI unsigned long long
+strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+ return ::strtoull(__nptr, __endptr, __base);
}
-static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr,
- int base, locale_t) {
- return wcstoll(nptr, endptr, base);
+inline _LIBCPP_HIDE_FROM_ABI long long
+wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
+ return ::wcstoll(__nptr, __endptr, __base);
}
-static inline unsigned long long wcstoull_l(const wchar_t *nptr,
- wchar_t **endptr, int base,
- locale_t) {
- return wcstoull(nptr, endptr, base);
+inline _LIBCPP_HIDE_FROM_ABI long long
+wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
+ return ::wcstoull(__nptr, __endptr, __base);
}
-static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr,
- locale_t) {
- return wcstold(nptr, endptr);
+inline _LIBCPP_HIDE_FROM_ABI long double
+wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
+ return ::wcstold(__nptr, __endptr);
}
#ifdef __cplusplus
lib/libcxx/include/__support/openbsd/xlocale.h
@@ -22,13 +22,13 @@ extern "C" {
inline _LIBCPP_HIDE_FROM_ABI long
-strtol_l(const char *nptr, char **endptr, int base, locale_t) {
- return ::strtol(nptr, endptr, base);
+strtol_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+ return ::strtol(__nptr, __endptr, __base);
}
inline _LIBCPP_HIDE_FROM_ABI unsigned long
-strtoul_l(const char *nptr, char **endptr, int base, locale_t) {
- return ::strtoul(nptr, endptr, base);
+strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+ return ::strtoul(__nptr, __endptr, __base);
}
lib/libcxx/include/__support/solaris/xlocale.h
@@ -32,40 +32,39 @@ struct lconv *localeconv(void);
struct lconv *localeconv_l(locale_t __l);
// FIXME: These are quick-and-dirty hacks to make things pretend to work
-static inline
-long long strtoll_l(const char *__nptr, char **__endptr,
- int __base, locale_t __loc) {
- return strtoll(__nptr, __endptr, __base);
+inline _LIBCPP_HIDE_FROM_ABI long long
+strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) {
+ return ::strtoll(__nptr, __endptr, __base);
}
-static inline
-long strtol_l(const char *__nptr, char **__endptr,
- int __base, locale_t __loc) {
- return strtol(__nptr, __endptr, __base);
+
+inline _LIBCPP_HIDE_FROM_ABI long
+strtol_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) {
+ return ::strtol(__nptr, __endptr, __base);
}
-static inline
-unsigned long long strtoull_l(const char *__nptr, char **__endptr,
- int __base, locale_t __loc) {
- return strtoull(__nptr, __endptr, __base);
+
+inline _LIBCPP_HIDE_FROM_ABI unsigned long long
+strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t __loc)
+ return ::strtoull(__nptr, __endptr, __base);
}
-static inline
-unsigned long strtoul_l(const char *__nptr, char **__endptr,
- int __base, locale_t __loc) {
- return strtoul(__nptr, __endptr, __base);
+
+inline _LIBCPP_HIDE_FROM_ABI unsigned long
+strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) {
+ return ::strtoul(__nptr, __endptr, __base);
}
-static inline
-float strtof_l(const char *__nptr, char **__endptr,
- locale_t __loc) {
- return strtof(__nptr, __endptr);
+
+inline _LIBCPP_HIDE_FROM_ABI float
+strtof_l(const char *__nptr, char **__endptr, locale_t __loc) {
+ return ::strtof(__nptr, __endptr);
}
-static inline
-double strtod_l(const char *__nptr, char **__endptr,
- locale_t __loc) {
- return strtod(__nptr, __endptr);
+
+inline _LIBCPP_HIDE_FROM_ABI double
+strtod_l(const char *__nptr, char **__endptr, locale_t __loc) {
+ return ::strtod(__nptr, __endptr);
}
-static inline
-long double strtold_l(const char *__nptr, char **__endptr,
- locale_t __loc) {
- return strtold(__nptr, __endptr);
+
+inline _LIBCPP_HIDE_FROM_ABI long double
+strtold_l(const char *__nptr, char **__endptr, locale_t __loc) {
+ return ::strtold(__nptr, __endptr);
}
lib/libcxx/include/__support/win32/locale_win32.h
@@ -11,7 +11,7 @@
#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
#include <__config>
-#include <__nullptr>
+#include <cstddef>
#include <locale.h> // _locale_t
#include <stdio.h>
@@ -186,28 +186,28 @@ private:
// Locale management functions
#define freelocale _free_locale
// FIXME: base currently unused. Needs manual work to construct the new locale
-locale_t newlocale( int mask, const char * locale, locale_t base );
+locale_t newlocale( int __mask, const char * __locale, locale_t __base );
// uselocale can't be implemented on Windows because Windows allows partial modification
// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
// not create any copies.
// We can still implement raii even without uselocale though.
-lconv *localeconv_l( locale_t &loc );
-size_t mbrlen_l( const char *__restrict s, size_t n,
- mbstate_t *__restrict ps, locale_t loc);
-size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
- size_t len, mbstate_t *__restrict ps, locale_t loc );
-size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
- locale_t loc);
-size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
- size_t n, mbstate_t *__restrict ps, locale_t loc);
-size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
- size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc);
-size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src,
- size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc);
-wint_t btowc_l( int c, locale_t loc );
-int wctob_l( wint_t c, locale_t loc );
+lconv *localeconv_l( locale_t & __loc );
+size_t mbrlen_l( const char *__restrict __s, size_t __n,
+ mbstate_t *__restrict __ps, locale_t __loc);
+size_t mbsrtowcs_l( wchar_t *__restrict __dst, const char **__restrict __src,
+ size_t __len, mbstate_t *__restrict __ps, locale_t __loc );
+size_t wcrtomb_l( char *__restrict __s, wchar_t __wc, mbstate_t *__restrict __ps,
+ locale_t __loc);
+size_t mbrtowc_l( wchar_t *__restrict __pwc, const char *__restrict __s,
+ size_t __n, mbstate_t *__restrict __ps, locale_t __loc);
+size_t mbsnrtowcs_l( wchar_t *__restrict __dst, const char **__restrict __src,
+ size_t __nms, size_t __len, mbstate_t *__restrict __ps, locale_t __loc);
+size_t wcsnrtombs_l( char *__restrict __dst, const wchar_t **__restrict __src,
+ size_t __nwc, size_t __len, mbstate_t *__restrict __ps, locale_t __loc);
+wint_t btowc_l( int __c, locale_t __loc );
+int wctob_l( wint_t __c, locale_t __loc );
decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );
@@ -223,18 +223,16 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l );
_LIBCPP_FUNC_VIS float strtof_l(const char*, char**, locale_t);
_LIBCPP_FUNC_VIS long double strtold_l(const char*, char**, locale_t);
#endif
-inline _LIBCPP_INLINE_VISIBILITY
-int
-islower_l(int c, _locale_t loc)
+inline _LIBCPP_HIDE_FROM_ABI int
+islower_l(int __c, _locale_t __loc)
{
- return _islower_l((int)c, loc);
+ return _islower_l((int)__c, __loc);
}
-inline _LIBCPP_INLINE_VISIBILITY
-int
-isupper_l(int c, _locale_t loc)
+inline _LIBCPP_HIDE_FROM_ABI int
+isupper_l(int __c, _locale_t __loc)
{
- return _isupper_l((int)c, loc);
+ return _isupper_l((int)__c, __loc);
}
#define isdigit_l _isdigit_l
@@ -266,18 +264,18 @@ _LIBCPP_FUNC_VIS size_t strftime_l(char *ret, size_t n, const char *format,
#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )
#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
-_LIBCPP_FUNC_VIS int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...);
-_LIBCPP_FUNC_VIS int asprintf_l( char **ret, locale_t loc, const char *format, ... );
-_LIBCPP_FUNC_VIS int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
+_LIBCPP_FUNC_VIS int snprintf_l(char *__ret, size_t __n, locale_t __loc, const char *__format, ...);
+_LIBCPP_FUNC_VIS int asprintf_l( char **__ret, locale_t __loc, const char *__format, ... );
+_LIBCPP_FUNC_VIS int vasprintf_l( char **__ret, locale_t __loc, const char *__format, va_list __ap );
// not-so-pressing FIXME: use locale to determine blank characters
-inline int isblank_l( int c, locale_t /*loc*/ )
+inline int isblank_l( int __c, locale_t /*loc*/ )
{
- return ( c == ' ' || c == '\t' );
+ return ( __c == ' ' || __c == '\t' );
}
-inline int iswblank_l( wint_t c, locale_t /*loc*/ )
+inline int iswblank_l( wint_t __c, locale_t /*loc*/ )
{
- return ( c == L' ' || c == L'\t' );
+ return ( __c == L' ' || __c == L'\t' );
}
#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h
@@ -16,18 +16,23 @@ extern "C" {
// Patch over lack of extended locale support
typedef void *locale_t;
-static inline locale_t duplocale(locale_t) {
+
+inline _LIBCPP_HIDE_FROM_ABI locale_t
+duplocale(locale_t) {
return NULL;
}
-static inline void freelocale(locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI void
+freelocale(locale_t) {
}
-static inline locale_t newlocale(int, const char *, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI locale_t
+newlocale(int, const char *, locale_t) {
return NULL;
}
-static inline locale_t uselocale(locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI locale_t
+uselocale(locale_t) {
return NULL;
}
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h
@@ -19,142 +19,142 @@
extern "C" {
#endif
-inline _LIBCPP_INLINE_VISIBILITY int isalnum_l(int c, locale_t) {
- return ::isalnum(c);
+inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) {
+ return ::isalnum(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int isalpha_l(int c, locale_t) {
- return ::isalpha(c);
+inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) {
+ return ::isalpha(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int isblank_l(int c, locale_t) {
- return ::isblank(c);
+inline _LIBCPP_HIDE_FROM_ABI int isblank_l(int __c, locale_t) {
+ return ::isblank(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iscntrl_l(int c, locale_t) {
- return ::iscntrl(c);
+inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) {
+ return ::iscntrl(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int isdigit_l(int c, locale_t) {
- return ::isdigit(c);
+inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) {
+ return ::isdigit(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int isgraph_l(int c, locale_t) {
- return ::isgraph(c);
+inline _LIBCPP_HIDE_FROM_ABI int isgraph_l(int __c, locale_t) {
+ return ::isgraph(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int islower_l(int c, locale_t) {
- return ::islower(c);
+inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) {
+ return ::islower(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int isprint_l(int c, locale_t) {
- return ::isprint(c);
+inline _LIBCPP_HIDE_FROM_ABI int isprint_l(int __c, locale_t) {
+ return ::isprint(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int ispunct_l(int c, locale_t) {
- return ::ispunct(c);
+inline _LIBCPP_HIDE_FROM_ABI int ispunct_l(int __c, locale_t) {
+ return ::ispunct(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int isspace_l(int c, locale_t) {
- return ::isspace(c);
+inline _LIBCPP_HIDE_FROM_ABI int isspace_l(int __c, locale_t) {
+ return ::isspace(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int isupper_l(int c, locale_t) {
- return ::isupper(c);
+inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) {
+ return ::isupper(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int isxdigit_l(int c, locale_t) {
- return ::isxdigit(c);
+inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) {
+ return ::isxdigit(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswalnum_l(wint_t c, locale_t) {
- return ::iswalnum(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) {
+ return ::iswalnum(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswalpha_l(wint_t c, locale_t) {
- return ::iswalpha(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) {
+ return ::iswalpha(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswblank_l(wint_t c, locale_t) {
- return ::iswblank(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswblank_l(wint_t __c, locale_t) {
+ return ::iswblank(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) {
- return ::iswcntrl(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) {
+ return ::iswcntrl(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswdigit_l(wint_t c, locale_t) {
- return ::iswdigit(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) {
+ return ::iswdigit(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswgraph_l(wint_t c, locale_t) {
- return ::iswgraph(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswgraph_l(wint_t __c, locale_t) {
+ return ::iswgraph(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswlower_l(wint_t c, locale_t) {
- return ::iswlower(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) {
+ return ::iswlower(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswprint_l(wint_t c, locale_t) {
- return ::iswprint(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) {
+ return ::iswprint(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswpunct_l(wint_t c, locale_t) {
- return ::iswpunct(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswpunct_l(wint_t __c, locale_t) {
+ return ::iswpunct(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswspace_l(wint_t c, locale_t) {
- return ::iswspace(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswspace_l(wint_t __c, locale_t) {
+ return ::iswspace(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswupper_l(wint_t c, locale_t) {
- return ::iswupper(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswupper_l(wint_t __c, locale_t) {
+ return ::iswupper(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int iswxdigit_l(wint_t c, locale_t) {
- return ::iswxdigit(c);
+inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) {
+ return ::iswxdigit(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int toupper_l(int c, locale_t) {
- return ::toupper(c);
+inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
+ return ::toupper(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int tolower_l(int c, locale_t) {
- return ::tolower(c);
+inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
+ return ::tolower(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY wint_t towupper_l(wint_t c, locale_t) {
- return ::towupper(c);
+inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
+ return ::towupper(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY wint_t towlower_l(wint_t c, locale_t) {
- return ::towlower(c);
+inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) {
+ return ::towlower(__c);
}
-inline _LIBCPP_INLINE_VISIBILITY int strcoll_l(const char *s1, const char *s2,
- locale_t) {
- return ::strcoll(s1, s2);
+inline _LIBCPP_HIDE_FROM_ABI int
+strcoll_l(const char *__s1, const char *__s2, locale_t) {
+ return ::strcoll(__s1, __s2);
}
-inline _LIBCPP_INLINE_VISIBILITY size_t strxfrm_l(char *dest, const char *src,
- size_t n, locale_t) {
- return ::strxfrm(dest, src, n);
+inline _LIBCPP_HIDE_FROM_ABI size_t
+strxfrm_l(char *__dest, const char *__src, size_t __n, locale_t) {
+ return ::strxfrm(__dest, __src, __n);
}
-inline _LIBCPP_INLINE_VISIBILITY size_t strftime_l(char *s, size_t max,
- const char *format,
- const struct tm *tm, locale_t) {
- return ::strftime(s, max, format, tm);
+inline _LIBCPP_HIDE_FROM_ABI size_t
+strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm,
+ locale_t) {
+ return ::strftime(__s, __max, __format, __tm);
}
-inline _LIBCPP_INLINE_VISIBILITY int wcscoll_l(const wchar_t *ws1,
- const wchar_t *ws2, locale_t) {
- return ::wcscoll(ws1, ws2);
+inline _LIBCPP_HIDE_FROM_ABI int
+wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) {
+ return ::wcscoll(__ws1, __ws2);
}
-inline _LIBCPP_INLINE_VISIBILITY size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src,
- size_t n, locale_t) {
- return ::wcsxfrm(dest, src, n);
+inline _LIBCPP_HIDE_FROM_ABI size_t
+wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) {
+ return ::wcsxfrm(__dest, __src, __n);
}
#ifdef __cplusplus
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h
@@ -19,44 +19,44 @@
extern "C" {
#endif
-inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char *nptr,
- char **endptr, locale_t) {
- return ::strtof(nptr, endptr);
+inline _LIBCPP_HIDE_FROM_ABI float
+strtof_l(const char *__nptr, char **__endptr, locale_t) {
+ return ::strtof(__nptr, __endptr);
}
-inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char *nptr,
- char **endptr, locale_t) {
- return ::strtod(nptr, endptr);
+inline _LIBCPP_HIDE_FROM_ABI double
+strtod_l(const char *__nptr, char **__endptr, locale_t) {
+ return ::strtod(__nptr, __endptr);
}
-inline _LIBCPP_INLINE_VISIBILITY long double strtold_l(const char *nptr,
- char **endptr, locale_t) {
- return ::strtold(nptr, endptr);
+inline _LIBCPP_HIDE_FROM_ABI long double
+strtold_l(const char *__nptr, char **__endptr, locale_t) {
+ return ::strtold(__nptr, __endptr);
}
-inline _LIBCPP_INLINE_VISIBILITY long long
-strtoll_l(const char *nptr, char **endptr, int base, locale_t) {
- return ::strtoll(nptr, endptr, base);
+inline _LIBCPP_HIDE_FROM_ABI long long
+strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+ return ::strtoll(__nptr, __endptr, __base);
}
-inline _LIBCPP_INLINE_VISIBILITY unsigned long long
-strtoull_l(const char *nptr, char **endptr, int base, locale_t) {
- return ::strtoull(nptr, endptr, base);
+inline _LIBCPP_HIDE_FROM_ABI unsigned long long
+strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+ return ::strtoull(__nptr, __endptr, __base);
}
-inline _LIBCPP_INLINE_VISIBILITY long long
-wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) {
- return ::wcstoll(nptr, endptr, base);
+inline _LIBCPP_HIDE_FROM_ABI long long
+wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
+ return ::wcstoll(__nptr, __endptr, __base);
}
-inline _LIBCPP_INLINE_VISIBILITY unsigned long long
-wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) {
- return ::wcstoull(nptr, endptr, base);
+inline _LIBCPP_HIDE_FROM_ABI unsigned long long
+wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
+ return ::wcstoull(__nptr, __endptr, __base);
}
-inline _LIBCPP_INLINE_VISIBILITY long double wcstold_l(const wchar_t *nptr,
- wchar_t **endptr, locale_t) {
- return ::wcstold(nptr, endptr);
+inline _LIBCPP_HIDE_FROM_ABI long double
+wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
+ return ::wcstold(__nptr, __endptr);
}
#ifdef __cplusplus
lib/libcxx/include/__thread/poll_with_backoff.h
@@ -10,11 +10,15 @@
#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
#include <__availability>
+#include <__chrono/duration.h>
+#include <__chrono/high_resolution_clock.h>
+#include <__chrono/steady_clock.h>
+#include <__chrono/time_point.h>
#include <__config>
-#include <chrono>
+#include <__filesystem/file_time_type.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__thread/timed_backoff_policy.h
@@ -13,11 +13,11 @@
#ifndef _LIBCPP_HAS_NO_THREADS
-#include <__threading_support>
-#include <chrono>
+# include <__chrono/duration.h>
+# include <__threading_support>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__type_traits/add_const.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ADD_CONST_H
+#define _LIBCPP___TYPE_TRAITS_ADD_CONST_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const {
+ typedef _LIBCPP_NODEBUG const _Tp type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ADD_CONST_H
lib/libcxx/include/__type_traits/add_cv.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ADD_CV_H
+#define _LIBCPP___TYPE_TRAITS_ADD_CV_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv {
+ typedef _LIBCPP_NODEBUG const volatile _Tp type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H
lib/libcxx/include/__type_traits/add_lvalue_reference.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
+#define _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
+
+#include <__config>
+#include <__type_traits/is_referenceable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
+template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; };
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
+{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
lib/libcxx/include/__type_traits/add_pointer.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
+#define _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
+
+#include <__config>
+#include <__type_traits/is_referenceable.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp,
+ bool = __is_referenceable<_Tp>::value ||
+ _IsSame<typename remove_cv<_Tp>::type, void>::value>
+struct __add_pointer_impl
+ {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;};
+template <class _Tp> struct __add_pointer_impl<_Tp, false>
+ {typedef _LIBCPP_NODEBUG _Tp type;};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
+ {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
lib/libcxx/include/__type_traits/add_rvalue_reference.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
+#define _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
+
+#include <__config>
+#include <__type_traits/is_referenceable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
+template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; };
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
+{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
lib/libcxx/include/__type_traits/add_volatile.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H
+#define _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile {
+ typedef _LIBCPP_NODEBUG volatile _Tp type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H
lib/libcxx/include/__type_traits/aligned_storage.h
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H
+#define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/nat.h>
+#include <__type_traits/type_list.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __align_type
+{
+ static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
+ typedef _Tp type;
+};
+
+struct __struct_double {long double __lx;};
+struct __struct_double4 {double __lx[4];};
+
+typedef
+ __type_list<__align_type<unsigned char>,
+ __type_list<__align_type<unsigned short>,
+ __type_list<__align_type<unsigned int>,
+ __type_list<__align_type<unsigned long>,
+ __type_list<__align_type<unsigned long long>,
+ __type_list<__align_type<double>,
+ __type_list<__align_type<long double>,
+ __type_list<__align_type<__struct_double>,
+ __type_list<__align_type<__struct_double4>,
+ __type_list<__align_type<int*>,
+ __nat
+ > > > > > > > > > > __all_types;
+
+template <size_t _Align>
+struct _ALIGNAS(_Align) __fallback_overaligned {};
+
+template <class _TL, size_t _Align> struct __find_pod;
+
+template <class _Hp, size_t _Align>
+struct __find_pod<__type_list<_Hp, __nat>, _Align>
+{
+ typedef typename conditional<
+ _Align == _Hp::value,
+ typename _Hp::type,
+ __fallback_overaligned<_Align>
+ >::type type;
+};
+
+template <class _Hp, class _Tp, size_t _Align>
+struct __find_pod<__type_list<_Hp, _Tp>, _Align>
+{
+ typedef typename conditional<
+ _Align == _Hp::value,
+ typename _Hp::type,
+ typename __find_pod<_Tp, _Align>::type
+ >::type type;
+};
+
+template <class _TL, size_t _Len> struct __find_max_align;
+
+template <class _Hp, size_t _Len>
+struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
+
+template <size_t _Len, size_t _A1, size_t _A2>
+struct __select_align
+{
+private:
+ static const size_t __min = _A2 < _A1 ? _A2 : _A1;
+ static const size_t __max = _A1 < _A2 ? _A2 : _A1;
+public:
+ static const size_t value = _Len < __max ? __min : __max;
+};
+
+template <class _Hp, class _Tp, size_t _Len>
+struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
+ : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
+
+template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
+struct _LIBCPP_TEMPLATE_VIS aligned_storage
+{
+ typedef typename __find_pod<__all_types, _Align>::type _Aligner;
+ union type
+ {
+ _Aligner __align;
+ unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
+ };
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
+ using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
+#endif
+
+#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
+template <size_t _Len>\
+struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
+{\
+ struct _ALIGNAS(n) type\
+ {\
+ unsigned char __lx[(_Len + n - 1)/n * n];\
+ };\
+}
+
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
+// PE/COFF does not support alignment beyond 8192 (=0x2000)
+#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
+#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+
+#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H
lib/libcxx/include/__type_traits/aligned_union.h
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
+#define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
+
+#include <__config>
+#include <__type_traits/aligned_storage.h>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <size_t _I0, size_t ..._In>
+struct __static_max;
+
+template <size_t _I0>
+struct __static_max<_I0>
+{
+ static const size_t value = _I0;
+};
+
+template <size_t _I0, size_t _I1, size_t ..._In>
+struct __static_max<_I0, _I1, _In...>
+{
+ static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
+ __static_max<_I1, _In...>::value;
+};
+
+template <size_t _Len, class _Type0, class ..._Types>
+struct aligned_union
+{
+ static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
+ _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
+ static const size_t __len = __static_max<_Len, sizeof(_Type0),
+ sizeof(_Types)...>::value;
+ typedef typename aligned_storage<__len, alignment_value>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
lib/libcxx/include/__type_traits/alignment_of.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H
+#define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
+ : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H
lib/libcxx/include/__type_traits/apply_cv.h
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_APPLY_CV_H
+#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_volatile.h>
+#include <__type_traits/remove_reference.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
+ bool = is_volatile<typename remove_reference<_Tp>::type>::value>
+struct __apply_cv
+{
+ typedef _LIBCPP_NODEBUG _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, true, false>
+{
+ typedef _LIBCPP_NODEBUG const _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, false, true>
+{
+ typedef volatile _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, true, true>
+{
+ typedef const volatile _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, false, false>
+{
+ typedef _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, true, false>
+{
+ typedef const _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, false, true>
+{
+ typedef volatile _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, true, true>
+{
+ typedef const volatile _Up& type;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_APPLY_CV_H
lib/libcxx/include/__type_traits/common_reference.h
@@ -0,0 +1,188 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H
+#define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H
+
+#include <__config>
+#include <__type_traits/common_type.h>
+#include <__type_traits/copy_cv.h>
+#include <__type_traits/copy_cvref.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/remove_reference.h>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// common_reference
+#if _LIBCPP_STD_VER > 17
+// Let COND_RES(X, Y) be:
+template <class _Xp, class _Yp>
+using __cond_res =
+ decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
+
+// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
+// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
+// `U`.
+// [Note: `XREF(A)` is `__xref<A>::template __apply`]
+template <class _Tp>
+struct __xref {
+ template<class _Up>
+ using __apply = __copy_cvref_t<_Tp, _Up>;
+};
+
+// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
+// and let COMMON-REF(A, B) be:
+template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>>
+struct __common_ref;
+
+template<class _Xp, class _Yp>
+using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;
+
+template<class _Xp, class _Yp>
+using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
+
+
+// If A and B are both lvalue reference types, COMMON-REF(A, B) is
+// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>>
+struct __common_ref<_Ap&, _Bp&, _Xp, _Yp>
+{
+ using __type = __cv_cond_res<_Xp, _Yp>;
+};
+
+// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
+template <class _Xp, class _Yp>
+using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
+
+
+// .... If A and B are both rvalue reference types, C is well-formed, and
+// is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+requires
+ requires { typename __common_ref_C<_Xp, _Yp>; } &&
+ is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
+ is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
+struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp>
+{
+ using __type = __common_ref_C<_Xp, _Yp>;
+};
+
+// Otherwise, let D be COMMON-REF(const X&, Y&). ...
+template <class _Tp, class _Up>
+using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;
+
+// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
+// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+requires requires { typename __common_ref_D<_Xp, _Yp>; } &&
+ is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
+struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp>
+{
+ using __type = __common_ref_D<_Xp, _Yp>;
+};
+
+// Otherwise, if A is an lvalue reference and B is an rvalue reference, then
+// COMMON-REF(A, B) is COMMON-REF(B, A).
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {};
+
+// Otherwise, COMMON-REF(A, B) is ill-formed.
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+struct __common_ref {};
+
+// Note C: For the common_reference trait applied to a parameter pack [...]
+
+template <class...>
+struct common_reference;
+
+template <class... _Types>
+using common_reference_t = typename common_reference<_Types...>::type;
+
+// bullet 1 - sizeof...(T) == 0
+template<>
+struct common_reference<> {};
+
+// bullet 2 - sizeof...(T) == 1
+template <class _Tp>
+struct common_reference<_Tp>
+{
+ using type = _Tp;
+};
+
+// bullet 3 - sizeof...(T) == 2
+template <class _Tp, class _Up> struct __common_reference_sub_bullet3;
+template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {};
+template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
+
+// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
+// the member typedef `type` denotes that type.
+template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
+
+template <class _Tp, class _Up>
+requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
+struct __common_reference_sub_bullet1<_Tp, _Up>
+{
+ using type = __common_ref_t<_Tp, _Up>;
+};
+
+// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
+// is well-formed, then the member typedef `type` denotes that type.
+template <class, class, template <class> class, template <class> class> struct basic_common_reference {};
+
+template <class _Tp, class _Up>
+using __basic_common_reference_t = typename basic_common_reference<
+ remove_cvref_t<_Tp>, remove_cvref_t<_Up>,
+ __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type;
+
+template <class _Tp, class _Up>
+requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
+struct __common_reference_sub_bullet2<_Tp, _Up>
+{
+ using type = __basic_common_reference_t<_Tp, _Up>;
+};
+
+// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
+// then the member typedef `type` denotes that type.
+template <class _Tp, class _Up>
+requires requires { typename __cond_res<_Tp, _Up>; }
+struct __common_reference_sub_bullet3<_Tp, _Up>
+{
+ using type = __cond_res<_Tp, _Up>;
+};
+
+
+// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
+// then the member typedef `type` denotes that type.
+// - Otherwise, there shall be no member `type`.
+template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
+
+// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if
+// any, as `common_reference_t<C, Rest...>`.
+template <class _Tp, class _Up, class _Vp, class... _Rest>
+requires requires { typename common_reference_t<_Tp, _Up>; }
+struct common_reference<_Tp, _Up, _Vp, _Rest...>
+ : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...>
+{};
+
+// bullet 5 - Otherwise, there shall be no member `type`.
+template <class...> struct common_reference {};
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H
lib/libcxx/include/__type_traits/common_type.h
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H
+#define _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+// Let COND_RES(X, Y) be:
+template <class _Tp, class _Up>
+using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
+
+template <class _Tp, class _Up, class = void>
+struct __common_type3 {};
+
+// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
+template <class _Tp, class _Up>
+struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
+{
+ using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
+};
+
+template <class _Tp, class _Up, class = void>
+struct __common_type2_imp : __common_type3<_Tp, _Up> {};
+#else
+template <class _Tp, class _Up, class = void>
+struct __common_type2_imp {};
+#endif
+
+// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
+template <class _Tp, class _Up>
+struct __common_type2_imp<_Tp, _Up,
+ typename __void_t<decltype(
+ true ? declval<_Tp>() : declval<_Up>()
+ )>::type>
+{
+ typedef _LIBCPP_NODEBUG typename decay<decltype(
+ true ? declval<_Tp>() : declval<_Up>()
+ )>::type type;
+};
+
+template <class, class = void>
+struct __common_type_impl {};
+
+// Clang provides variadic templates in C++03 as an extension.
+#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
+# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
+template <class... _Tp>
+struct __common_types;
+template <class... _Tp>
+struct _LIBCPP_TEMPLATE_VIS common_type;
+#else
+# define _LIBCPP_OPTIONAL_PACK(...)
+struct __no_arg;
+template <class _Tp, class _Up, class = __no_arg>
+struct __common_types;
+template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
+ class _Unused = __no_arg>
+struct common_type {
+ static_assert(sizeof(_Unused) == 0,
+ "common_type accepts at most 3 arguments in C++03");
+};
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Up>
+struct __common_type_impl<
+ __common_types<_Tp, _Up>,
+ typename __void_t<typename common_type<_Tp, _Up>::type>::type>
+{
+ typedef typename common_type<_Tp, _Up>::type type;
+};
+
+template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
+struct __common_type_impl<
+ __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
+ typename __void_t<typename common_type<_Tp, _Up>::type>::type>
+ : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
+ _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
+};
+
+// bullet 1 - sizeof...(Tp) == 0
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS common_type<> {};
+
+// bullet 2 - sizeof...(Tp) == 1
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
+ : public common_type<_Tp, _Tp> {};
+
+// bullet 3 - sizeof...(Tp) == 2
+
+// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
+template <class _Tp, class _Up>
+struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
+ : conditional<
+ _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
+ __common_type2_imp<_Tp, _Up>,
+ common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
+ >::type
+{};
+
+// bullet 4 - sizeof...(Tp) > 2
+
+template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
+struct _LIBCPP_TEMPLATE_VIS
+ common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
+ : __common_type_impl<
+ __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
+
+#undef _LIBCPP_OPTIONAL_PACK
+
+#if _LIBCPP_STD_VER > 11
+template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H
lib/libcxx/include/__type_traits/conditional.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_CONDITIONAL_H
+#define _LIBCPP___TYPE_TRAITS_CONDITIONAL_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <bool>
+struct _IfImpl;
+
+template <>
+struct _IfImpl<true> {
+ template <class _IfRes, class _ElseRes>
+ using _Select _LIBCPP_NODEBUG = _IfRes;
+};
+
+template <>
+struct _IfImpl<false> {
+ template <class _IfRes, class _ElseRes>
+ using _Select _LIBCPP_NODEBUG = _ElseRes;
+};
+
+template <bool _Cond, class _IfRes, class _ElseRes>
+using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
+
+template <bool _Bp, class _If, class _Then>
+ struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
+template <class _If, class _Then>
+ struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
+
+#if _LIBCPP_STD_VER > 11
+template <bool _Bp, class _IfRes, class _ElseRes>
+using conditional_t = typename conditional<_Bp, _IfRes, _ElseRes>::type;
+#endif
+
+// Helper so we can use "conditional_t" in all language versions.
+template <bool _Bp, class _If, class _Then> using __conditional_t = typename conditional<_Bp, _If, _Then>::type;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H
lib/libcxx/include/__type_traits/conjunction.h
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
+#define _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Arg, class... _Args>
+struct __conjunction_impl {
+ using type = conditional_t<!bool(_Arg::value), _Arg, typename __conjunction_impl<_Args...>::type>;
+};
+
+template <class _Arg>
+struct __conjunction_impl<_Arg> {
+ using type = _Arg;
+};
+
+template <class... _Args>
+struct conjunction : __conjunction_impl<true_type, _Args...>::type {};
+
+template<class... _Args>
+inline constexpr bool conjunction_v = conjunction<_Args...>::value;
+
+#endif // _LIBCPP_STD_VER > 14
+
+template <class...>
+using __expand_to_true = true_type;
+
+template <class... _Pred>
+__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
+
+template <class...>
+false_type __and_helper(...);
+
+template <class... _Pred>
+using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
lib/libcxx/include/__type_traits/copy_cv.h
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_COPY_CV_H
+#define _LIBCPP___TYPE_TRAITS_COPY_CV_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_cv.h>
+#include <__type_traits/add_volatile.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
+// top-level cv-qualifiers.
+template <class _From, class _To>
+struct __copy_cv
+{
+ using type = _To;
+};
+
+template <class _From, class _To>
+struct __copy_cv<const _From, _To>
+{
+ using type = typename add_const<_To>::type;
+};
+
+template <class _From, class _To>
+struct __copy_cv<volatile _From, _To>
+{
+ using type = typename add_volatile<_To>::type;
+};
+
+template <class _From, class _To>
+struct __copy_cv<const volatile _From, _To>
+{
+ using type = typename add_cv<_To>::type;
+};
+
+template <class _From, class _To>
+using __copy_cv_t = typename __copy_cv<_From, _To>::type;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_COPY_CV_H
lib/libcxx/include/__type_traits/copy_cvref.h
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_COPY_CVREF_H
+#define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H
+
+#include <__config>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/add_rvalue_reference.h>
+#include <__type_traits/copy_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _From, class _To>
+struct __copy_cvref
+{
+ using type = __copy_cv_t<_From, _To>;
+};
+
+template <class _From, class _To>
+struct __copy_cvref<_From&, _To>
+{
+ using type = typename add_lvalue_reference<__copy_cv_t<_From, _To> >::type;
+};
+
+template <class _From, class _To>
+struct __copy_cvref<_From&&, _To>
+{
+ using type = typename add_rvalue_reference<__copy_cv_t<_From, _To> >::type;
+};
+
+template <class _From, class _To>
+using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_COPY_CVREF_H
lib/libcxx/include/__type_traits/decay.h
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_DECAY_H
+#define _LIBCPP___TYPE_TRAITS_DECAY_H
+
+#include <__config>
+#include <__type_traits/add_pointer.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_referenceable.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_extent.h>
+#include <__type_traits/remove_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Up, bool>
+struct __decay {
+ typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;
+};
+
+template <class _Up>
+struct __decay<_Up, true> {
+public:
+ typedef _LIBCPP_NODEBUG typename conditional
+ <
+ is_array<_Up>::value,
+ typename remove_extent<_Up>::type*,
+ typename conditional
+ <
+ is_function<_Up>::value,
+ typename add_pointer<_Up>::type,
+ typename remove_cv<_Up>::type
+ >::type
+ >::type type;
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS decay
+{
+private:
+ typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
+public:
+ typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using decay_t = typename decay<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_DECAY_H
lib/libcxx/include/__type_traits/disjunction.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
+#define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <bool>
+struct _OrImpl;
+
+template <>
+struct _OrImpl<true> {
+ template <class _Res, class _First, class... _Rest>
+ using _Result _LIBCPP_NODEBUG =
+ typename _OrImpl<!bool(_First::value) && sizeof...(_Rest) != 0>::template _Result<_First, _Rest...>;
+};
+
+template <>
+struct _OrImpl<false> {
+ template <class _Res, class...>
+ using _Result = _Res;
+};
+
+template <class... _Args>
+using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _Result<false_type, _Args...>;
+
+#if _LIBCPP_STD_VER > 14
+
+template <class... _Args>
+struct disjunction : _Or<_Args...> {};
+
+template <class... _Args>
+inline constexpr bool disjunction_v = _Or<_Args...>::value;
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
lib/libcxx/include/__type_traits/enable_if.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_ENABLE_IF_H
+#define _LIBCPP___TYPE_TRAITS_ENABLE_IF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
+
+template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type;
+
+#if _LIBCPP_STD_VER > 11
+template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H
lib/libcxx/include/__type_traits/extent.h
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_EXTENT_H
+#define _LIBCPP___TYPE_TRAITS_EXTENT_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__array_extent)
+
+template<class _Tp, size_t _Dim = 0>
+struct _LIBCPP_TEMPLATE_VIS extent
+ : integral_constant<size_t, __array_extent(_Tp, _Dim)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, unsigned _Ip = 0>
+inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
+#endif
+
+#else // __has_builtin(__array_extent)
+
+template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
+ : public integral_constant<size_t, 0> {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
+ : public integral_constant<size_t, 0> {};
+template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
+ : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
+ : public integral_constant<size_t, _Np> {};
+template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
+ : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, unsigned _Ip = 0>
+inline constexpr size_t extent_v = extent<_Tp, _Ip>::value;
+#endif
+
+#endif // __has_builtin(__array_extent)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_EXTENT_H
lib/libcxx/include/__type_traits/has_unique_object_representation.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H
+#define _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_all_extents.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
+ : public integral_constant<bool,
+ __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
+
+template <class _Tp>
+inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value;
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H
lib/libcxx/include/__type_traits/has_virtual_destructor.h
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_HAS_VIRTUAL_DESTRUCTOR_H
+#define _LIBCPP___TYPE_TRAITS_HAS_VIRTUAL_DESTRUCTOR_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__has_virtual_destructor)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
+ : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
+ : public false_type {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_HAS_VIRTUAL_DESTRUCTOR_H
lib/libcxx/include/__type_traits/integral_constant.h
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H
+#define _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, _Tp __v>
+struct _LIBCPP_TEMPLATE_VIS integral_constant
+{
+ static _LIBCPP_CONSTEXPR const _Tp value = __v;
+ typedef _Tp value_type;
+ typedef integral_constant type;
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
+#if _LIBCPP_STD_VER > 11
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr value_type operator ()() const _NOEXCEPT {return value;}
+#endif
+};
+
+template <class _Tp, _Tp __v>
+_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
+
+typedef integral_constant<bool, true> true_type;
+typedef integral_constant<bool, false> false_type;
+
+template <bool _Val>
+using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>;
+
+#if _LIBCPP_STD_VER > 14
+template <bool __b>
+using bool_constant = integral_constant<bool, __b>;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H
lib/libcxx/include/__type_traits/is_abstract.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H
+#define _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
+ : public integral_constant<bool, __is_abstract(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_abstract_v = __is_abstract(_Tp);
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H
lib/libcxx/include/__type_traits/is_aggregate.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H
+#define _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
+is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
+
+template <class _Tp>
+inline constexpr bool is_aggregate_v = __is_aggregate(_Tp);
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H
lib/libcxx/include/__type_traits/is_arithmetic.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H
+#define _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_integral.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
+ : public integral_constant<bool, is_integral<_Tp>::value ||
+ is_floating_point<_Tp>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H
lib/libcxx/include/__type_traits/is_array.h
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
+#define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// TODO: Clang incorrectly reports that __is_array is true for T[0].
+// Re-enable the branch once https://llvm.org/PR54705 is fixed.
+#if __has_builtin(__is_array) && 0
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_array_v = __is_array(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
+ : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
+ : public true_type {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
+ : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_array_v = is_array<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_array)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
lib/libcxx/include/__type_traits/is_assignable.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
+
+#if __has_builtin(__is_assignable)
+
+template<class _Tp, class _Up>
+struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Arg>
+inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
+#endif
+
+#else // __has_builtin(__is_assignable)
+
+template <class _Tp, class _Arg>
+typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
+__is_assignable_test(int);
+
+template <class, class>
+false_type __is_assignable_test(...);
+
+
+template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
+struct __is_assignable_imp
+ : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
+
+template <class _Tp, class _Arg>
+struct __is_assignable_imp<_Tp, _Arg, true>
+ : public false_type
+{
+};
+
+template <class _Tp, class _Arg>
+struct is_assignable
+ : public __is_assignable_imp<_Tp, _Arg> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Arg>
+inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
+#endif
+
+#endif // __has_builtin(__is_assignable)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_base_of.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H
+#define _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Bp, class _Dp>
+struct _LIBCPP_TEMPLATE_VIS is_base_of
+ : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Bp, class _Dp>
+inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp);
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H
lib/libcxx/include/__type_traits/is_bounded_array.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
+#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array : false_type {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array<_Tp[_Np]> : true_type {};
+
+#if _LIBCPP_STD_VER > 17
+
+template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
+
+template <class _Tp>
+inline constexpr
+bool is_bounded_array_v = is_bounded_array<_Tp>::value;
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
lib/libcxx/include/__type_traits/is_callable.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Func, class... _Args, class = decltype(std::declval<_Func>()(std::declval<_Args>()...))>
+true_type __is_callable_helper(int);
+template<class...>
+false_type __is_callable_helper(...);
+
+template<class _Func, class... _Args>
+struct __is_callable : decltype(__is_callable_helper<_Func, _Args...>(0)) {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H
lib/libcxx/include/__type_traits/is_class.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_CLASS_H
+#define _LIBCPP___TYPE_TRAITS_IS_CLASS_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_union.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
+ : public integral_constant<bool, __is_class(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_class_v = __is_class(_Tp);
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_CLASS_H
lib/libcxx/include/__type_traits/is_compound.h
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H
+#define _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_fundamental.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_compound)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_compound_v = __is_compound(_Tp);
+#endif
+
+#else // __has_builtin(__is_compound)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
+ : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_compound_v = is_compound<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_compound)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H
lib/libcxx/include/__type_traits/is_const.h
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_CONST_H
+#define _LIBCPP___TYPE_TRAITS_IS_CONST_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_const)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_const_v = __is_const(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_const_v = is_const<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_const)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_CONST_H
lib/libcxx/include/__type_traits/is_constant_evaluated.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
+#define _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+_LIBCPP_INLINE_VISIBILITY
+inline constexpr bool is_constant_evaluated() noexcept {
+ return __builtin_is_constant_evaluated();
+}
+#endif
+
+inline _LIBCPP_CONSTEXPR
+bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
lib/libcxx/include/__type_traits/is_constructible.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class ..._Args>
+struct _LIBCPP_TEMPLATE_VIS is_constructible
+ : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
+{ };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class ..._Args>
+inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_convertible.h
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/remove_reference.h>
+#include <__utility/declval.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__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)> {};
+
+#else // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
+
+namespace __is_convertible_imp
+{
+template <class _Tp> void __test_convert(_Tp);
+
+template <class _From, class _To, class = void>
+struct __is_convertible_test : public false_type {};
+
+template <class _From, class _To>
+struct __is_convertible_test<_From, _To,
+ decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
+{};
+
+template <class _Tp, bool _IsArray = is_array<_Tp>::value,
+ bool _IsFunction = is_function<_Tp>::value,
+ bool _IsVoid = is_void<_Tp>::value>
+ struct __is_array_function_or_void {enum {value = 0};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
+}
+
+template <class _Tp,
+ unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
+struct __is_convertible_check
+{
+ static const size_t __v = 0;
+};
+
+template <class _Tp>
+struct __is_convertible_check<_Tp, 0>
+{
+ static const size_t __v = sizeof(_Tp);
+};
+
+template <class _T1, class _T2,
+ unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
+ unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
+struct __is_convertible
+ : public integral_constant<bool,
+ __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
+ >
+{};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
+
+template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
+ : public __is_convertible<_T1, _T2>
+{
+ static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
+ static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
+};
+
+#endif // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
+
+#if _LIBCPP_STD_VER > 14
+template <class _From, class _To>
+inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
lib/libcxx/include/__type_traits/is_copy_assignable.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_assignable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
+ : public is_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_copy_constructible.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
+ : public is_constructible<_Tp,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_core_convertible.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_CORE_CONVERTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_CORE_CONVERTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed.
+// We can't test for that, but we can test implicit convertibility by passing it
+// to a function. Notice that __is_core_convertible<void,void> is false,
+// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
+
+template <class _Tp, class _Up, class = void>
+struct __is_core_convertible : public false_type {};
+
+template <class _Tp, class _Up>
+struct __is_core_convertible<_Tp, _Up, decltype(
+ static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
+)> : public true_type {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_CORE_CONVERTIBLE_H
lib/libcxx/include/__type_traits/is_default_constructible.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_default_constructible
+ : public is_constructible<_Tp>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_destructible.h
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_DESTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_DESTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_all_extents.h>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_destructible)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_destructible_v = __is_destructible(_Tp);
+#endif
+
+#else // __has_builtin(__is_destructible)
+
+// if it's a reference, return true
+// if it's a function, return false
+// if it's void, return false
+// if it's an array of unknown bound, return false
+// Otherwise, return "declval<_Up&>().~_Up()" is well-formed
+// where _Up is remove_all_extents<_Tp>::type
+
+template <class>
+struct __is_destructible_apply { typedef int type; };
+
+template <typename _Tp>
+struct __is_destructor_wellformed {
+ template <typename _Tp1>
+ static true_type __test (
+ typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
+ );
+
+ template <typename _Tp1>
+ static false_type __test (...);
+
+ static const bool value = decltype(__test<_Tp>(12))::value;
+};
+
+template <class _Tp, bool>
+struct __destructible_imp;
+
+template <class _Tp>
+struct __destructible_imp<_Tp, false>
+ : public integral_constant<bool,
+ __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
+
+template <class _Tp>
+struct __destructible_imp<_Tp, true>
+ : public true_type {};
+
+template <class _Tp, bool>
+struct __destructible_false;
+
+template <class _Tp>
+struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};
+
+template <class _Tp>
+struct __destructible_false<_Tp, true> : public false_type {};
+
+template <class _Tp>
+struct is_destructible
+ : public __destructible_false<_Tp, is_function<_Tp>::value> {};
+
+template <class _Tp>
+struct is_destructible<_Tp[]>
+ : public false_type {};
+
+template <>
+struct is_destructible<void>
+ : public false_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_destructible)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_DESTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_empty.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_EMPTY_H
+#define _LIBCPP___TYPE_TRAITS_IS_EMPTY_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_empty
+ : public integral_constant<bool, __is_empty(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_empty_v = __is_empty(_Tp);
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_EMPTY_H
lib/libcxx/include/__type_traits/is_enum.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_ENUM_H
+#define _LIBCPP___TYPE_TRAITS_IS_ENUM_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
+ : public integral_constant<bool, __is_enum(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_enum_v = __is_enum(_Tp);
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_ENUM_H
lib/libcxx/include/__type_traits/is_final.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_FINAL_H
+#define _LIBCPP___TYPE_TRAITS_IS_FINAL_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
+__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
+is_final : public integral_constant<bool, __is_final(_Tp)> {};
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_final_v = __is_final(_Tp);
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_FINAL_H
lib/libcxx/include/__type_traits/is_floating_point.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H
+#define _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
+template <> struct __libcpp_is_floating_point<float> : public true_type {};
+template <> struct __libcpp_is_floating_point<double> : public true_type {};
+template <> struct __libcpp_is_floating_point<long double> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
+ : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H
lib/libcxx/include/__type_traits/is_function.h
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H
+#define _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_function)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {};
+
+#else
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_function
+ : public integral_constant<bool, !(is_reference<_Tp>::value || is_const<const _Tp>::value)> {};
+
+#endif // __has_builtin(__is_function)
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_function_v = is_function<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H
lib/libcxx/include/__type_traits/is_fundamental.h
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H
+#define _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_null_pointer.h>
+#include <__type_traits/is_void.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_fundamental)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
+#endif
+
+#else // __has_builtin(__is_fundamental)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
+ : public integral_constant<bool, is_void<_Tp>::value ||
+ __is_nullptr_t<_Tp>::value ||
+ is_arithmetic<_Tp>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_fundamental)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H
lib/libcxx/include/__type_traits/is_integral.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H
+#define _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
+template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
+#endif
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
+#endif
+template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<short> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<int> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<long> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };
+template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
+#endif
+
+#if __has_builtin(__is_integral)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_integral_v = __is_integral(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
+ : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_integral_v = is_integral<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_integral)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H
lib/libcxx/include/__type_traits/is_literal_type.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE
+#define _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type
+ : public integral_constant<bool, __is_literal_type(_Tp)>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
+#endif // _LIBCPP_STD_VER > 14
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE
lib/libcxx/include/__type_traits/is_member_function_pointer.h
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
+#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/remove_cv.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct __libcpp_is_member_pointer {
+ enum {
+ __is_member = false,
+ __is_func = false,
+ __is_obj = false
+ };
+};
+template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
+ enum {
+ __is_member = true,
+ __is_func = is_function<_Tp>::value,
+ __is_obj = !__is_func,
+ };
+};
+
+#if __has_builtin(__is_member_function_pointer)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
+ : _BoolConstant<__is_member_function_pointer(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
+#endif
+
+#else // __has_builtin(__is_member_function_pointer)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
+ : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_member_function_pointer)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
lib/libcxx/include/__type_traits/is_member_object_pointer.h
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H
+#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_member_object_pointer)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
+ : _BoolConstant<__is_member_object_pointer(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
+#endif
+
+#else // __has_builtin(__is_member_object_pointer)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
+ : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_member_object_pointer)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
lib/libcxx/include/__type_traits/is_member_pointer.h
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H
+#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_member_pointer)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
+#endif
+
+#else // __has_builtin(__is_member_pointer)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
+ : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_member_pointer)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H
lib/libcxx/include/__type_traits/is_move_assignable.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/add_rvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_assignable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
+ : public is_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_rvalue_reference<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_move_constructible.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/add_rvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_move_constructible
+ : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_assignable.h
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_nothrow_assignable)
+
+template <class _Tp, class _Arg>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
+ : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
+
+#else
+
+template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
+ : public false_type
+{
+};
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
+ : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
+{
+};
+
+template <class _Tp, class _Arg>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
+ : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
+{
+};
+
+#endif // __has_builtin(__is_nothrow_assignable)
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Arg>
+inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_constructible.h
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_nothrow_constructible)
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
+ : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
+
+#else
+
+template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
+
+template <class _Tp, class... _Args>
+struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
+ : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
+{
+};
+
+template <class _Tp>
+void __implicit_conversion_to(_Tp) noexcept { }
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
+ : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
+{
+};
+
+template <class _Tp, bool _IsReference, class... _Args>
+struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
+ : public false_type
+{
+};
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
+ : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
+{
+};
+
+template <class _Tp, size_t _Ns>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
+ : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
+{
+};
+
+#endif // __has_builtin(__is_nothrow_constructible)
+
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class ..._Args>
+inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_convertible.h
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
+
+#include <__config>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/disjunction.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/lazy.h>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <typename _Tp>
+static void __test_noexcept(_Tp) noexcept;
+
+template<typename _Fm, typename _To>
+static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
+__is_nothrow_convertible_test();
+
+template <typename _Fm, typename _To>
+struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
+{ };
+
+template <typename _Fm, typename _To>
+struct is_nothrow_convertible : _Or<
+ _And<is_void<_To>, is_void<_Fm>>,
+ _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
+>::type { };
+
+template <typename _Fm, typename _To>
+inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_copy_assignable.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_nothrow_assignable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
+ : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_copy_constructible.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_nothrow_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
+ : public is_nothrow_constructible<_Tp,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_default_constructible.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_nothrow_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
+ : public is_nothrow_constructible<_Tp>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_destructible.h
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_destructible.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_scalar.h>
+#include <__type_traits/remove_all_extents.h>
+#include <__utility/declval.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
+
+template <class _Tp>
+struct __libcpp_is_nothrow_destructible<false, _Tp>
+ : public false_type
+{
+};
+
+template <class _Tp>
+struct __libcpp_is_nothrow_destructible<true, _Tp>
+ : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
+ : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
+{
+};
+
+template <class _Tp, size_t _Ns>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
+ : public is_nothrow_destructible<_Tp>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
+ : public true_type
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
+ : public true_type
+{
+};
+
+#else
+
+template <class _Tp> struct __libcpp_nothrow_destructor
+ : public integral_constant<bool, is_scalar<_Tp>::value ||
+ is_reference<_Tp>::value> {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
+ : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
+ : public false_type {};
+
+#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_move_assignable.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/add_rvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_nothrow_assignable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
+ : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_move_constructible.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/add_rvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_nothrow_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
+ : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_null_pointer.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H
+#define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cv.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
+template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
+ : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
+ : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
+#endif
+#endif // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H
lib/libcxx/include/__type_traits/is_object.h
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_OBJECT_H
+#define _LIBCPP___TYPE_TRAITS_IS_OBJECT_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_class.h>
+#include <__type_traits/is_scalar.h>
+#include <__type_traits/is_union.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_object)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_object_v = __is_object(_Tp);
+#endif
+
+#else // __has_builtin(__is_object)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
+ : public integral_constant<bool, is_scalar<_Tp>::value ||
+ is_array<_Tp>::value ||
+ is_union<_Tp>::value ||
+ is_class<_Tp>::value > {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_object_v = is_object<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_object)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_OBJECT_H
lib/libcxx/include/__type_traits/is_pod.h
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_POD_H
+#define _LIBCPP___TYPE_TRAITS_IS_POD_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_pod)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
+ : public integral_constant<bool, __is_pod(_Tp)> {};
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
+ : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
+ is_trivially_copy_constructible<_Tp>::value &&
+ is_trivially_copy_assignable<_Tp>::value &&
+ is_trivially_destructible<_Tp>::value> {};
+
+#endif // __has_builtin(__is_pod)
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_pod_v = is_pod<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_POD_H
lib/libcxx/include/__type_traits/is_pointer.h
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_POINTER_H
+#define _LIBCPP___TYPE_TRAITS_IS_POINTER_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_pointer)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_pointer_v = __is_pointer(_Tp);
+#endif
+
+#else // __has_builtin(__is_pointer)
+
+template <class _Tp> struct __libcpp_is_pointer : public false_type {};
+template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
+
+template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
+#if defined(_LIBCPP_HAS_OBJC_ARC)
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
+template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
+#endif
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
+ : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_pointer)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H
lib/libcxx/include/__type_traits/is_polymorphic.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_H
+#define _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_polymorphic
+ : public integral_constant<bool, __is_polymorphic(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp);
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_H
lib/libcxx/include/__type_traits/is_primary_template.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
+#define _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
+
+#include <__config>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_valid_expansion.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+using __test_for_primary_template = __enable_if_t<
+ _IsSame<_Tp, typename _Tp::__primary_template>::value
+ >;
+template <class _Tp>
+using __is_primary_template = _IsValidExpansion<
+ __test_for_primary_template, _Tp
+ >;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
lib/libcxx/include/__type_traits/is_reference.h
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H
+#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_lvalue_reference) && \
+ __has_builtin(__is_rvalue_reference) && \
+ __has_builtin(__is_reference)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { };
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_reference_v = __is_reference(_Tp);
+template <class _Tp>
+inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
+template <class _Tp>
+inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
+#endif
+
+#else // __has_builtin(__is_lvalue_reference) && etc...
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_reference_v = is_reference<_Tp>::value;
+
+template <class _Tp>
+inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
+
+template <class _Tp>
+inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_lvalue_reference) && etc...
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H
lib/libcxx/include/__type_traits/is_reference_wrapper.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H
+#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
+
+template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
+template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
+template <class _Tp> struct __is_reference_wrapper
+ : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H
lib/libcxx/include/__type_traits/is_referenceable.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_same.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct __is_referenceable_impl {
+ template <class _Tp> static _Tp& __test(int);
+ template <class _Tp> static false_type __test(...);
+};
+
+template <class _Tp>
+struct __is_referenceable : integral_constant<bool,
+ _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
lib/libcxx/include/__type_traits/is_same.h
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_SAME_H
+#define _LIBCPP___TYPE_TRAITS_IS_SAME_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Up>
+struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Up>
+inline constexpr bool is_same_v = __is_same(_Tp, _Up);
+#endif
+
+// _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:
+// is_same<A,B> and is_same<C,D> are guaranteed to be different types, but
+// _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type).
+// Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame
+// mustn't be directly used anywhere that contributes to name-mangling
+// (such as in a dependent return type).
+
+template <class _Tp, class _Up>
+using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;
+
+template <class _Tp, class _Up>
+using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_SAME_H
lib/libcxx/include/__type_traits/is_scalar.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_SCALAR_H
+#define _LIBCPP___TYPE_TRAITS_IS_SCALAR_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_member_pointer.h>
+#include <__type_traits/is_pointer.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_scalar)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_scalar_v = __is_scalar(_Tp);
+#endif
+
+#else // __has_builtin(__is_scalar)
+
+template <class _Tp> struct __is_block : false_type {};
+#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
+template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
+#endif
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
+ : public integral_constant<bool, is_arithmetic<_Tp>::value ||
+ is_member_pointer<_Tp>::value ||
+ is_pointer<_Tp>::value ||
+ __is_nullptr_t<_Tp>::value ||
+ __is_block<_Tp>::value ||
+ is_enum<_Tp>::value > {};
+
+template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_scalar)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_SCALAR_H
lib/libcxx/include/__type_traits/is_scoped_enum.h
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
+#define _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/underlying_type.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+template <class _Tp, bool = is_enum_v<_Tp> >
+struct __is_scoped_enum_helper : false_type {};
+
+template <class _Tp>
+struct __is_scoped_enum_helper<_Tp, true>
+ : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
+ : public __is_scoped_enum_helper<_Tp> {};
+
+template <class _Tp>
+inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
lib/libcxx/include/__type_traits/is_signed.h
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_SIGNED_H
+#define _LIBCPP___TYPE_TRAITS_IS_SIGNED_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_signed)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_signed_v = __is_signed(_Tp);
+#endif
+
+#else // __has_builtin(__is_signed)
+
+template <class _Tp, bool = is_integral<_Tp>::value>
+struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {};
+
+template <class _Tp>
+struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
+
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
+struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
+
+template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_signed_v = is_signed<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_signed)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_H
lib/libcxx/include/__type_traits/is_signed_integer.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H
+#define _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
+template <> struct __libcpp_is_signed_integer<signed char> : public true_type {};
+template <> struct __libcpp_is_signed_integer<signed short> : public true_type {};
+template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
+template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
+template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H
lib/libcxx/include/__type_traits/is_standard_layout.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_STANDARD_LAYOUT_H
+#define _LIBCPP___TYPE_TRAITS_IS_STANDARD_LAYOUT_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
+#if __has_builtin(__is_standard_layout)
+ : public integral_constant<bool, __is_standard_layout(_Tp)>
+#else
+ : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
+#endif
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_STANDARD_LAYOUT_H
lib/libcxx/include/__type_traits/is_trivial.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIAL_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIAL_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
+#if __has_builtin(__is_trivial)
+ : public integral_constant<bool, __is_trivial(_Tp)>
+#else
+ : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
+ is_trivially_default_constructible<_Tp>::value>
+#endif
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIAL_H
lib/libcxx/include/__type_traits/is_trivially_assignable.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Arg>
+struct is_trivially_assignable
+ : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
+{ };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Arg>
+inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_constructible.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
+ : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
+{
+};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class... _Args>
+inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_copy_assignable.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_trivially_assignable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
+ : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_copy_constructible.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_trivially_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
+ : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_copyable.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
+ : public integral_constant<bool, __is_trivially_copyable(_Tp)>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
lib/libcxx/include/__type_traits/is_trivially_default_constructible.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_trivially_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
+ : public is_trivially_constructible<_Tp>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_destructible.h
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_trivially_destructible)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
+ : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
+
+#elif __has_builtin(__has_trivial_destructor)
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
+ : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
+
+#else
+
+template <class _Tp> struct __libcpp_trivial_destructor
+ : public integral_constant<bool, is_scalar<_Tp>::value ||
+ is_reference<_Tp>::value> {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
+ : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
+ : public false_type {};
+
+#endif // __has_builtin(__is_trivially_destructible)
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_move_assignable.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H
+
+#include <__config>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/add_rvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_trivially_assignable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
+ : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
+ typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_move_constructible.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/add_rvalue_reference.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_trivially_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
+ : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+ {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_unbounded_array.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
+#define _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array : false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array<_Tp[]> : true_type {};
+
+#if _LIBCPP_STD_VER > 17
+
+template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
+
+template <class _Tp>
+inline constexpr
+bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
lib/libcxx/include/__type_traits/is_union.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_UNION_H
+#define _LIBCPP___TYPE_TRAITS_IS_UNION_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
+ : public integral_constant<bool, __is_union(_Tp)> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_union_v = __is_union(_Tp);
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_UNION_H
lib/libcxx/include/__type_traits/is_unsigned.h
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H
+#define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_integral.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Before AppleClang 14, __is_unsigned returned true for enums with signed underlying type.
+#if __has_builtin(__is_unsigned) && !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1400)
+
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
+#endif
+
+#else // __has_builtin(__is_unsigned)
+
+template <class _Tp, bool = is_integral<_Tp>::value>
+struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {};
+
+template <class _Tp>
+struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
+
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
+struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
+
+template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_unsigned)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H
lib/libcxx/include/__type_traits/is_unsigned_integer.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H
+#define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H
lib/libcxx/include/__type_traits/is_valid_expansion.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H
+#define _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
+true_type __sfinae_test_impl(int);
+template <template <class...> class, class ...>
+false_type __sfinae_test_impl(...);
+
+template <template <class ...> class _Templ, class ..._Args>
+using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H
lib/libcxx/include/__type_traits/is_void.h
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_VOID_H
+#define _LIBCPP___TYPE_TRAITS_IS_VOID_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_void)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_void_v = __is_void(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
+ : public is_same<typename remove_cv<_Tp>::type, void> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_void_v = is_void<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_void)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_VOID_H
lib/libcxx/include/__type_traits/is_volatile.h
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_VOLATILE_H
+#define _LIBCPP___TYPE_TRAITS_IS_VOLATILE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if __has_builtin(__is_volatile)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_volatile_v = __is_volatile(_Tp);
+#endif
+
+#else
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
+#endif
+
+#endif // __has_builtin(__is_volatile)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_VOLATILE_H
lib/libcxx/include/__type_traits/lazy.h
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_LAZY_H
+#define _LIBCPP___TYPE_TRAITS_LAZY_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <template <class...> class _Func, class ..._Args>
+struct _Lazy : _Func<_Args...> {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_LAZY_H
lib/libcxx/include/__type_traits/make_32_64_or_128_bit.h
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H
+#define _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_signed.h>
+#include <__type_traits/is_unsigned.h>
+#include <__type_traits/make_unsigned.h>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+/// Helper to promote an integral to smallest 32, 64, or 128 bit representation.
+///
+/// The restriction is the same as the integral version of to_char.
+template <class _Tp>
+#if _LIBCPP_STD_VER > 17
+ requires (is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>)
+#endif
+using __make_32_64_or_128_bit_t =
+ __copy_unsigned_t<_Tp,
+ __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t,
+ __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t,
+#ifndef _LIBCPP_HAS_NO_INT128
+ __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t,
+ /* else */ void>
+#else
+ /* else */ void
+#endif
+ > >
+ >;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H
lib/libcxx/include/__type_traits/make_signed.h
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H
+#define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H
+
+#include <__config>
+#include <__type_traits/apply_cv.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/nat.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/type_list.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+typedef
+ __type_list<signed char,
+ __type_list<signed short,
+ __type_list<signed int,
+ __type_list<signed long,
+ __type_list<signed long long,
+#ifndef _LIBCPP_HAS_NO_INT128
+ __type_list<__int128_t,
+#endif
+ __nat
+#ifndef _LIBCPP_HAS_NO_INT128
+ >
+#endif
+ > > > > > __signed_types;
+
+template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
+struct __make_signed {};
+
+template <class _Tp>
+struct __make_signed<_Tp, true>
+{
+ typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
+};
+
+template <> struct __make_signed<bool, true> {};
+template <> struct __make_signed< signed short, true> {typedef short type;};
+template <> struct __make_signed<unsigned short, true> {typedef short type;};
+template <> struct __make_signed< signed int, true> {typedef int type;};
+template <> struct __make_signed<unsigned int, true> {typedef int type;};
+template <> struct __make_signed< signed long, true> {typedef long type;};
+template <> struct __make_signed<unsigned long, true> {typedef long type;};
+template <> struct __make_signed< signed long long, true> {typedef long long type;};
+template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
+template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
+#endif
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS make_signed
+{
+ typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H
lib/libcxx/include/__type_traits/make_unsigned.h
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H
+#define _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H
+
+#include <__config>
+#include <__type_traits/apply_cv.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_unsigned.h>
+#include <__type_traits/nat.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/type_list.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+typedef
+ __type_list<unsigned char,
+ __type_list<unsigned short,
+ __type_list<unsigned int,
+ __type_list<unsigned long,
+ __type_list<unsigned long long,
+#ifndef _LIBCPP_HAS_NO_INT128
+ __type_list<__uint128_t,
+#endif
+ __nat
+#ifndef _LIBCPP_HAS_NO_INT128
+ >
+#endif
+ > > > > > __unsigned_types;
+
+template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
+struct __make_unsigned {};
+
+template <class _Tp>
+struct __make_unsigned<_Tp, true>
+{
+ typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
+};
+
+template <> struct __make_unsigned<bool, true> {};
+template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
+template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
+template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
+template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
+template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
+template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
+template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
+template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
+template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
+#endif
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS make_unsigned
+{
+ typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr
+typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
+ return static_cast<typename make_unsigned<_Tp>::type>(__x);
+}
+#endif
+
+template <class _Tp, class _Up>
+using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, typename make_unsigned<_Up>::type, _Up>;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H
lib/libcxx/include/__type_traits/nat.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_NAT_H
+#define _LIBCPP___TYPE_TRAITS_NAT_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct __nat
+{
+#ifndef _LIBCPP_CXX03_LANG
+ __nat() = delete;
+ __nat(const __nat&) = delete;
+ __nat& operator=(const __nat&) = delete;
+ ~__nat() = delete;
+#endif
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_NAT_H
lib/libcxx/include/__type_traits/negation.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_NEGATION_H
+#define _LIBCPP___TYPE_TRAITS_NEGATION_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Pred>
+struct _Not : _BoolConstant<!_Pred::value> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+struct negation : _Not<_Tp> {};
+template<class _Tp>
+inline constexpr bool negation_v = negation<_Tp>::value;
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_NEGATION_H
lib/libcxx/include/__type_traits/promote.h
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_PROMOTE_H
+#define _LIBCPP___TYPE_TRAITS_PROMOTE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_same.h>
+#include <__utility/declval.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __numeric_type
+{
+ static void __test(...);
+ static float __test(float);
+ static double __test(char);
+ static double __test(int);
+ static double __test(unsigned);
+ static double __test(long);
+ static double __test(unsigned long);
+ static double __test(long long);
+ static double __test(unsigned long long);
+ static double __test(double);
+ static long double __test(long double);
+
+ typedef decltype(__test(declval<_Tp>())) type;
+ static const bool value = _IsNotSame<type, void>::value;
+};
+
+template <>
+struct __numeric_type<void>
+{
+ static const bool value = true;
+};
+
+template <class _A1, class _A2 = void, class _A3 = void,
+ bool = __numeric_type<_A1>::value &&
+ __numeric_type<_A2>::value &&
+ __numeric_type<_A3>::value>
+class __promote_imp
+{
+public:
+ static const bool value = false;
+};
+
+template <class _A1, class _A2, class _A3>
+class __promote_imp<_A1, _A2, _A3, true>
+{
+private:
+ typedef typename __promote_imp<_A1>::type __type1;
+ typedef typename __promote_imp<_A2>::type __type2;
+ typedef typename __promote_imp<_A3>::type __type3;
+public:
+ typedef decltype(__type1() + __type2() + __type3()) type;
+ static const bool value = true;
+};
+
+template <class _A1, class _A2>
+class __promote_imp<_A1, _A2, void, true>
+{
+private:
+ typedef typename __promote_imp<_A1>::type __type1;
+ typedef typename __promote_imp<_A2>::type __type2;
+public:
+ typedef decltype(__type1() + __type2()) type;
+ static const bool value = true;
+};
+
+template <class _A1>
+class __promote_imp<_A1, void, void, true>
+{
+public:
+ typedef typename __numeric_type<_A1>::type type;
+ static const bool value = true;
+};
+
+template <class _A1, class _A2 = void, class _A3 = void>
+class __promote : public __promote_imp<_A1, _A2, _A3> {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H
lib/libcxx/include/__type_traits/rank.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_RANK_H
+#define _LIBCPP___TYPE_TRAITS_RANK_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
+ : public integral_constant<size_t, 0> {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
+ : public integral_constant<size_t, rank<_Tp>::value + 1> {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
+ : public integral_constant<size_t, rank<_Tp>::value + 1> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+inline constexpr size_t rank_v = rank<_Tp>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_RANK_H
lib/libcxx/include/__type_traits/remove_all_extents.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
+ {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
+ {typedef typename remove_all_extents<_Tp>::type type;};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
+ {typedef typename remove_all_extents<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
lib/libcxx/include/__type_traits/remove_const.h
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H
lib/libcxx/include/__type_traits/remove_cv.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CV_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H
+
+#include <__config>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_volatile.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
+{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CV_H
lib/libcxx/include/__type_traits/remove_cvref.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H
+
+#include <__config>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type;
+
+template <class _Tp, class _Up>
+struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {};
+
+#if _LIBCPP_STD_VER > 17
+// remove_cvref - same as __uncvref
+template <class _Tp>
+struct remove_cvref {
+ using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;
+};
+
+template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H
lib/libcxx/include/__type_traits/remove_extent.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
+ {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
+ {typedef _Tp type;};
+template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
+ {typedef _Tp type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
lib/libcxx/include/__type_traits/remove_pointer.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H
lib/libcxx/include/__type_traits/remove_reference.h
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
lib/libcxx/include/__type_traits/remove_volatile.h
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H
lib/libcxx/include/__type_traits/type_identity.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H
+#define _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __type_identity { typedef _Tp type; };
+
+template <class _Tp>
+using __type_identity_t _LIBCPP_NODEBUG = typename __type_identity<_Tp>::type;
+
+#if _LIBCPP_STD_VER > 17
+template<class _Tp> struct type_identity { typedef _Tp type; };
+template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H
lib/libcxx/include/__type_traits/type_list.h
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
+#define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Hp, class _Tp>
+struct __type_list
+{
+ typedef _Hp _Head;
+ typedef _Tp _Tail;
+};
+
+template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
+
+template <class _Hp, class _Tp, size_t _Size>
+struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
+{
+ typedef _LIBCPP_NODEBUG _Hp type;
+};
+
+template <class _Hp, class _Tp, size_t _Size>
+struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
+{
+ typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
lib/libcxx/include/__type_traits/underlying_type.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_UNDERLYING_TYPE_H
+#define _LIBCPP___TYPE_TRAITS_UNDERLYING_TYPE_H
+
+#include <__config>
+#include <__type_traits/is_enum.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
+
+template <class _Tp>
+struct __underlying_type_impl<_Tp, false> {};
+
+template <class _Tp>
+struct __underlying_type_impl<_Tp, true>
+{
+ typedef __underlying_type(_Tp) type;
+};
+
+template <class _Tp>
+struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_UNDERLYING_TYPE_H
lib/libcxx/include/__type_traits/void_t.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_VOID_T_H
+#define _LIBCPP___TYPE_TRAITS_VOID_T_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+template <class...> using void_t = void;
+#endif
+
+template <class>
+struct __void_t { typedef void type; };
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_VOID_T_H
lib/libcxx/include/__utility/as_const.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/auto_cast.h
@@ -14,7 +14,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#define _LIBCPP_AUTO_CAST(expr) static_cast<typename decay<decltype((expr))>::type>(expr)
lib/libcxx/include/__utility/cmp.h
@@ -16,7 +16,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -24,19 +24,16 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template<class _Tp, class... _Up>
struct _IsSameAsAny : _Or<_IsSame<_Tp, _Up>...> {};
template<class _Tp>
concept __is_safe_integral_cmp = is_integral_v<_Tp> &&
- !_IsSameAsAny<_Tp, bool, char
+ !_IsSameAsAny<_Tp, bool, char, char16_t, char32_t
#ifndef _LIBCPP_HAS_NO_CHAR8_T
, char8_t
#endif
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
- , char16_t, char32_t
-#endif
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
, wchar_t
#endif
@@ -101,7 +98,7 @@ bool in_range(_Up __u) noexcept
return _VSTD::cmp_less_equal(__u, numeric_limits<_Tp>::max()) &&
_VSTD::cmp_greater_equal(__u, numeric_limits<_Tp>::min());
}
-#endif
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/declval.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/exchange.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/forward.h
@@ -11,10 +11,11 @@
#define _LIBCPP___UTILITY_FORWARD_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_reference.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/in_place.h
@@ -13,7 +13,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/integer_sequence.h
@@ -13,7 +13,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/move.h
@@ -14,7 +14,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -26,15 +26,10 @@ move(_Tp&& __t) _NOEXCEPT {
return static_cast<_Up&&>(__t);
}
-#ifndef _LIBCPP_CXX03_LANG
template <class _Tp>
using __move_if_noexcept_result_t =
typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,
_Tp&&>::type;
-#else // _LIBCPP_CXX03_LANG
-template <class _Tp>
-using __move_if_noexcept_result_t = const _Tp&;
-#endif
template <class _Tp>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>
lib/libcxx/include/__utility/pair.h
@@ -21,7 +21,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -315,7 +315,7 @@ private:
#endif
};
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER > 14
template<class _T1, class _T2>
pair(_T1, _T2) -> pair<_T1, _T2>;
#endif
@@ -330,7 +330,7 @@ operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
return __x.first == __y.first && __x.second == __y.second;
}
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <class _T1, class _T2>
_LIBCPP_HIDE_FROM_ABI constexpr
@@ -345,7 +345,7 @@ operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
return _VSTD::__synth_three_way(__x.second, __y.second);
}
-#else // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#else // _LIBCPP_STD_VER > 17
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -387,7 +387,23 @@ operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
return !(__y < __x);
}
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
+
+#if _LIBCPP_STD_VER > 20
+template <class _T1, class _T2, class _U1, class _U2, template<class> class _TQual, template<class> class _UQual>
+ requires requires { typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
+ common_reference_t<_TQual<_T2>, _UQual<_U2>>>; }
+struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> {
+ using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
+ common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
+};
+
+template <class _T1, class _T2, class _U1, class _U2>
+ requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }
+struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
+ using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>;
+};
+#endif // _LIBCPP_STD_VER > 20
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
lib/libcxx/include/__utility/piecewise_construct.h
@@ -12,7 +12,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/priority_tag.h
@@ -13,7 +13,7 @@
#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/rel_ops.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/swap.h
@@ -16,7 +16,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/to_underlying.h
@@ -14,7 +14,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__utility/transaction.h
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -86,6 +86,11 @@ private:
bool __completed_;
};
+template <class _Rollback>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __transaction<_Rollback> __make_transaction(_Rollback __rollback) {
+ return __transaction<_Rollback>(std::move(__rollback));
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___UTILITY_TRANSACTION_H
lib/libcxx/include/__utility/unreachable.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_UNREACHABLE_H
+#define _LIBCPP___UTILITY_UNREACHABLE_H
+
+#include <__config>
+#include <cstdlib>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable()
+{
+#if __has_builtin(__builtin_unreachable)
+ __builtin_unreachable();
+#else
+ std::abort();
+#endif
+}
+
+#if _LIBCPP_STD_VER > 20
+
+[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }
+
+#endif // _LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif
lib/libcxx/include/__variant/monostate.h
@@ -15,7 +15,7 @@
#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/experimental/__config
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
@@ -32,19 +32,6 @@
#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }
#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr
-#if defined(_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM)
-# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM /* nothing */
-#else
-# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM __attribute__((deprecated("std::experimental::filesystem has now been deprecated in favor of C++17's std::filesystem. Please stop using it and start using std::filesystem. This experimental version will be removed in LLVM 11. You can remove this warning by defining the _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM macro.")))
-#endif
-
-#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
- _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM { \
- inline namespace v1 {
-
-#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
- } } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
-
#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
#define _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
#endif
lib/libcxx/include/experimental/__memory
@@ -10,7 +10,6 @@
#ifndef _LIBCPP_EXPERIMENTAL___MEMORY
#define _LIBCPP_EXPERIMENTAL___MEMORY
-#include <__functional_base>
#include <__memory/allocator_arg_t.h>
#include <__memory/uses_allocator.h>
#include <experimental/__config>
@@ -18,7 +17,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS
lib/libcxx/include/experimental/algorithm
@@ -31,13 +31,14 @@ ForwardIterator search(ForwardIterator first, ForwardIterator last,
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__debug>
#include <algorithm>
#include <experimental/__config>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS
lib/libcxx/include/experimental/coroutine
@@ -45,24 +45,17 @@ template <class P> struct hash<coroutine_handle<P>>;
*/
-#include <__debug>
+#include <__assert> // all public C++ headers provide the assertion handler
+#include <__functional/hash.h>
+#include <__functional/operations.h>
#include <cstddef>
#include <experimental/__config>
-#include <functional>
#include <memory> // for hash<T*>
#include <new>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-#ifdef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
-# if defined(_LIBCPP_WARNING)
- _LIBCPP_WARNING("<experimental/coroutine> cannot be used with this compiler")
-# else
-# warning <experimental/coroutine> cannot be used with this compiler
-# endif
+# pragma GCC system_header
#endif
#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
lib/libcxx/include/experimental/deque
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_DEQUE
#define _LIBCPP_EXPERIMENTAL_DEQUE
+
/*
experimental/deque synopsis
@@ -28,12 +29,13 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <deque>
#include <experimental/__config>
#include <experimental/memory_resource>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/filesystem
@@ -1,256 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_FILESYSTEM
-#define _LIBCPP_EXPERIMENTAL_FILESYSTEM
-/*
- filesystem synopsis
-
- namespace std { namespace experimental { namespace filesystem { inline namespace v1 {
-
- class path;
-
- void swap(path& lhs, path& rhs) noexcept;
- size_t hash_value(const path& p) noexcept;
-
- bool operator==(const path& lhs, const path& rhs) noexcept;
- bool operator!=(const path& lhs, const path& rhs) noexcept;
- bool operator< (const path& lhs, const path& rhs) noexcept;
- bool operator<=(const path& lhs, const path& rhs) noexcept;
- bool operator> (const path& lhs, const path& rhs) noexcept;
- bool operator>=(const path& lhs, const path& rhs) noexcept;
-
- path operator/ (const path& lhs, const path& rhs);
-
- // fs.path.io operators are friends of path.
- template <class charT, class traits>
- friend basic_ostream<charT, traits>&
- operator<<(basic_ostream<charT, traits>& os, const path& p);
-
- template <class charT, class traits>
- friend basic_istream<charT, traits>&
- operator>>(basic_istream<charT, traits>& is, path& p);
-
- template <class Source>
- path u8path(const Source& source);
- template <class InputIterator>
- path u8path(InputIterator first, InputIterator last);
-
- class filesystem_error;
- class directory_entry;
-
- class directory_iterator;
-
- // enable directory_iterator range-based for statements
- directory_iterator begin(directory_iterator iter) noexcept;
- directory_iterator end(const directory_iterator&) noexcept;
-
- class recursive_directory_iterator;
-
- // enable recursive_directory_iterator range-based for statements
- recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept;
- recursive_directory_iterator end(const recursive_directory_iterator&) noexcept;
-
- class file_status;
-
- struct space_info
- {
- uintmax_t capacity;
- uintmax_t free;
- uintmax_t available;
- };
-
- enum class file_type;
- enum class perms;
- enum class perm_options;
- enum class copy_options;
- enum class directory_options;
-
- typedef chrono::time_point<trivial-clock> file_time_type;
-
- // operational functions
-
- path absolute(const path& p);
- path absolute(const path& p, error_code &ec);
-
- path canonical(const path& p);
- path canonical(const path& p, error_code& ec);
-
- void copy(const path& from, const path& to);
- void copy(const path& from, const path& to, error_code& ec);
- void copy(const path& from, const path& to, copy_options options);
- void copy(const path& from, const path& to, copy_options options,
- error_code& ec);
-
- bool copy_file(const path& from, const path& to);
- bool copy_file(const path& from, const path& to, error_code& ec);
- bool copy_file(const path& from, const path& to, copy_options option);
- bool copy_file(const path& from, const path& to, copy_options option,
- error_code& ec);
-
- void copy_symlink(const path& existing_symlink, const path& new_symlink);
- void copy_symlink(const path& existing_symlink, const path& new_symlink,
- error_code& ec) noexcept;
-
- bool create_directories(const path& p);
- bool create_directories(const path& p, error_code& ec);
-
- bool create_directory(const path& p);
- bool create_directory(const path& p, error_code& ec) noexcept;
-
- bool create_directory(const path& p, const path& attributes);
- bool create_directory(const path& p, const path& attributes,
- error_code& ec) noexcept;
-
- void create_directory_symlink(const path& to, const path& new_symlink);
- void create_directory_symlink(const path& to, const path& new_symlink,
- error_code& ec) noexcept;
-
- void create_hard_link(const path& to, const path& new_hard_link);
- void create_hard_link(const path& to, const path& new_hard_link,
- error_code& ec) noexcept;
-
- void create_symlink(const path& to, const path& new_symlink);
- void create_symlink(const path& to, const path& new_symlink,
- error_code& ec) noexcept;
-
- path current_path();
- path current_path(error_code& ec);
- void current_path(const path& p);
- void current_path(const path& p, error_code& ec) noexcept;
-
- bool exists(file_status s) noexcept;
- bool exists(const path& p);
- bool exists(const path& p, error_code& ec) noexcept;
-
- bool equivalent(const path& p1, const path& p2);
- bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
-
- uintmax_t file_size(const path& p);
- uintmax_t file_size(const path& p, error_code& ec) noexcept;
-
- uintmax_t hard_link_count(const path& p);
- uintmax_t hard_link_count(const path& p, error_code& ec) noexcept;
-
- bool is_block_file(file_status s) noexcept;
- bool is_block_file(const path& p);
- bool is_block_file(const path& p, error_code& ec) noexcept;
-
- bool is_character_file(file_status s) noexcept;
- bool is_character_file(const path& p);
- bool is_character_file(const path& p, error_code& ec) noexcept;
-
- bool is_directory(file_status s) noexcept;
- bool is_directory(const path& p);
- bool is_directory(const path& p, error_code& ec) noexcept;
-
- bool is_empty(const path& p);
- bool is_empty(const path& p, error_code& ec) noexcept;
-
- bool is_fifo(file_status s) noexcept;
- bool is_fifo(const path& p);
- bool is_fifo(const path& p, error_code& ec) noexcept;
-
- bool is_other(file_status s) noexcept;
- bool is_other(const path& p);
- bool is_other(const path& p, error_code& ec) noexcept;
-
- bool is_regular_file(file_status s) noexcept;
- bool is_regular_file(const path& p);
- bool is_regular_file(const path& p, error_code& ec) noexcept;
-
- bool is_socket(file_status s) noexcept;
- bool is_socket(const path& p);
- bool is_socket(const path& p, error_code& ec) noexcept;
-
- bool is_symlink(file_status s) noexcept;
- bool is_symlink(const path& p);
- bool is_symlink(const path& p, error_code& ec) noexcept;
-
- file_time_type last_write_time(const path& p);
- file_time_type last_write_time(const path& p, error_code& ec) noexcept;
- void last_write_time(const path& p, file_time_type new_time);
- void last_write_time(const path& p, file_time_type new_time,
- error_code& ec) noexcept;
-
- void permissions(const path& p, perms prms,
- perm_options opts=perm_options::replace);
- void permissions(const path& p, perms prms, error_code& ec) noexcept;
- void permissions(const path& p, perms prms, perm_options opts,
- error_code& ec);
-
- path proximate(const path& p, error_code& ec);
- path proximate(const path& p, const path& base = current_path());
- path proximate(const path& p, const path& base, error_code &ec);
-
- path read_symlink(const path& p);
- path read_symlink(const path& p, error_code& ec);
-
- path relative(const path& p, error_code& ec);
- path relative(const path& p, const path& base=current_path());
- path relative(const path& p, const path& base, error_code& ec);
-
- bool remove(const path& p);
- bool remove(const path& p, error_code& ec) noexcept;
-
- uintmax_t remove_all(const path& p);
- uintmax_t remove_all(const path& p, error_code& ec);
-
- void rename(const path& from, const path& to);
- void rename(const path& from, const path& to, error_code& ec) noexcept;
-
- void resize_file(const path& p, uintmax_t size);
- void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
-
- space_info space(const path& p);
- space_info space(const path& p, error_code& ec) noexcept;
-
- file_status status(const path& p);
- file_status status(const path& p, error_code& ec) noexcept;
-
- bool status_known(file_status s) noexcept;
-
- file_status symlink_status(const path& p);
- file_status symlink_status(const path& p, error_code& ec) noexcept;
-
- path temp_directory_path();
- path temp_directory_path(error_code& ec);
-
- path weakly_canonical(path const& p);
- path weakly_canonical(path const& p, error_code& ec);
-
-
-} } } } // namespaces std::experimental::filesystem::v1
-
-*/
-
-#include <experimental/__config>
-#include <filesystem>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-#ifndef _LIBCPP_CXX03_LANG
-
-#define __cpp_lib_experimental_filesystem 201406
-
-_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
-
-using namespace _VSTD_FS;
-
-_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
-
-#endif // !_LIBCPP_CXX03_LANG
-
-_LIBCPP_POP_MACROS
-
-#endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM
lib/libcxx/include/experimental/forward_list
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_FORWARD_LIST
#define _LIBCPP_EXPERIMENTAL_FORWARD_LIST
+
/*
experimental/forward_list synopsis
@@ -28,12 +29,13 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <forward_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/functional
@@ -18,29 +18,6 @@
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
-
- // See C++14 20.9.9, Function object binders
- template <class T> constexpr bool is_bind_expression_v
- = is_bind_expression<T>::value;
- template <class T> constexpr int is_placeholder_v
- = is_placeholder<T>::value;
-
- // 4.2, Class template function
- template<class> class function; // undefined
- template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
-
- template<class R, class... ArgTypes>
- void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
-
- template<class R, class... ArgTypes>
- bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
- template<class R, class... ArgTypes>
- bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
- template<class R, class... ArgTypes>
- bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
- template<class R, class... ArgTypes>
- bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
-
// 4.3, Searchers
template<class ForwardIterator, class BinaryPredicate = equal_to<>>
class default_searcher;
@@ -79,16 +56,14 @@ inline namespace fundamentals_v1 {
} // namespace fundamentals_v1
} // namespace experimental
- template<class R, class... ArgTypes, class Alloc>
- struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>;
-
} // namespace std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__debug>
+#include <__functional/identity.h>
#include <__memory/uses_allocator.h>
-#include <algorithm>
#include <array>
#include <experimental/__config>
#include <functional>
@@ -97,7 +72,7 @@ inline namespace fundamentals_v1 {
#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -105,10 +80,20 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_LFTS
+#ifdef _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_SEARCHERS
+# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER
+# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER
+# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER
+#else
+# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::default_searcher will be removed in LLVM 17. Use std::default_searcher instead")
+# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_searcher will be removed in LLVM 17. Use std::boyer_moore_searcher instead")
+# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_horspool_searcher will be removed in LLVM 17. Use std::boyer_moore_horspool_searcher instead")
+#endif
+
#if _LIBCPP_STD_VER > 11
// default searcher
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
-class _LIBCPP_TEMPLATE_VIS default_searcher {
+class _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_TEMPLATE_VIS default_searcher {
public:
_LIBCPP_INLINE_VISIBILITY
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
@@ -120,9 +105,8 @@ public:
pair<_ForwardIterator2, _ForwardIterator2>
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
{
- return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
- typename iterator_traits<_ForwardIterator>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category());
+ auto __proj = __identity();
+ return std::__search_impl(__f, __l, __first_, __last_, __pred_, __proj, __proj);
}
private:
@@ -132,7 +116,7 @@ private:
};
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_INLINE_VISIBILITY
default_searcher<_ForwardIterator, _BinaryPredicate>
make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())
{
@@ -144,7 +128,6 @@ template<class _Key, class _Value, class _Hash, class _BinaryPredicate, bool /*u
// General case for BM data searching; use a map
template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>
class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
-public: // TODO private:
typedef _Value value_type;
typedef _Key key_type;
@@ -179,7 +162,7 @@ private:
typedef _Key key_type;
typedef typename make_unsigned<key_type>::type unsigned_key_type;
- typedef std::array<value_type, numeric_limits<unsigned_key_type>::max()> skip_map;
+ typedef std::array<value_type, 256> skip_map;
skip_map __table;
public:
@@ -206,7 +189,7 @@ public:
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
-class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {
+class _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {
private:
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
@@ -236,11 +219,9 @@ public:
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<_RandomAccessIterator2>::value_type>::type
- >::value,
- "Corpus and Pattern iterators must point to the same type" );
+ static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type,
+ typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
+ "Corpus and Pattern iterators must point to the same type");
if (__f == __l ) return make_pair(__l, __l); // empty corpus
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
@@ -253,7 +234,7 @@ public:
return this->__search(__f, __l);
}
-public: // TODO private:
+private:
_RandomAccessIterator1 __first_;
_RandomAccessIterator1 __last_;
_BinaryPredicate __pred_;
@@ -320,7 +301,7 @@ public: // TODO private:
vector<difference_type> & __suffix = *__suffix_.get();
if (__count > 0)
{
- vector<value_type> __scratch(__count);
+ vector<difference_type> __scratch(__count);
__compute_bm_prefix(__f, __l, __pred, __scratch);
for ( size_t __i = 0; __i <= __count; __i++ )
@@ -345,7 +326,7 @@ public: // TODO private:
template<class _RandomAccessIterator,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
class _BinaryPredicate = equal_to<>>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_INLINE_VISIBILITY
boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
_Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
@@ -357,7 +338,7 @@ make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
-class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {
+class _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {
private:
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
@@ -388,11 +369,9 @@ public:
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<_RandomAccessIterator2>::value_type>::type
- >::value,
- "Corpus and Pattern iterators must point to the same type" );
+ static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type,
+ typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
+ "Corpus and Pattern iterators must point to the same type");
if (__f == __l ) return make_pair(__l, __l); // empty corpus
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
@@ -440,7 +419,7 @@ private:
template<class _RandomAccessIterator,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
class _BinaryPredicate = equal_to<>>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_INLINE_VISIBILITY
boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
_Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
lib/libcxx/include/experimental/iterator
@@ -52,14 +52,16 @@ namespace std {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__memory/addressof.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <experimental/__config>
+#include <iosfwd> // char_traits
#include <iterator>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 11
lib/libcxx/include/experimental/list
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_LIST
#define _LIBCPP_EXPERIMENTAL_LIST
+
/*
experimental/list synopsis
@@ -28,12 +29,13 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/map
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_MAP
#define _LIBCPP_EXPERIMENTAL_MAP
+
/*
experimental/map synopsis
@@ -33,12 +34,13 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <map>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/memory_resource
@@ -64,8 +64,9 @@ namespace pmr {
*/
-#include <__debug>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__tuple>
+#include <__utility/move.h>
#include <cstddef>
#include <cstdlib>
#include <experimental/__config>
@@ -75,10 +76,9 @@ namespace pmr {
#include <new>
#include <stdexcept>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/experimental/propagate_const
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
#define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
+
/*
propagate_const synopsis
@@ -106,13 +107,16 @@
*/
+#include <__assert> // all public C++ headers provide the assertion handler
+#include <__functional/operations.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <experimental/__config>
-#include <functional>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 11
lib/libcxx/include/experimental/regex
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_REGEX
#define _LIBCPP_EXPERIMENTAL_REGEX
+
/*
experimental/regex synopsis
@@ -35,13 +36,14 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <experimental/string>
#include <regex>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/set
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_SET
#define _LIBCPP_EXPERIMENTAL_SET
+
/*
experimental/set synopsis
@@ -33,12 +34,13 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <set>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/simd
@@ -649,14 +649,20 @@ public:
*/
-#include <algorithm>
+#include <__assert> // all public C++ headers provide the assertion handler
+#include <__functional/operations.h>
#include <array>
#include <cstddef>
#include <experimental/__config>
-#include <functional>
+#include <tuple>
+
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <functional>
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -1236,32 +1242,32 @@ _Tp reduce(const simd<_Tp, _Abi>&, _BinaryOp = _BinaryOp());
template <class _MaskType, class _SimdType, class _BinaryOp>
typename _SimdType::value_type
reduce(const const_where_expression<_MaskType, _SimdType>&,
- typename _SimdType::value_type neutral_element, _BinaryOp binary_op);
+ typename _SimdType::value_type __neutral_element, _BinaryOp);
template <class _MaskType, class _SimdType>
typename _SimdType::value_type
reduce(const const_where_expression<_MaskType, _SimdType>&,
- plus<typename _SimdType::value_type> binary_op = {});
+ plus<typename _SimdType::value_type> = {});
template <class _MaskType, class _SimdType>
typename _SimdType::value_type
reduce(const const_where_expression<_MaskType, _SimdType>&,
- multiplies<typename _SimdType::value_type> binary_op);
+ multiplies<typename _SimdType::value_type>);
template <class _MaskType, class _SimdType>
typename _SimdType::value_type
reduce(const const_where_expression<_MaskType, _SimdType>&,
- bit_and<typename _SimdType::value_type> binary_op);
+ bit_and<typename _SimdType::value_type>);
template <class _MaskType, class _SimdType>
typename _SimdType::value_type
reduce(const const_where_expression<_MaskType, _SimdType>&,
- bit_or<typename _SimdType::value_type> binary_op);
+ bit_or<typename _SimdType::value_type>);
template <class _MaskType, class _SimdType>
typename _SimdType::value_type
reduce(const const_where_expression<_MaskType, _SimdType>&,
- bit_xor<typename _SimdType::value_type> binary_op);
+ bit_xor<typename _SimdType::value_type>);
template <class _Tp, class _Abi>
_Tp hmin(const simd<_Tp, _Abi>&);
@@ -1471,6 +1477,7 @@ public:
simd operator+() const;
simd operator-() const;
+#if 0
// binary operators [simd.binary]
friend simd operator+(const simd&, const simd&);
friend simd operator-(const simd&, const simd&);
@@ -1507,6 +1514,7 @@ public:
friend mask_type operator<=(const simd&, const simd&);
friend mask_type operator>(const simd&, const simd&);
friend mask_type operator<(const simd&, const simd&);
+#endif
};
// [simd.mask.class]
@@ -1546,6 +1554,7 @@ public:
// unary operators [simd.mask.unary]
simd_mask operator!() const noexcept;
+#if 0
// simd_mask binary operators [simd.mask.binary]
friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept;
friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept;
@@ -1561,6 +1570,7 @@ public:
// simd_mask compares [simd.mask.comparison]
friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept;
friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept;
+#endif
};
#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/experimental/string
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_STRING
#define _LIBCPP_EXPERIMENTAL_STRING
+
/*
experimental/string synopsis
@@ -37,12 +38,13 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <string>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/type_traits
@@ -68,6 +68,7 @@ inline namespace fundamentals_v1 {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#if _LIBCPP_STD_VER > 11
@@ -76,7 +77,7 @@ inline namespace fundamentals_v1 {
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS
lib/libcxx/include/experimental/unordered_map
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_MAP
#define _LIBCPP_EXPERIMENTAL_UNORDERED_MAP
+
/*
experimental/unordered_map synopsis
@@ -39,12 +40,21 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <unordered_map>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <array>
+# include <bit>
+# include <functional>
+# include <vector>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/unordered_set
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_SET
#define _LIBCPP_EXPERIMENTAL_UNORDERED_SET
+
/*
experimental/unordered_set synopsis
@@ -33,12 +34,13 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <unordered_set>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/experimental/utility
@@ -30,11 +30,12 @@ inline namespace fundamentals_v1 {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS
lib/libcxx/include/experimental/vector
@@ -9,6 +9,7 @@
#ifndef _LIBCPP_EXPERIMENTAL_VECTOR
#define _LIBCPP_EXPERIMENTAL_VECTOR
+
/*
experimental/vector synopsis
@@ -28,12 +29,13 @@ namespace pmr {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <experimental/__config>
#include <experimental/memory_resource>
#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
lib/libcxx/include/ext/__hash
@@ -10,9 +10,9 @@
#ifndef _LIBCPP_EXT_HASH
#define _LIBCPP_EXT_HASH
-#pragma GCC system_header
+# pragma GCC system_header
-#include <__string>
+#include <__config>
#include <cstring>
#include <string>
@@ -21,7 +21,7 @@ namespace __gnu_cxx {
template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
- : public std::unary_function<const char*, size_t>
+ : public std::__unary_function<const char*, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const char *__c) const _NOEXCEPT
@@ -31,7 +31,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
- : public std::unary_function<char*, size_t>
+ : public std::__unary_function<char*, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(char *__c) const _NOEXCEPT
@@ -41,7 +41,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
- : public std::unary_function<char, size_t>
+ : public std::__unary_function<char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(char __c) const _NOEXCEPT
@@ -51,7 +51,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
- : public std::unary_function<signed char, size_t>
+ : public std::__unary_function<signed char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(signed char __c) const _NOEXCEPT
@@ -61,7 +61,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
- : public std::unary_function<unsigned char, size_t>
+ : public std::__unary_function<unsigned char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned char __c) const _NOEXCEPT
@@ -71,7 +71,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
- : public std::unary_function<short, size_t>
+ : public std::__unary_function<short, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(short __c) const _NOEXCEPT
@@ -81,7 +81,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
- : public std::unary_function<unsigned short, size_t>
+ : public std::__unary_function<unsigned short, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned short __c) const _NOEXCEPT
@@ -91,7 +91,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
- : public std::unary_function<int, size_t>
+ : public std::__unary_function<int, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(int __c) const _NOEXCEPT
@@ -101,7 +101,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
- : public std::unary_function<unsigned int, size_t>
+ : public std::__unary_function<unsigned int, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned int __c) const _NOEXCEPT
@@ -111,7 +111,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
- : public std::unary_function<long, size_t>
+ : public std::__unary_function<long, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(long __c) const _NOEXCEPT
@@ -121,7 +121,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
- : public std::unary_function<unsigned long, size_t>
+ : public std::__unary_function<unsigned long, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned long __c) const _NOEXCEPT
lib/libcxx/include/ext/hash_map
@@ -201,13 +201,19 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__hash_table>
+#include <algorithm>
#include <ext/__hash>
#include <functional>
#include <stdexcept>
#include <type_traits>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iterator>
+#endif
+
#if defined(__DEPRECATED) && __DEPRECATED
#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")
@@ -217,7 +223,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
namespace __gnu_cxx {
@@ -599,7 +605,7 @@ public:
{return __table_.bucket_size(__n);}
_LIBCPP_INLINE_VISIBILITY
- void resize(size_type __n) {__table_.rehash(__n);}
+ void resize(size_type __n) {__table_.__rehash_unique(__n);}
private:
__node_holder __construct_node(const key_type& __k);
@@ -610,7 +616,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -619,7 +625,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -637,7 +643,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__first, __last);
}
@@ -648,7 +654,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__first, __last);
}
@@ -657,7 +663,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const hash_map& __u)
: __table_(__u.__table_)
{
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -868,7 +874,7 @@ public:
{return __table_.bucket_size(__n);}
_LIBCPP_INLINE_VISIBILITY
- void resize(size_type __n) {__table_.rehash(__n);}
+ void resize(size_type __n) {__table_.__rehash_multi(__n);}
};
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -876,7 +882,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -885,7 +891,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -903,7 +909,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__first, __last);
}
@@ -914,7 +920,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__first, __last);
}
@@ -923,7 +929,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const hash_multimap& __u)
: __table_(__u.__table_)
{
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
lib/libcxx/include/ext/hash_set
@@ -192,11 +192,17 @@ template <class Value, class Hash, class Pred, class Alloc>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__hash_table>
+#include <algorithm>
#include <ext/__hash>
#include <functional>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iterator>
+#endif
+
#if defined(__DEPRECATED) && __DEPRECATED
#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")
@@ -206,7 +212,7 @@ template <class Value, class Hash, class Pred, class Alloc>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
namespace __gnu_cxx {
@@ -327,7 +333,7 @@ public:
size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
_LIBCPP_INLINE_VISIBILITY
- void resize(size_type __n) {__table_.rehash(__n);}
+ void resize(size_type __n) {__table_.__rehash_unique(__n);}
};
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -335,7 +341,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -343,7 +349,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -361,7 +367,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__first, __last);
}
@@ -372,7 +378,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__first, __last);
}
@@ -381,7 +387,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
const hash_set& __u)
: __table_(__u.__table_)
{
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -547,7 +553,7 @@ public:
size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
_LIBCPP_INLINE_VISIBILITY
- void resize(size_type __n) {__table_.rehash(__n);}
+ void resize(size_type __n) {__table_.__rehash_multi(__n);}
};
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -555,7 +561,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -564,7 +570,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -582,7 +588,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__first, __last);
}
@@ -593,7 +599,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__first, __last);
}
@@ -602,7 +608,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const hash_multiset& __u)
: __table_(__u.__table_)
{
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
lib/libcxx/include/__assert
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ASSERT
+#define _LIBCPP___ASSERT
+
+#include <__config>
+#include <__verbose_abort>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// This is for backwards compatibility with code that might have been enabling
+// assertions through the Debug mode previously.
+// TODO: In LLVM 16, make it an error to define _LIBCPP_DEBUG
+#if defined(_LIBCPP_DEBUG)
+# ifndef _LIBCPP_ENABLE_ASSERTIONS
+# define _LIBCPP_ENABLE_ASSERTIONS 1
+# endif
+#endif
+
+// Automatically enable assertions when the debug mode is enabled.
+#if defined(_LIBCPP_ENABLE_DEBUG_MODE)
+# ifndef _LIBCPP_ENABLE_ASSERTIONS
+# define _LIBCPP_ENABLE_ASSERTIONS 1
+# endif
+#endif
+
+#ifndef _LIBCPP_ENABLE_ASSERTIONS
+# define _LIBCPP_ENABLE_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS_DEFAULT
+#endif
+
+#if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
+# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
+#endif
+
+#if _LIBCPP_ENABLE_ASSERTIONS
+# define _LIBCPP_ASSERT(expression, message) \
+ (__builtin_expect(static_cast<bool>(expression), 1) ? \
+ (void)0 : \
+ ::std::__libcpp_verbose_abort("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
+#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
+# define _LIBCPP_ASSERT(expression, message) \
+ (_LIBCPP_DIAGNOSTIC_PUSH \
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \
+ __builtin_assume(static_cast<bool>(expression)) \
+ _LIBCPP_DIAGNOSTIC_POP)
+#else
+# define _LIBCPP_ASSERT(expression, message) ((void)0)
+#endif
+
+#endif // _LIBCPP___ASSERT
lib/libcxx/include/__availability
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
+# pragma GCC system_header
#endif
// Libc++ is shipped by various vendors. In particular, it is used as a system
@@ -91,6 +91,10 @@
// other exception types. These were put in the shared library to prevent
// code bloat from every user program defining the vtable for these exception
// types.
+ //
+ // Note that when exceptions are disabled, the methods that normally throw
+ // these exceptions can be used even on older deployment targets, but those
+ // methods will abort instead of throwing.
# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
@@ -99,10 +103,15 @@
# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
// This controls the availability of the sized version of ::operator delete,
- // which was added to the dylib later.
+ // ::operator delete[], and their align_val_t variants, which were all added
+ // in C++17, and hence not present in early dylibs.
# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
// This controls the availability of the std::future_error exception.
+ //
+ // Note that when exceptions are disabled, the methods that normally throw
+ // std::future_error can be used even on older deployment targets, but those
+ // methods will abort instead of throwing.
# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
// This controls the availability of std::type_info's vtable.
@@ -126,16 +135,14 @@
# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
- // This controls the availability of std::to_chars.
-# define _LIBCPP_AVAILABILITY_TO_CHARS
-
// This controls the availability of floating-point std::to_chars functions.
// These overloads were added later than the integer overloads.
# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT
// This controls the availability of the C++20 synchronization library,
// which requires shared library support for various operations
- // (see libcxx/src/atomic.cpp).
+ // (see libcxx/src/atomic.cpp). This includes <barier>, <latch>,
+ // <semaphore>, and notification functions on std::atomic.
# define _LIBCPP_AVAILABILITY_SYNC
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier
@@ -149,10 +156,26 @@
# define _LIBCPP_AVAILABILITY_FORMAT
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
+ // This controls whether the default verbose termination function is
+ // provided by the library.
+ //
+ // Note that when users provide their own custom function, it doesn't
+ // matter whether the dylib provides a default function, and the
+ // availability markup can actually give a false positive diagnostic
+ // (it will think that no function is provided, when in reality the
+ // user has provided their own).
+ //
+ // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED
+ // to the compiler to tell the library to ignore the fact that the
+ // default function isn't available on their deployment target. Note that
+ // defining this macro but failing to define a custom function will lead to
+ // a load-time error on back-deployment targets, so it should be avoided.
+# define _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT
+
#elif defined(__APPLE__)
# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
- __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(macos,strict,introduced=10.12))) \
__attribute__((availability(ios,strict,introduced=10.0))) \
__attribute__((availability(tvos,strict,introduced=10.0))) \
__attribute__((availability(watchos,strict,introduced=3.0)))
@@ -164,24 +187,27 @@
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex
# endif
+ // Note: bad_optional_access & friends were not introduced in the matching
+ // macOS and iOS versions, so the version mismatch between macOS and others
+ // is intended.
# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
- __attribute__((availability(macosx,strict,introduced=10.13))) \
- __attribute__((availability(ios,strict,introduced=11.0))) \
- __attribute__((availability(tvos,strict,introduced=11.0))) \
- __attribute__((availability(watchos,strict,introduced=4.0)))
+ __attribute__((availability(macos,strict,introduced=10.13))) \
+ __attribute__((availability(ios,strict,introduced=12.0))) \
+ __attribute__((availability(tvos,strict,introduced=12.0))) \
+ __attribute__((availability(watchos,strict,introduced=5.0)))
# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
- __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(macos,strict,introduced=10.12))) \
__attribute__((availability(ios,strict,introduced=10.0))) \
__attribute__((availability(tvos,strict,introduced=10.0))) \
__attribute__((availability(watchos,strict,introduced=3.0)))
# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
- __attribute__((availability(macosx,strict,introduced=10.12))) \
+ __attribute__((availability(macos,strict,introduced=10.12))) \
__attribute__((availability(ios,strict,introduced=10.0))) \
__attribute__((availability(tvos,strict,introduced=10.0))) \
__attribute__((availability(watchos,strict,introduced=3.0)))
@@ -190,26 +216,26 @@
__attribute__((availability(ios,strict,introduced=6.0)))
# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
- __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(macos,strict,introduced=10.9))) \
__attribute__((availability(ios,strict,introduced=7.0)))
# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
- __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(macos,strict,introduced=10.9))) \
__attribute__((availability(ios,strict,introduced=7.0)))
# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
- __attribute__((availability(macosx,strict,introduced=10.9))) \
+ __attribute__((availability(macos,strict,introduced=10.9))) \
__attribute__((availability(ios,strict,introduced=7.0)))
# define _LIBCPP_AVAILABILITY_FILESYSTEM \
- __attribute__((availability(macosx,strict,introduced=10.15))) \
+ __attribute__((availability(macos,strict,introduced=10.15))) \
__attribute__((availability(ios,strict,introduced=13.0))) \
__attribute__((availability(tvos,strict,introduced=13.0))) \
__attribute__((availability(watchos,strict,introduced=6.0)))
# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
- _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
- _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
- _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
_Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
_Pragma("clang attribute pop") \
@@ -223,14 +249,11 @@
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
# endif
-# define _LIBCPP_AVAILABILITY_TO_CHARS \
- _LIBCPP_AVAILABILITY_FILESYSTEM
-
# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \
__attribute__((unavailable))
# define _LIBCPP_AVAILABILITY_SYNC \
- __attribute__((availability(macosx,strict,introduced=11.0))) \
+ __attribute__((availability(macos,strict,introduced=11.0))) \
__attribute__((availability(ios,strict,introduced=14.0))) \
__attribute__((availability(tvos,strict,introduced=14.0))) \
__attribute__((availability(watchos,strict,introduced=7.0)))
@@ -244,13 +267,12 @@
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
# endif
- // This controls the availability of the C++20 format library.
- // The library is in development and not ABI stable yet. P2216 is
- // retroactively accepted in C++20. This paper contains ABI breaking
- // changes.
# define _LIBCPP_AVAILABILITY_FORMAT \
__attribute__((unavailable))
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
+
+# define _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT \
+ __attribute__((unavailable))
#else
// ...New vendors can add availability markup here...
@@ -274,4 +296,14 @@
# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
#endif
+// Define the special verbose termination function availability attribute, which can be silenced by
+// users if they provide their own custom function. The rest of the code should not use the
+// *_DEFAULT_* macro directly, since that would make it ignore the fact that the user provided
+// a custom function.
+#if defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED)
+# define _LIBCPP_AVAILABILITY_VERBOSE_ABORT /* nothing */
+#else
+# define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT
+#endif
+
#endif // _LIBCPP___AVAILABILITY
lib/libcxx/include/__bit_reference
@@ -10,12 +10,19 @@
#ifndef _LIBCPP___BIT_REFERENCE
#define _LIBCPP___BIT_REFERENCE
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/min.h>
#include <__bits>
#include <__config>
-#include <algorithm>
+#include <__iterator/iterator_traits.h>
+#include <__memory/construct_at.h>
+#include <__memory/pointer_traits.h>
+#include <cstring>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -47,15 +54,15 @@ class __bit_reference
friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, false>;
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference(const __bit_reference&) = default;
- _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT
{return static_cast<bool>(*__seg_ & __mask_);}
- _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT
{return !static_cast<bool>(*this);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference& operator=(bool __x) _NOEXCEPT
{
if (__x)
@@ -65,16 +72,26 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept {
+ if (__x)
+ *__seg_ |= __mask_;
+ else
+ *__seg_ &= ~__mask_;
+ return *this;
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
{return operator=(static_cast<bool>(__x));}
- _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
{return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
- _LIBCPP_INLINE_VISIBILITY
- __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
: __seg_(__s), __mask_(__m) {}
};
@@ -84,7 +101,7 @@ class __bit_reference<_Cp, false>
};
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
{
@@ -94,7 +111,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
}
template <class _Cp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
{
@@ -104,7 +121,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
{
@@ -114,7 +131,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
{
@@ -138,19 +155,19 @@ public:
_LIBCPP_INLINE_VISIBILITY
__bit_const_reference(const __bit_const_reference&) = default;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
: __seg_(__x.__seg_), __mask_(__x.__mask_) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
{return static_cast<bool>(*__seg_ & __mask_);}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
{return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
- __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
+ explicit __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
: __seg_(__s), __mask_(__m) {}
__bit_const_reference& operator=(const __bit_const_reference&) = delete;
@@ -159,12 +176,12 @@ private:
// find
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
- static const int __bits_per_word = _It::__bits_per_word;
+ const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@@ -195,7 +212,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, _IsConst> _It;
@@ -234,11 +251,11 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, _IsConst>
-find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
+find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
{
- if (static_cast<bool>(__value_))
+ if (static_cast<bool>(__value))
return _VSTD::__find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
return _VSTD::__find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
}
@@ -310,9 +327,9 @@ __count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_typ
template <class _Cp, bool _IsConst, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename __bit_iterator<_Cp, _IsConst>::difference_type
-count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
+count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
{
- if (static_cast<bool>(__value_))
+ if (static_cast<bool>(__value))
return _VSTD::__count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
return _VSTD::__count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
}
@@ -320,7 +337,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las
// fill_n
template <class _Cp>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
@@ -338,7 +355,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_address(__first.__seg_), 0, __nw * sizeof(__storage_type));
+ std::fill_n(std::__to_address(__first.__seg_), __nw, 0);
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@@ -350,7 +367,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
template <class _Cp>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
@@ -368,7 +385,8 @@ __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_address(__first.__seg_), -1, __nw * sizeof(__storage_type));
+ // __storage_type is always an unsigned type, so -1 sets all bits
+ std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1));
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@@ -380,13 +398,13 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
-fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_)
+fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)
{
if (__n > 0)
{
- if (__value_)
+ if (__value)
_VSTD::__fill_n_true(__first, __n);
else
_VSTD::__fill_n_false(__first, __n);
@@ -396,16 +414,17 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
// fill
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
-fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value_)
+fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)
{
- _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value_);
+ _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value);
}
// copy
template <class _Cp, bool _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
@@ -435,9 +454,7 @@ __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_address(__result.__seg_),
- _VSTD::__to_address(__first.__seg_),
- __nw * sizeof(__storage_type));
+ std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_));
__n -= __nw * __bits_per_word;
__result.__seg_ += __nw;
// do last word
@@ -455,6 +472,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
}
template <class _Cp, bool _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
@@ -462,7 +480,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
- static const int __bits_per_word = _In::__bits_per_word;
+ const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -533,7 +551,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
}
template <class _Cp, bool _IsConst>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
@@ -545,7 +563,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
// copy_backward
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@@ -576,9 +594,7 @@ __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_address(__result.__seg_),
- _VSTD::__to_address(__last.__seg_),
- __nw * sizeof(__storage_type));
+ std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_));
__n -= __nw * __bits_per_word;
// do last word
if (__n > 0)
@@ -594,7 +610,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
}
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@@ -680,7 +696,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
}
template <class _Cp, bool _IsConst>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
@@ -887,14 +903,19 @@ struct __bit_array
difference_type __size_;
__storage_type __word_[_Np];
- _LIBCPP_INLINE_VISIBILITY static difference_type capacity()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static difference_type capacity()
{return static_cast<difference_type>(_Np * __bits_per_word);}
- _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {}
- _LIBCPP_INLINE_VISIBILITY iterator begin()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_array(difference_type __s) : __size_(__s) {
+ if (__libcpp_is_constant_evaluated()) {
+ for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)
+ std::__construct_at(__word_ + __i, 0);
+ }
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin()
{
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
}
- _LIBCPP_INLINE_VISIBILITY iterator end()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end()
{
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
static_cast<unsigned>(__size_ % __bits_per_word));
@@ -902,7 +923,7 @@ struct __bit_array
};
template <class _Cp>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)
{
typedef __bit_iterator<_Cp, false> _I1;
@@ -953,14 +974,14 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
// equal
template <class _Cp, bool _IC1, bool _IC2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
__bit_iterator<_Cp, _IC2> __first2)
{
typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
- static const int __bits_per_word = _It::__bits_per_word;
+ const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@@ -1035,14 +1056,14 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
}
template <class _Cp, bool _IC1, bool _IC2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
__bit_iterator<_Cp, _IC2> __first2)
{
typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
- static const int __bits_per_word = _It::__bits_per_word;
+ const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@@ -1078,7 +1099,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
}
template <class _Cp, bool _IC1, bool _IC2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
{
@@ -1095,7 +1116,11 @@ public:
typedef typename _Cp::difference_type difference_type;
typedef bool value_type;
typedef __bit_iterator pointer;
+#ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference;
+#else
+ using reference = typename conditional<_IsConst, bool, __bit_reference<_Cp> >::type;
+#endif
typedef random_access_iterator_tag iterator_category;
private:
@@ -1108,7 +1133,7 @@ private:
unsigned __ctz_;
public:
- _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT
#if _LIBCPP_STD_VER > 11
: __seg_(nullptr), __ctz_(0)
#endif
@@ -1119,7 +1144,7 @@ public:
// When _IsConst=true, this is a converting constructor;
// the copy and move constructors are implicitly generated
// and trivial.
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
@@ -1128,17 +1153,19 @@ public:
// the implicit generation of a defaulted one is deprecated.
// When _IsConst=true, the assignment operators are
// implicitly generated and trivial.
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
__seg_ = __it.__seg_;
__ctz_ = __it.__ctz_;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
- {return reference(__seg_, __storage_type(1) << __ctz_);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT {
+ return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >
+ ::type(__seg_, __storage_type(1) << __ctz_);
+ }
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++()
{
if (__ctz_ != __bits_per_word-1)
++__ctz_;
@@ -1150,14 +1177,14 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator++(int)
{
__bit_iterator __tmp = *this;
++(*this);
return __tmp;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--()
{
if (__ctz_ != 0)
--__ctz_;
@@ -1169,14 +1196,14 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator--(int)
{
__bit_iterator __tmp = *this;
--(*this);
return __tmp;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator+=(difference_type __n)
{
if (__n >= 0)
__seg_ += (__n + __ctz_) / __bits_per_word;
@@ -1188,55 +1215,55 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator-=(difference_type __n)
{
return *this += -__n;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator+(difference_type __n) const
{
__bit_iterator __t(*this);
__t += __n;
return __t;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(difference_type __n) const
{
__bit_iterator __t(*this);
__t -= __n;
return __t;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)
{return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}
- _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](difference_type __n) const {return *(*this + __n);}
- _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
{return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}
- _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
{return !(__x == __y);}
- _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
{return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}
- _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
{return __y < __x;}
- _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
{return !(__y < __x);}
- _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
{return !(__x < __y);}
private:
- _LIBCPP_INLINE_VISIBILITY
- __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
: __seg_(__s), __ctz_(__ctz) {}
friend typename _Cp::__self;
@@ -1245,26 +1272,44 @@ private:
friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, true>;
template <class _Dp> friend struct __bit_array;
- template <class _Dp> friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
- template <class _Dp> friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
+ template <class _Dp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+
+ template <class _Dp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>,
__bit_iterator<__C1, false>,
__bit_iterator<__C2, false>);
@@ -1274,22 +1319,32 @@ private:
template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>,
__bit_iterator<__C1, false>,
__bit_iterator<__C2, false>);
- template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
- __bit_iterator<_Dp, false>,
- __bit_iterator<_Dp, false>);
- template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC2>);
- template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC2>);
- template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC2>);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>,
- typename _Dp::size_type);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>,
- typename _Dp::size_type);
+ template <class _Dp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
+ __bit_iterator<_Dp, false>,
+ __bit_iterator<_Dp, false>);
+ template <class _Dp, bool _IC1, bool _IC2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend bool equal(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
__count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
lib/libcxx/include/__bits
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -43,6 +43,23 @@ int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x);
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }
+# ifndef _LIBCPP_HAS_NO_INT128
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
+ // The function is written in this form due to C++ constexpr limitations.
+ // The algorithm:
+ // - Test whether any bit in the high 64-bits is set
+ // - No bits set:
+ // - The high 64-bits contain 64 leading zeros,
+ // - Add the result of the low 64-bits.
+ // - Any bits set:
+ // - The number of leading zeros of the input is the number of leading
+ // zeros in the high 64-bits.
+ return ((__x >> 64) == 0)
+ ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x)))
+ : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
+}
+# endif
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
lib/libcxx/include/__bsd_locale_defaults.h
@@ -11,11 +11,11 @@
// we will define the mapping from an internal macro to the real BSD symbol.
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H
-#define _LIBCPP_BSD_LOCALE_DEFAULTS_H
+#ifndef _LIBCPP___BSD_LOCALE_DEFAULTS_H
+#define _LIBCPP___BSD_LOCALE_DEFAULTS_H
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc)
@@ -33,4 +33,4 @@
#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__)
#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__)
-#endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H
+#endif // _LIBCPP___BSD_LOCALE_DEFAULTS_H
lib/libcxx/include/__bsd_locale_fallbacks.h
@@ -10,15 +10,15 @@
// of those functions for non-BSD platforms.
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
-#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
+#ifndef _LIBCPP___BSD_LOCALE_FALLBACKS_H
+#define _LIBCPP___BSD_LOCALE_FALLBACKS_H
#include <memory>
#include <stdarg.h>
#include <stdlib.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -140,4 +140,4 @@ int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...)
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
+#endif // _LIBCPP___BSD_LOCALE_FALLBACKS_H
lib/libcxx/include/__config
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_CONFIG
-#define _LIBCPP_CONFIG
+#ifndef _LIBCPP___CONFIG
+#define _LIBCPP___CONFIG
#if defined(_MSC_VER) && !defined(__clang__)
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -17,334 +17,326 @@
#endif
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef __cplusplus
-#define _LIBCPP_VERSION 14000
+# define _LIBCPP_VERSION 15000
-#ifndef _LIBCPP_ABI_VERSION
-# define _LIBCPP_ABI_VERSION 1
-#endif
+# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
+# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
-#if __STDC_HOSTED__ == 0
-# define _LIBCPP_FREESTANDING
-#endif
+// Valid C++ identifier that revs with every libc++ version. This can be used to
+// generate identifiers that must be unique for every released libc++ version.
+# define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION)
+
+# if __STDC_HOSTED__ == 0
+# define _LIBCPP_FREESTANDING
+# endif
-#ifndef _LIBCPP_STD_VER
-# if __cplusplus <= 201103L
-# define _LIBCPP_STD_VER 11
-# elif __cplusplus <= 201402L
-# define _LIBCPP_STD_VER 14
-# elif __cplusplus <= 201703L
-# define _LIBCPP_STD_VER 17
-# elif __cplusplus <= 202002L
-# define _LIBCPP_STD_VER 20
+# ifndef _LIBCPP_STD_VER
+# if __cplusplus <= 201103L
+# define _LIBCPP_STD_VER 11
+# elif __cplusplus <= 201402L
+# define _LIBCPP_STD_VER 14
+# elif __cplusplus <= 201703L
+# define _LIBCPP_STD_VER 17
+# elif __cplusplus <= 202002L
+# define _LIBCPP_STD_VER 20
+# else
+# define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification
+# endif
+# endif // _LIBCPP_STD_VER
+
+# if defined(__ELF__)
+# define _LIBCPP_OBJECT_FORMAT_ELF 1
+# elif defined(__MACH__)
+# define _LIBCPP_OBJECT_FORMAT_MACHO 1
+# elif defined(_WIN32)
+# define _LIBCPP_OBJECT_FORMAT_COFF 1
+# elif defined(__wasm__)
+# define _LIBCPP_OBJECT_FORMAT_WASM 1
+# elif defined(_AIX)
+# define _LIBCPP_OBJECT_FORMAT_XCOFF 1
# else
-# define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification
-# endif
-#endif // _LIBCPP_STD_VER
-
-#if defined(__ELF__)
-# define _LIBCPP_OBJECT_FORMAT_ELF 1
-#elif defined(__MACH__)
-# define _LIBCPP_OBJECT_FORMAT_MACHO 1
-#elif defined(_WIN32)
-# define _LIBCPP_OBJECT_FORMAT_COFF 1
-#elif defined(__wasm__)
-# define _LIBCPP_OBJECT_FORMAT_WASM 1
-#else
- // ... add new file formats here ...
-#endif
+// ... add new file formats here ...
+# endif
-#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
+# if _LIBCPP_ABI_VERSION >= 2
// Change short string representation so that string data starts at offset 0,
// improving its alignment in some cases.
-# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
// Fix deque iterator type in order to support incomplete types.
-# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
// Fix undefined behavior in how std::list stores its linked nodes.
-# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
+# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
// Fix undefined behavior in how __tree stores its end and parent nodes.
-# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
+# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
// Fix undefined behavior in how __hash_table stores its pointer types.
-# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
-# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
-# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
+# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
+# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
+# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
// Define a key function for `bad_function_call` in the library, to centralize
// its vtable and typeinfo to libc++ rather than having all other libraries
// using that class define their own copies.
-# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
// Override the default return value of exception::what() for
// bad_function_call::what() with a string that is specific to
// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
// because it changes the vtable layout of bad_function_call.
-# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
+# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
-# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
-// In C++20 and later, don't derive std::plus from std::binary_function,
-// nor std::negate from std::unary_function.
-# define _LIBCPP_ABI_NO_BINDER_BASES
+# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
// Give reverse_iterator<T> one data member of type T, not two.
// Also, in C++17 and later, don't derive iterator types from std::iterator.
-# define _LIBCPP_ABI_NO_ITERATOR_BASES
+# define _LIBCPP_ABI_NO_ITERATOR_BASES
// Use the smallest possible integer type to represent the index of the variant.
// Previously libc++ used "unsigned int" exclusively.
-# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
// Unstable attempt to provide a more optimized std::function
-# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
+# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
// All the regex constants must be distinct and nonzero.
-# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
-// Use raw pointers, not wrapped ones, for std::span's iterator type.
-# define _LIBCPP_ABI_SPAN_POINTER_ITERATORS
+# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
// Re-worked external template instantiations for std::string with a focus on
// performance and fast-path inlining.
-# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
+# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
// Enable clang::trivial_abi on std::unique_ptr.
-# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
+# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
-# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
+# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
// std::random_device holds some state when it uses an implementation that gets
// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
// implementation to another one on a platform that has already shipped
// std::random_device, one needs to retain the same object layout to remain ABI
// compatible. This switch removes these workarounds for platforms that don't care
// about ABI compatibility.
-# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
-// Remove basic_string common base
-# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
-// Remove vector base class
-# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
-#elif _LIBCPP_ABI_VERSION == 1
-# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
+// Don't export the legacy __basic_string_common class and its methods from the built library.
+# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
+// Don't export the legacy __vector_base_common class and its methods from the built library.
+# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
+// According to the Standard, `bitset::operator[] const` returns bool
+# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
+// Remove the base 10 implementation of std::to_chars from the dylib.
+// The implementation moved to the header, but we still export the symbols from
+// the dylib for backwards compatibility.
+# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
+# elif _LIBCPP_ABI_VERSION == 1
+# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
// Enable compiling copies of now inline methods into the dylib to support
// applications compiled against older libraries. This is unnecessary with
// COFF dllexport semantics, since dllexport forces a non-inline definition
// of inline functions to be emitted anyway. Our own non-inline copy would
-// conflict with the dllexport-emitted copy, so we disable it.
-# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
-# endif
+// conflict with the dllexport-emitted copy, so we disable it. For XCOFF,
+// the linker will take issue with the symbols in the shared object if the
+// weak inline methods get visibility (such as from -fvisibility-inlines-hidden),
+// so disable it.
+# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
+# endif
// Feature macros for disabling pre ABI v1 features. All of these options
// are deprecated.
-# if defined(__FreeBSD__)
-# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
+# if defined(__FreeBSD__)
+# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
+# endif
# endif
-#endif
-
-// By default, don't use a nullptr_t emulation type in C++03.
-//
-// This is technically an ABI break from previous releases, however it is
-// very unlikely to impact anyone. If a user is impacted by this break,
-// they can return to using the C++03 nullptr emulation by defining
-// _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION.
-//
-// This switch will be removed entirely in favour of never providing a
-// C++03 emulation after one release.
-//
-// IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE
-// A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN
-// IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION.
-#ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION
-# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
-#endif
-#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
+# if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2
// Enable additional explicit instantiations of iostreams components. This
// reduces the number of weak definitions generated in programs that use
// iostreams by providing a single strong definition in the shared library.
-# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
+# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
// Define a key function for `bad_function_call` in the library, to centralize
// its vtable and typeinfo to libc++ rather than having all other libraries
// using that class define their own copies.
-# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
-#endif
+# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+# endif
-#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
-#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
+# define _LIBCPP_TOSTRING2(x) # x
+# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
-#ifndef _LIBCPP_ABI_NAMESPACE
-# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
-#endif
-
-#if __cplusplus < 201103L
-#define _LIBCPP_CXX03_LANG
-#endif
+# if __cplusplus < 201103L
+# define _LIBCPP_CXX03_LANG
+# endif
-#ifndef __has_attribute
-#define __has_attribute(__x) 0
-#endif
+# ifndef __has_attribute
+# define __has_attribute(__x) 0
+# endif
-#ifndef __has_builtin
-#define __has_builtin(__x) 0
-#endif
+# ifndef __has_builtin
+# define __has_builtin(__x) 0
+# endif
-#ifndef __has_extension
-#define __has_extension(__x) 0
-#endif
+# ifndef __has_extension
+# define __has_extension(__x) 0
+# endif
-#ifndef __has_feature
-#define __has_feature(__x) 0
-#endif
+# ifndef __has_feature
+# define __has_feature(__x) 0
+# endif
-#ifndef __has_cpp_attribute
-#define __has_cpp_attribute(__x) 0
-#endif
+# ifndef __has_cpp_attribute
+# define __has_cpp_attribute(__x) 0
+# endif
// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
// the compiler and '1' otherwise.
-#ifndef __is_identifier
-#define __is_identifier(__x) 1
-#endif
+# ifndef __is_identifier
+# define __is_identifier(__x) 1
+# endif
-#ifndef __has_declspec_attribute
-#define __has_declspec_attribute(__x) 0
-#endif
+# ifndef __has_declspec_attribute
+# define __has_declspec_attribute(__x) 0
+# endif
-#define __has_keyword(__x) !(__is_identifier(__x))
+# define __has_keyword(__x) !(__is_identifier(__x))
-#ifndef __has_include
-#define __has_include(...) 0
-#endif
+# ifndef __has_include
+# define __has_include(...) 0
+# endif
-#if defined(__apple_build_version__)
-# define _LIBCPP_COMPILER_CLANG_BASED
-# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
-#elif defined(__clang__)
-# define _LIBCPP_COMPILER_CLANG_BASED
-# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
-#elif defined(__GNUC__)
-# define _LIBCPP_COMPILER_GCC
-#elif defined(_MSC_VER)
-# define _LIBCPP_COMPILER_MSVC
-#elif defined(__IBMCPP__)
-# define _LIBCPP_COMPILER_IBM
-#endif
+# if defined(__apple_build_version__)
+# define _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
+# elif defined(__clang__)
+# define _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
+# elif defined(__GNUC__)
+# define _LIBCPP_COMPILER_GCC
+# elif defined(_MSC_VER)
+# define _LIBCPP_COMPILER_MSVC
+# endif
-#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
-#error "libc++ does not support using GCC with C++03. Please enable C++11"
-#endif
+# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
+# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
+# endif
+
+# ifdef _LIBCPP_COMPILER_MSVC
+# error If you successfully use libc++ with MSVC please tell the libc++ developers and consider upstreaming your \
+changes. We are not aware of anybody using this configuration and know that at least some code is currently broken. \
+If there are users of this configuration we are happy to provide support.
+# endif
// FIXME: ABI detection should be done via compiler builtin macros. This
// is just a placeholder until Clang implements such macros. For now assume
// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
// and allow the user to explicitly specify the ABI to handle cases where this
// heuristic falls short.
-#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
-# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
-#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
-# define _LIBCPP_ABI_ITANIUM
-#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
-# define _LIBCPP_ABI_MICROSOFT
-#else
-# if defined(_WIN32) && defined(_MSC_VER)
+# if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
+# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
+# elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
+# define _LIBCPP_ABI_ITANIUM
+# elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
# define _LIBCPP_ABI_MICROSOFT
# else
-# define _LIBCPP_ABI_ITANIUM
+# if defined(_WIN32) && defined(_MSC_VER)
+# define _LIBCPP_ABI_MICROSOFT
+# else
+# define _LIBCPP_ABI_ITANIUM
+# endif
# endif
-#endif
-#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
-# define _LIBCPP_ABI_VCRUNTIME
-#endif
+# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
+# define _LIBCPP_ABI_VCRUNTIME
+# endif
-// Need to detect which libc we're using if we're on Linux.
-#if defined(__linux__)
-# include <features.h>
-# if defined(__GLIBC_PREREQ)
-# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
-# else
-# define _LIBCPP_GLIBC_PREREQ(a, b) 0
-# endif // defined(__GLIBC_PREREQ)
-#endif // defined(__linux__)
+# if __has_feature(experimental_library)
+# ifndef _LIBCPP_ENABLE_EXPERIMENTAL
+# define _LIBCPP_ENABLE_EXPERIMENTAL
+# endif
+# endif
-#if defined(__MVS__)
-# include <features.h> // for __NATIVE_ASCII_F
-#endif
+// Incomplete features get their own specific disabling flags. This makes it
+// easier to grep for target specific flags once the feature is complete.
+# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+# define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
+# define _LIBCPP_HAS_NO_INCOMPLETE_RANGES
+# endif
-#ifdef __LITTLE_ENDIAN__
-# if __LITTLE_ENDIAN__
-# define _LIBCPP_LITTLE_ENDIAN
-# endif // __LITTLE_ENDIAN__
-#endif // __LITTLE_ENDIAN__
+// Need to detect which libc we're using if we're on Linux.
+# if defined(__linux__)
+# include <features.h>
+# if defined(__GLIBC_PREREQ)
+# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
+# else
+# define _LIBCPP_GLIBC_PREREQ(a, b) 0
+# endif // defined(__GLIBC_PREREQ)
+# endif // defined(__linux__)
-#ifdef __BIG_ENDIAN__
-# if __BIG_ENDIAN__
-# define _LIBCPP_BIG_ENDIAN
-# endif // __BIG_ENDIAN__
-#endif // __BIG_ENDIAN__
+# if defined(__MVS__)
+# include <features.h> // for __NATIVE_ASCII_F
+# endif
-#ifdef __BYTE_ORDER__
-# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# ifdef __LITTLE_ENDIAN__
+# if __LITTLE_ENDIAN__
+# define _LIBCPP_LITTLE_ENDIAN
+# endif // __LITTLE_ENDIAN__
+# endif // __LITTLE_ENDIAN__
+
+# ifdef __BIG_ENDIAN__
+# if __BIG_ENDIAN__
+# define _LIBCPP_BIG_ENDIAN
+# endif // __BIG_ENDIAN__
+# endif // __BIG_ENDIAN__
+
+# ifdef __BYTE_ORDER__
+# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# define _LIBCPP_LITTLE_ENDIAN
+# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# define _LIBCPP_BIG_ENDIAN
+# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# endif // __BYTE_ORDER__
+
+# ifdef __FreeBSD__
+# include <sys/endian.h>
+# include <osreldate.h>
+# if _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_LITTLE_ENDIAN
+# else // _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_BIG_ENDIAN
+# endif // _BYTE_ORDER == _LITTLE_ENDIAN
+# endif // __FreeBSD__
+
+# if defined(__NetBSD__) || defined(__OpenBSD__)
+# include <sys/endian.h>
+# if _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_LITTLE_ENDIAN
+# else // _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_BIG_ENDIAN
+# endif // _BYTE_ORDER == _LITTLE_ENDIAN
+# endif // defined(__NetBSD__) || defined(__OpenBSD__)
+
+# if defined(_WIN32)
+# define _LIBCPP_WIN32API
# define _LIBCPP_LITTLE_ENDIAN
-# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-# define _LIBCPP_BIG_ENDIAN
-# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-#endif // __BYTE_ORDER__
-
-#ifdef __FreeBSD__
-# include <sys/endian.h>
-# include <osreldate.h>
-# if _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_LITTLE_ENDIAN
-# else // _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_BIG_ENDIAN
-# endif // _BYTE_ORDER == _LITTLE_ENDIAN
-#endif // __FreeBSD__
-
-#if defined(__NetBSD__) || defined(__OpenBSD__)
-# include <sys/endian.h>
-# if _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_LITTLE_ENDIAN
-# else // _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_BIG_ENDIAN
-# endif // _BYTE_ORDER == _LITTLE_ENDIAN
-#endif // defined(__NetBSD__) || defined(__OpenBSD__)
-
-#if defined(_WIN32)
-# define _LIBCPP_WIN32API
-# define _LIBCPP_LITTLE_ENDIAN
-# define _LIBCPP_SHORT_WCHAR 1
+# define _LIBCPP_SHORT_WCHAR 1
// Both MinGW and native MSVC provide a "MSVC"-like environment
-# define _LIBCPP_MSVCRT_LIKE
+# define _LIBCPP_MSVCRT_LIKE
// If mingw not explicitly detected, assume using MS C runtime only if
// a MS compatibility version is specified.
-# if defined(_MSC_VER) && !defined(__MINGW32__)
-# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
-# endif
-# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
-# define _LIBCPP_HAS_BITSCAN64
-# endif
-# define _LIBCPP_HAS_OPEN_WITH_WCHAR
-# if defined(_LIBCPP_MSVCRT)
-# define _LIBCPP_HAS_QUICK_EXIT
-# endif
+# if defined(_MSC_VER) && !defined(__MINGW32__)
+# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
+# endif
+# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
+# define _LIBCPP_HAS_BITSCAN64
+# endif
+# define _LIBCPP_HAS_OPEN_WITH_WCHAR
+# endif // defined(_WIN32)
-// Some CRT APIs are unavailable to store apps
-# if defined(WINAPI_FAMILY)
-# include <winapifamily.h>
-# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
- (!defined(WINAPI_PARTITION_SYSTEM) || \
- !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
-# define _LIBCPP_WINDOWS_STORE_APP
+# ifdef __sun__
+# include <sys/isa_defs.h>
+# ifdef _LITTLE_ENDIAN
+# define _LIBCPP_LITTLE_ENDIAN
+# else
+# define _LIBCPP_BIG_ENDIAN
# endif
-# endif
-#endif // defined(_WIN32)
+# endif // __sun__
-#ifdef __sun__
-# include <sys/isa_defs.h>
-# ifdef _LITTLE_ENDIAN
-# define _LIBCPP_LITTLE_ENDIAN
-# else
-# define _LIBCPP_BIG_ENDIAN
+# if defined(_AIX) && !defined(__64BIT__)
+// The size of wchar is 2 byte on 32-bit mode on AIX.
+# define _LIBCPP_SHORT_WCHAR 1
# endif
-#endif // __sun__
-
-#if defined(_AIX) && !defined(__64BIT__)
- // The size of wchar is 2 byte on 32-bit mode on AIX.
-# define _LIBCPP_SHORT_WCHAR 1
-#endif
// Libc++ supports various implementations of std::random_device.
//
@@ -384,806 +376,581 @@
// Use rand_s(), for use on Windows.
// When this option is used, the token passed to `std::random_device`'s
// constructor *must* be "/dev/urandom" -- anything else is an error.
-#if defined(__OpenBSD__) || defined(__APPLE__)
-# define _LIBCPP_USING_ARC4_RANDOM
-#elif defined(__wasi__)
-# define _LIBCPP_USING_GETENTROPY
-#elif defined(__Fuchsia__)
-# define _LIBCPP_USING_FUCHSIA_CPRNG
-#elif defined(__native_client__)
-# define _LIBCPP_USING_NACL_RANDOM
-#elif defined(_LIBCPP_WIN32API)
-# define _LIBCPP_USING_WIN32_RANDOM
-#else
-# define _LIBCPP_USING_DEV_RANDOM
-#endif
-
-#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
-# include <endian.h>
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# define _LIBCPP_LITTLE_ENDIAN
-# elif __BYTE_ORDER == __BIG_ENDIAN
-# define _LIBCPP_BIG_ENDIAN
-# else // __BYTE_ORDER == __BIG_ENDIAN
-# error unable to determine endian
+# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
+ defined(__DragonFly__) || defined(__sun__)
+# define _LIBCPP_USING_ARC4_RANDOM
+# elif defined(__wasi__) || defined(__EMSCRIPTEN__)
+# define _LIBCPP_USING_GETENTROPY
+# elif defined(__Fuchsia__)
+# define _LIBCPP_USING_FUCHSIA_CPRNG
+# elif defined(__native_client__)
+# define _LIBCPP_USING_NACL_RANDOM
+# elif defined(_LIBCPP_WIN32API)
+# define _LIBCPP_USING_WIN32_RANDOM
+# else
+# define _LIBCPP_USING_DEV_RANDOM
# endif
-#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
-#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
-# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
-#else
-# define _LIBCPP_NO_CFI
-#endif
-
-// If the compiler supports using_if_exists, pretend we have those functions and they'll
-// be picked up if the C library provides them.
-//
-// TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists
-// for platforms that don't have a conforming C11 library, so we can drop this whole thing.
-#if __has_attribute(using_if_exists)
-# define _LIBCPP_HAS_TIMESPEC_GET
-# define _LIBCPP_HAS_QUICK_EXIT
-# define _LIBCPP_HAS_ALIGNED_ALLOC
-#else
-#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L
-# if defined(__FreeBSD__)
-# define _LIBCPP_HAS_ALIGNED_ALLOC
-# define _LIBCPP_HAS_QUICK_EXIT
-# if __FreeBSD_version >= 1300064 || \
- (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
-# define _LIBCPP_HAS_TIMESPEC_GET
-# endif
-# elif defined(__BIONIC__)
-# 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
-# elif defined(__OpenBSD__)
-# define _LIBCPP_HAS_ALIGNED_ALLOC
-# define _LIBCPP_HAS_TIMESPEC_GET
-# elif defined(__linux__)
-# if !defined(_LIBCPP_HAS_MUSL_LIBC)
-# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
-# define _LIBCPP_HAS_QUICK_EXIT
-# endif
-# if _LIBCPP_GLIBC_PREREQ(2, 17)
-# define _LIBCPP_HAS_ALIGNED_ALLOC
-# 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
-# endif
-# elif defined(_LIBCPP_MSVCRT)
- // Using Microsoft's C Runtime library, not MinGW
-# define _LIBCPP_HAS_TIMESPEC_GET
-# elif defined(__APPLE__)
- // timespec_get and aligned_alloc were introduced in macOS 10.15 and
- // aligned releases
-# if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \
- (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
- (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
- (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000))
-# define _LIBCPP_HAS_ALIGNED_ALLOC
-# define _LIBCPP_HAS_TIMESPEC_GET
+# if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
+# include <endian.h>
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define _LIBCPP_LITTLE_ENDIAN
+# elif __BYTE_ORDER == __BIG_ENDIAN
+# define _LIBCPP_BIG_ENDIAN
+# else // __BYTE_ORDER == __BIG_ENDIAN
+# error unable to determine endian
# endif
-# endif // __APPLE__
-#endif
-#endif // __has_attribute(using_if_exists)
-
-#ifndef _LIBCPP_CXX03_LANG
-# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
-#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
-# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
-#else
-# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
-#endif
+# endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
-#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
+# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
+# else
+# define _LIBCPP_NO_CFI
+# endif
-#if defined(_LIBCPP_COMPILER_CLANG_BASED)
+# ifndef _LIBCPP_CXX03_LANG
-#if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
-# error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead
-#endif
-#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
- (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
-# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
-#endif
+# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
+# define _ALIGNAS_TYPE(x) alignas(x)
+# define _ALIGNAS(x) alignas(x)
+# define _LIBCPP_NORETURN [[noreturn]]
+# define _NOEXCEPT noexcept
+# define _NOEXCEPT_(x) noexcept(x)
-#if __has_feature(cxx_alignas)
-# define _ALIGNAS_TYPE(x) alignas(x)
-# define _ALIGNAS(x) alignas(x)
-#else
-# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
-# define _ALIGNAS(x) __attribute__((__aligned__(x)))
-#endif
+# else
+
+# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
+# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
+# define _ALIGNAS(x) __attribute__((__aligned__(x)))
+# define _LIBCPP_NORETURN __attribute__((noreturn))
+# define _LIBCPP_HAS_NO_NOEXCEPT
+# define nullptr __nullptr
+# define _NOEXCEPT throw()
+# define _NOEXCEPT_(x)
-#if __cplusplus < 201103L
typedef __char16_t char16_t;
typedef __char32_t char32_t;
-#endif
-
-#if !__has_feature(cxx_exceptions)
-# define _LIBCPP_NO_EXCEPTIONS
-#endif
-#if !(__has_feature(cxx_strong_enums))
-#define _LIBCPP_HAS_NO_STRONG_ENUMS
-#endif
-
-#if __has_feature(cxx_attributes)
-# define _LIBCPP_NORETURN [[noreturn]]
-#else
-# define _LIBCPP_NORETURN __attribute__ ((noreturn))
-#endif
-
-#if !(__has_feature(cxx_nullptr))
-# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
-# define nullptr __nullptr
-# else
-# define _LIBCPP_HAS_NO_NULLPTR
# endif
-#endif
-
-// Objective-C++ features (opt-in)
-#if __has_feature(objc_arc)
-#define _LIBCPP_HAS_OBJC_ARC
-#endif
-
-#if __has_feature(objc_arc_weak)
-#define _LIBCPP_HAS_OBJC_ARC_WEAK
-#endif
-
-#if __has_extension(blocks)
-# define _LIBCPP_HAS_EXTENSION_BLOCKS
-#endif
-#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
-# define _LIBCPP_HAS_BLOCKS_RUNTIME
-#endif
+# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
+# define _LIBCPP_NO_EXCEPTIONS
+# endif
-#if !(__has_feature(cxx_noexcept))
-#define _LIBCPP_HAS_NO_NOEXCEPT
-#endif
+# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
-#if !__has_feature(address_sanitizer)
-#define _LIBCPP_HAS_NO_ASAN
-#endif
+# if defined(_LIBCPP_COMPILER_CLANG_BASED)
-// Allow for build-time disabling of unsigned integer sanitization
-#if __has_attribute(no_sanitize)
-#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
-#endif
-
-#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+# if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
+# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+# endif
-#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
+// Objective-C++ features (opt-in)
+# if __has_feature(objc_arc)
+# define _LIBCPP_HAS_OBJC_ARC
+# endif
-#elif defined(_LIBCPP_COMPILER_GCC)
+# if __has_feature(objc_arc_weak)
+# define _LIBCPP_HAS_OBJC_ARC_WEAK
+# endif
-#define _ALIGNAS(x) __attribute__((__aligned__(x)))
-#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
+# if __has_extension(blocks)
+# define _LIBCPP_HAS_EXTENSION_BLOCKS
+# endif
-#define _LIBCPP_NORETURN __attribute__((noreturn))
+# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
+# define _LIBCPP_HAS_BLOCKS_RUNTIME
+# endif
-#if !defined(__EXCEPTIONS)
-# define _LIBCPP_NO_EXCEPTIONS
-#endif
+# if !__has_feature(address_sanitizer)
+# define _LIBCPP_HAS_NO_ASAN
+# endif
-#if !defined(__SANITIZE_ADDRESS__)
-#define _LIBCPP_HAS_NO_ASAN
-#endif
+// Allow for build-time disabling of unsigned integer sanitization
+# if __has_attribute(no_sanitize)
+# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
+# endif
-#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
-#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
+# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
-#elif defined(_LIBCPP_COMPILER_MSVC)
+# elif defined(_LIBCPP_COMPILER_GCC)
-#define _LIBCPP_TOSTRING2(x) #x
-#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
-#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
+# if !defined(__SANITIZE_ADDRESS__)
+# define _LIBCPP_HAS_NO_ASAN
+# endif
-#if _MSC_VER < 1900
-#error "MSVC versions prior to Visual Studio 2015 are not supported"
-#endif
+# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
-#define __alignof__ __alignof
-#define _LIBCPP_NORETURN __declspec(noreturn)
-#define _ALIGNAS(x) __declspec(align(x))
-#define _ALIGNAS_TYPE(x) alignas(x)
+# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
-#define _LIBCPP_WEAK
+# elif defined(_LIBCPP_COMPILER_MSVC)
-#define _LIBCPP_HAS_NO_ASAN
+# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
-#define _LIBCPP_ALWAYS_INLINE __forceinline
+# if _MSC_VER < 1900
+# error "MSVC versions prior to Visual Studio 2015 are not supported"
+# endif
-#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+# define _LIBCPP_NORETURN __declspec(noreturn)
-#define _LIBCPP_DISABLE_EXTENSION_WARNING
+# define _LIBCPP_WEAK
-#elif defined(_LIBCPP_COMPILER_IBM)
+# define _LIBCPP_HAS_NO_ASAN
-#define _ALIGNAS(x) __attribute__((__aligned__(x)))
-#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
-#define _ATTRIBUTE(x) __attribute__((x))
-#define _LIBCPP_NORETURN __attribute__((noreturn))
+# define _LIBCPP_ALWAYS_INLINE __forceinline
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
+# define _LIBCPP_HAS_NO_VECTOR_EXTENSION
-#if defined(_AIX)
-#define __MULTILOCALE_API
-#endif
+# define _LIBCPP_DISABLE_EXTENSION_WARNING
-#define _LIBCPP_HAS_NO_ASAN
+# endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC]
-#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
-#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+# ifdef _DLL
+# define _LIBCPP_CRT_FUNC __declspec(dllimport)
+# else
+# define _LIBCPP_CRT_FUNC
+# endif
-#define _LIBCPP_DISABLE_EXTENSION_WARNING
+# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
+# define _LIBCPP_DLL_VIS
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_EXPORTED_FROM_ABI
+# elif defined(_LIBCPP_BUILDING_LIBRARY)
+# define _LIBCPP_DLL_VIS __declspec(dllexport)
+# if defined(__MINGW32__)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# else
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
+# endif
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
+# else
+# define _LIBCPP_DLL_VIS __declspec(dllimport)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
+# endif
-#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
+# define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
+# define _LIBCPP_HIDDEN
+# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+# define _LIBCPP_TEMPLATE_VIS
+# define _LIBCPP_TEMPLATE_DATA_VIS
+# define _LIBCPP_ENUM_VIS
-#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
+# else
-#ifdef _DLL
-# define _LIBCPP_CRT_FUNC __declspec(dllimport)
-#else
-# define _LIBCPP_CRT_FUNC
-#endif
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
+# else
+# define _LIBCPP_VISIBILITY(vis)
+# endif
-#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_DLL_VIS
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS
-# define _LIBCPP_EXPORTED_FROM_ABI
-#elif defined(_LIBCPP_BUILDING_LIBRARY)
-# define _LIBCPP_DLL_VIS __declspec(dllexport)
-# if defined(__MINGW32__)
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
+# define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default")
+# define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default")
+# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
+# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
+# define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default")
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-# else
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
-# endif
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
-# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
-#else
-# define _LIBCPP_DLL_VIS __declspec(dllimport)
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-# define _LIBCPP_OVERRIDABLE_FUNC_VIS
-# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
-#endif
-#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
-#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
-#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
-#define _LIBCPP_HIDDEN
-#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
-#define _LIBCPP_TEMPLATE_VIS
-#define _LIBCPP_TEMPLATE_DATA_VIS
-#define _LIBCPP_ENUM_VIS
+// TODO: Make this a proper customization point or remove the option to override it.
+# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
+# endif
-#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+// The inline should be removed once PR32114 is resolved
+# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
+# else
+# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+# endif
-#ifndef _LIBCPP_HIDDEN
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
-# else
-# define _LIBCPP_HIDDEN
-# endif
-#endif
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# if __has_attribute(__type_visibility__)
+# define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default")))
+# else
+# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
+# endif
+# else
+# define _LIBCPP_TEMPLATE_VIS
+# endif
-#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-// The inline should be removed once PR32114 is resolved
-# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
-# else
-# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
-# endif
-#endif
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
+# define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default")))
+# else
+# define _LIBCPP_ENUM_VIS
+# endif
+
+# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
-#ifndef _LIBCPP_FUNC_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
+# if __has_attribute(exclude_from_explicit_instantiation)
+# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
# else
-# define _LIBCPP_FUNC_VIS
+// Try to approximate the effect of exclude_from_explicit_instantiation
+// (which is that entities are not assumed to be provided by explicit
+// template instantiations in the dylib) by always inlining those entities.
+# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
# endif
-#endif
-#ifndef _LIBCPP_TYPE_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
+// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
+// on two levels:
+// 1. The symbol is given hidden visibility, which ensures that users won't start exporting
+// symbols from their dynamic library by means of using the libc++ headers. This ensures
+// that those symbols stay private to the dynamic library in which it is defined.
+//
+// 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures
+// that no ODR violation can arise from mixing two TUs compiled with different versions
+// of libc++ where we would have changed the definition of a symbol. If the symbols shared
+// the same name, the ODR would require that their definitions be token-by-token equivalent,
+// which basically prevents us from being able to make any change to any function in our
+// headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at
+// each release, which lets us change the definition of these symbols at our leisure.
+// Note that historically, this has been achieved in various ways, including force-inlining
+// all functions or giving internal linkage to all functions. Both these (previous) solutions
+// suffer from drawbacks that lead notably to code bloat.
+//
+// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
+// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
+//
+// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
+// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
+// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
+# ifndef _LIBCPP_NO_ABI_TAG
+# define _LIBCPP_HIDE_FROM_ABI \
+ _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
+ __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER))))
# else
-# define _LIBCPP_TYPE_VIS
+# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
# endif
-#endif
-#ifndef _LIBCPP_TEMPLATE_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# if __has_attribute(__type_visibility__)
-# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
+# ifdef _LIBCPP_BUILDING_LIBRARY
+# if _LIBCPP_ABI_VERSION > 1
+# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
# else
-# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
+# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
# endif
# else
-# define _LIBCPP_TEMPLATE_VIS
+# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
# endif
-#endif
-#ifndef _LIBCPP_TEMPLATE_DATA_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default")))
-# else
-# define _LIBCPP_TEMPLATE_DATA_VIS
-# endif
-#endif
+// Just so we can migrate to the new macros gradually.
+# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
-#ifndef _LIBCPP_EXPORTED_FROM_ABI
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
-# else
-# define _LIBCPP_EXPORTED_FROM_ABI
-# endif
-#endif
+// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
+// clang-format off
+# define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
+# define _LIBCPP_END_NAMESPACE_STD }}
+# define _VSTD std
-#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
-#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
-#endif
+_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
-#ifndef _LIBCPP_EXCEPTION_ABI
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
+# if _LIBCPP_STD_VER > 14
+# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
+ _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
# else
-# define _LIBCPP_EXCEPTION_ABI
+# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
+ _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
# endif
-#endif
-#ifndef _LIBCPP_ENUM_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
-# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
-# else
-# define _LIBCPP_ENUM_VIS
-# endif
-#endif
+# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
+// clang-format on
-#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
-# else
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# endif
-#endif
+# define _VSTD_FS std::__fs::filesystem
-#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-#endif
+# if __has_attribute(__enable_if__)
+# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
+# endif
-#if __has_attribute(internal_linkage)
-# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
-#else
-# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
-#endif
+# ifndef __SIZEOF_INT128__
+# define _LIBCPP_HAS_NO_INT128
+# endif
-#if __has_attribute(exclude_from_explicit_instantiation)
-# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
-#else
- // Try to approximate the effect of exclude_from_explicit_instantiation
- // (which is that entities are not assumed to be provided by explicit
- // template instantiations in the dylib) by always inlining those entities.
-# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
-#endif
+# ifdef _LIBCPP_CXX03_LANG
+# define static_assert(...) _Static_assert(__VA_ARGS__)
+# define decltype(...) __decltype(__VA_ARGS__)
+# endif // _LIBCPP_CXX03_LANG
-#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
-# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
-# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
+# ifdef _LIBCPP_CXX03_LANG
+# define _LIBCPP_CONSTEXPR
# else
-# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
+# define _LIBCPP_CONSTEXPR constexpr
# endif
-#endif
-#ifndef _LIBCPP_HIDE_FROM_ABI
-# if _LIBCPP_HIDE_FROM_ABI_PER_TU
-# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+# ifndef __cpp_consteval
+# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
# else
-# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
+# define _LIBCPP_CONSTEVAL consteval
# endif
-#endif
-#ifdef _LIBCPP_BUILDING_LIBRARY
-# if _LIBCPP_ABI_VERSION > 1
-# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
+# ifdef __GNUC__
+# define _LIBCPP_NOALIAS __attribute__((__malloc__))
# else
-# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+# define _LIBCPP_NOALIAS
# endif
-#else
-# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
-#endif
-
-// Just so we can migrate to the new macros gradually.
-#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
-
-// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
-#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
-#define _LIBCPP_END_NAMESPACE_STD } }
-#define _VSTD std
-_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
-
-#if _LIBCPP_STD_VER > 14
-#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
- _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
-#else
-#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
- _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
-#endif
-
-#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
- _LIBCPP_END_NAMESPACE_STD } }
-
-#define _VSTD_FS _VSTD::__fs::filesystem
-
-#if __has_attribute(__enable_if__)
-# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
-#endif
-
-#ifndef _LIBCPP_HAS_NO_NOEXCEPT
-# define _NOEXCEPT noexcept
-# define _NOEXCEPT_(x) noexcept(x)
-#else
-# define _NOEXCEPT throw()
-# define _NOEXCEPT_(x)
-#endif
-
-#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
-typedef unsigned short char16_t;
-typedef unsigned int char32_t;
-#endif
-
-#ifndef __SIZEOF_INT128__
-#define _LIBCPP_HAS_NO_INT128
-#endif
-#ifdef _LIBCPP_CXX03_LANG
-# define static_assert(...) _Static_assert(__VA_ARGS__)
-# define decltype(...) __decltype(__VA_ARGS__)
-#endif // _LIBCPP_CXX03_LANG
-
-#ifdef _LIBCPP_CXX03_LANG
-# define _LIBCPP_CONSTEXPR
-#else
-# define _LIBCPP_CONSTEXPR constexpr
-#endif
-
-#ifndef __cpp_consteval
-# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
-#else
-# define _LIBCPP_CONSTEVAL consteval
-#endif
-
-#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L
-#define _LIBCPP_HAS_NO_CONCEPTS
-#endif
-
-#ifdef __GNUC__
-# define _LIBCPP_NOALIAS __attribute__((__malloc__))
-#else
-# define _LIBCPP_NOALIAS
-#endif
-
-#if __has_attribute(using_if_exists)
-# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
-#else
-# define _LIBCPP_USING_IF_EXISTS
-#endif
-
-#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
-# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
-# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
- __lx __v_; \
- _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
- _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
- _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
- };
-#else // _LIBCPP_HAS_NO_STRONG_ENUMS
-# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
-# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
-#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
-
-// _LIBCPP_DEBUG potential values:
-// - undefined: No assertions. This is the default.
-// - 0: Basic assertions
-// - 1: Basic assertions + iterator validity checks + unspecified behavior randomization.
-# if !defined(_LIBCPP_DEBUG)
-# define _LIBCPP_DEBUG_LEVEL 0
-# elif _LIBCPP_DEBUG == 0
-# define _LIBCPP_DEBUG_LEVEL 1
-# elif _LIBCPP_DEBUG == 1
-# define _LIBCPP_DEBUG_LEVEL 2
+# if __has_attribute(using_if_exists)
+# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
# else
-# error Supported values for _LIBCPP_DEBUG are 0 and 1
+# define _LIBCPP_USING_IF_EXISTS
# endif
-# if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG)
-# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
+# ifdef _LIBCPP_CXX03_LANG
+# define _LIBCPP_DECLARE_STRONG_ENUM(x) \
+ struct _LIBCPP_TYPE_VIS x { \
+ enum __lx
+// clang-format off
+# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
+ __lx __v_; \
+ _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
+ _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
+ _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \
+ };
+// clang-format on
+
+# else // _LIBCPP_CXX03_LANG
+# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
+# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
+# endif // _LIBCPP_CXX03_LANG
+
+# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \
+ defined(__NetBSD__)
+# define _LIBCPP_LOCALE__L_EXTENSIONS 1
# endif
-# if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
-# if defined(_LIBCPP_CXX03_LANG)
-# error Support for unspecified stability is only for C++11 and higher
-# endif
-# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
- do { \
- if (!__builtin_is_constant_evaluated()) \
- _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \
- } while (false)
-# else
-# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
- do { \
- } while (false)
+# ifdef __FreeBSD__
+# define _DECLARE_C99_LDBL_MATH 1
# endif
-// Libc++ allows disabling extern template instantiation declarations by
-// means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
-//
-// Furthermore, when the Debug mode is enabled, we disable extern declarations
-// when building user code because we don't want to use the functions compiled
-// in the library, which might not have had the debug mode enabled when built.
-// However, some extern declarations need to be used, because code correctness
-// depends on it (several instances in <locale>). Those special declarations
-// are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled
-// even when the debug mode is enabled.
-#if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
-# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
-# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */
-#elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY)
-# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
-# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
-#else
-# define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
-# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
-#endif
-
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
- defined(__sun__) || defined(__NetBSD__)
-#define _LIBCPP_LOCALE__L_EXTENSIONS 1
-#endif
-
-#ifdef __FreeBSD__
-#define _DECLARE_C99_LDBL_MATH 1
-#endif
-
// If we are getting operator new from the MSVC CRT, then allocation overloads
// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
-#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
-# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
-#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
- // We're deferring to Microsoft's STL to provide aligned new et al. We don't
- // have it unless the language feature test macro is defined.
-# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
-#elif defined(__MVS__)
-# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
-#endif
+# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
+// We're deferring to Microsoft's STL to provide aligned new et al. We don't
+// have it unless the language feature test macro is defined.
+# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+# elif defined(__MVS__)
+# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
+# endif
-#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
- (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
-# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-#endif
+# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
+# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+# endif
-#if defined(__APPLE__) || defined(__FreeBSD__)
-#define _LIBCPP_HAS_DEFAULTRUNELOCALE
-#endif
+# if defined(__APPLE__) || defined(__FreeBSD__)
+# define _LIBCPP_HAS_DEFAULTRUNELOCALE
+# endif
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
-#define _LIBCPP_WCTYPE_IS_MASK
-#endif
+# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
+# define _LIBCPP_WCTYPE_IS_MASK
+# endif
-#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
-#define _LIBCPP_HAS_NO_CHAR8_T
-#endif
+# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
+# define _LIBCPP_HAS_NO_CHAR8_T
+# endif
// Deprecation macros.
//
// Deprecations warnings are always enabled, except when users explicitly opt-out
// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
-#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
-# if __has_attribute(deprecated)
-# define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
-# elif _LIBCPP_STD_VER > 11
-# define _LIBCPP_DEPRECATED [[deprecated]]
+# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# if __has_attribute(deprecated)
+# define _LIBCPP_DEPRECATED __attribute__((deprecated))
+# define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m)))
+# elif _LIBCPP_STD_VER > 11
+# define _LIBCPP_DEPRECATED [[deprecated]]
+# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
+# else
+# define _LIBCPP_DEPRECATED
+# define _LIBCPP_DEPRECATED_(m)
+# endif
# else
# define _LIBCPP_DEPRECATED
+# define _LIBCPP_DEPRECATED_(m)
# endif
-#else
-# define _LIBCPP_DEPRECATED
-#endif
-#if !defined(_LIBCPP_CXX03_LANG)
-# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
-#else
-# define _LIBCPP_DEPRECATED_IN_CXX11
-#endif
+# if !defined(_LIBCPP_CXX03_LANG)
+# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
+# else
+# define _LIBCPP_DEPRECATED_IN_CXX11
+# endif
-#if _LIBCPP_STD_VER >= 14
-# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
-#else
-# define _LIBCPP_DEPRECATED_IN_CXX14
-#endif
+# if _LIBCPP_STD_VER > 11
+# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
+# else
+# define _LIBCPP_DEPRECATED_IN_CXX14
+# endif
-#if _LIBCPP_STD_VER >= 17
-# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
-#else
-# define _LIBCPP_DEPRECATED_IN_CXX17
-#endif
+# if _LIBCPP_STD_VER > 14
+# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
+# else
+# define _LIBCPP_DEPRECATED_IN_CXX17
+# endif
-#if _LIBCPP_STD_VER > 17
-# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
-#else
-# define _LIBCPP_DEPRECATED_IN_CXX20
-#endif
+# if _LIBCPP_STD_VER > 17
+# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
+# else
+# define _LIBCPP_DEPRECATED_IN_CXX20
+# endif
-#if !defined(_LIBCPP_HAS_NO_CHAR8_T)
-# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
-#else
-# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
-#endif
+# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
+# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
+# else
+# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
+# endif
// Macros to enter and leave a state where deprecation warnings are suppressed.
-#if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
-# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
- _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
-# define _LIBCPP_SUPPRESS_DEPRECATED_POP \
- _Pragma("GCC diagnostic pop")
-#else
-# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
-# define _LIBCPP_SUPPRESS_DEPRECATED_POP
-#endif
+# if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
+ _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
+# else
+# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+# define _LIBCPP_SUPPRESS_DEPRECATED_POP
+# endif
-#if _LIBCPP_STD_VER <= 11
-# define _LIBCPP_EXPLICIT_AFTER_CXX11
-#else
-# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
-#endif
+# if _LIBCPP_STD_VER <= 11
+# define _LIBCPP_EXPLICIT_AFTER_CXX11
+# else
+# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
+# endif
-#if _LIBCPP_STD_VER > 11
-# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
-#else
-# define _LIBCPP_CONSTEXPR_AFTER_CXX11
-#endif
+# if _LIBCPP_STD_VER > 11
+# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
+# else
+# define _LIBCPP_CONSTEXPR_AFTER_CXX11
+# endif
-#if _LIBCPP_STD_VER > 14
-# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
-#else
-# define _LIBCPP_CONSTEXPR_AFTER_CXX14
-#endif
+# if _LIBCPP_STD_VER > 14
+# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
+# else
+# define _LIBCPP_CONSTEXPR_AFTER_CXX14
+# endif
-#if _LIBCPP_STD_VER > 17
-# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
-#else
-# define _LIBCPP_CONSTEXPR_AFTER_CXX17
-#endif
+# if _LIBCPP_STD_VER > 17
+# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
+# else
+# define _LIBCPP_CONSTEXPR_AFTER_CXX17
+# endif
-#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
-# define _LIBCPP_NODISCARD [[nodiscard]]
-#elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
-# define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
-#else
+# if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
+# define _LIBCPP_NODISCARD [[nodiscard]]
+# elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
+# define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
+# else
// We can't use GCC's [[gnu::warn_unused_result]] and
// __attribute__((warn_unused_result)), because GCC does not silence them via
// (void) cast.
-# define _LIBCPP_NODISCARD
-#endif
+# define _LIBCPP_NODISCARD
+# endif
// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
// specified as such as an extension.
-#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
-# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
-#else
-# define _LIBCPP_NODISCARD_EXT
-#endif
+# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
+# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
+# else
+# define _LIBCPP_NODISCARD_EXT
+# endif
-#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
- (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
-# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
-#else
-# define _LIBCPP_NODISCARD_AFTER_CXX17
-#endif
+# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
+# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
+# else
+# define _LIBCPP_NODISCARD_AFTER_CXX17
+# endif
-#if __has_attribute(no_destroy)
-# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
-#else
-# define _LIBCPP_NO_DESTROY
-#endif
+# if __has_attribute(no_destroy)
+# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
+# else
+# define _LIBCPP_NO_DESTROY
+# endif
-#ifndef _LIBCPP_HAS_NO_ASAN
-extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
- const void *, const void *, const void *, const void *);
-#endif
+# ifndef _LIBCPP_HAS_NO_ASAN
+ extern "C" _LIBCPP_FUNC_VIS void
+ __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
+# endif
// Try to find out if RTTI is disabled.
-#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)
-# define _LIBCPP_NO_RTTI
-#elif defined(__GNUC__) && !defined(__GXX_RTTI)
-# define _LIBCPP_NO_RTTI
-#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
-# define _LIBCPP_NO_RTTI
-#endif
+# if !defined(__cpp_rtti) || __cpp_rtti < 199711L
+# define _LIBCPP_NO_RTTI
+# endif
-#ifndef _LIBCPP_WEAK
-#define _LIBCPP_WEAK __attribute__((__weak__))
-#endif
+# ifndef _LIBCPP_WEAK
+# define _LIBCPP_WEAK __attribute__((__weak__))
+# endif
// Thread API
-#if !defined(_LIBCPP_HAS_NO_THREADS) && \
- !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
- !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
- !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-# if defined(__FreeBSD__) || \
- defined(__wasi__) || \
- defined(__NetBSD__) || \
- defined(__OpenBSD__) || \
- defined(__NuttX__) || \
- defined(__linux__) || \
- defined(__GNU__) || \
- defined(__APPLE__) || \
- defined(__sun__) || \
- defined(__MVS__) || \
- defined(_AIX)
-# define _LIBCPP_HAS_THREAD_API_PTHREAD
-# elif defined(__Fuchsia__)
- // TODO(44575): Switch to C11 thread API when possible.
-# define _LIBCPP_HAS_THREAD_API_PTHREAD
-# elif defined(_LIBCPP_WIN32API)
-# define _LIBCPP_HAS_THREAD_API_WIN32
-# else
-# error "No thread API"
-# endif // _LIBCPP_HAS_THREAD_API
-#endif // _LIBCPP_HAS_NO_THREADS
-
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
-#if defined(__ANDROID__) && __ANDROID_API__ >= 30
-#define _LIBCPP_HAS_COND_CLOCKWAIT
-#elif defined(_LIBCPP_GLIBC_PREREQ)
-#if _LIBCPP_GLIBC_PREREQ(2, 30)
-#define _LIBCPP_HAS_COND_CLOCKWAIT
-#endif
-#endif
-#endif
+// clang-format off
+# if !defined(_LIBCPP_HAS_NO_THREADS) && \
+ !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
+ !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
+ !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+# if defined(__FreeBSD__) || \
+ defined(__wasi__) || \
+ defined(__NetBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__NuttX__) || \
+ defined(__linux__) || \
+ defined(__GNU__) || \
+ defined(__APPLE__) || \
+ defined(__sun__) || \
+ defined(__MVS__) || \
+ defined(_AIX) || \
+ defined(__EMSCRIPTEN__)
+// clang-format on
+# define _LIBCPP_HAS_THREAD_API_PTHREAD
+# elif defined(__Fuchsia__)
+// TODO(44575): Switch to C11 thread API when possible.
+# define _LIBCPP_HAS_THREAD_API_PTHREAD
+# elif defined(_LIBCPP_WIN32API)
+# define _LIBCPP_HAS_THREAD_API_WIN32
+# else
+# error "No thread API"
+# endif // _LIBCPP_HAS_THREAD_API
+# endif // _LIBCPP_HAS_NO_THREADS
+
+# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+# if defined(__ANDROID__) && __ANDROID_API__ >= 30
+# define _LIBCPP_HAS_COND_CLOCKWAIT
+# elif defined(_LIBCPP_GLIBC_PREREQ)
+# if _LIBCPP_GLIBC_PREREQ(2, 30)
+# define _LIBCPP_HAS_COND_CLOCKWAIT
+# endif
+# endif
+# endif
-#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
-#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
+# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
_LIBCPP_HAS_NO_THREADS is not defined.
-#endif
+# endif
-#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
+# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+# error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
_LIBCPP_HAS_NO_THREADS is defined.
-#endif
+# endif
-#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
-#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
+# if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
+# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
_LIBCPP_HAS_NO_THREADS is defined.
-#endif
+# endif
-#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
-#define __STDCPP_THREADS__ 1
-#endif
+# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
+# define __STDCPP_THREADS__ 1
+# endif
// The glibc and Bionic implementation of pthreads implements
// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
@@ -1195,11 +962,13 @@ extern "C" _LIBCPP_FUNC_VIS 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
+// clang-format off
+# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \
+ (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
+ defined(_LIBCPP_HAS_THREAD_API_WIN32)
+// clang-format on
+# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
+# endif
// Destroying a condvar is a nop on Windows.
//
@@ -1209,225 +978,245 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
//
// TODO(EricWF): This is potentially true for some pthread implementations
// as well.
-#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
- defined(_LIBCPP_HAS_THREAD_API_WIN32)
-# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
-#endif
+# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)
+# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
+# endif
// Some systems do not provide gets() in their C library, for security reasons.
-#if defined(_LIBCPP_MSVCRT) || \
- (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
- defined(__OpenBSD__)
-# define _LIBCPP_C_HAS_NO_GETS
-#endif
-
-#if defined(__BIONIC__) || defined(__NuttX__) || \
- defined(__Fuchsia__) || defined(__wasi__) || \
- defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
-#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
-#endif
+# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__)
+# define _LIBCPP_C_HAS_NO_GETS
+# endif
-#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
-# define _LIBCPP_HAS_C_ATOMIC_IMP
-#elif defined(_LIBCPP_COMPILER_GCC)
-# define _LIBCPP_HAS_GCC_ATOMIC_IMP
-#endif
+# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
+ defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
+# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+# endif
-#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
- !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
- !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
-# define _LIBCPP_HAS_NO_ATOMIC_HEADER
-#else
-# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
-# define _LIBCPP_ATOMIC_FLAG_TYPE bool
+# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
+# define _LIBCPP_HAS_C_ATOMIC_IMP
+# elif defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_HAS_GCC_ATOMIC_IMP
# endif
-# ifdef _LIBCPP_FREESTANDING
-# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
+
+# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
+ !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
+# define _LIBCPP_HAS_NO_ATOMIC_HEADER
+# else
+# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
+# define _LIBCPP_ATOMIC_FLAG_TYPE bool
+# endif
+# ifdef _LIBCPP_FREESTANDING
+# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
+# endif
# endif
-#endif
-#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
-#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
-#endif
+# ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+# endif
-#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
-# if defined(__clang__) && __has_attribute(acquire_capability)
+# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
+# if defined(__clang__) && __has_attribute(acquire_capability)
// Work around the attribute handling in clang. When both __declspec and
// __attribute__ are present, the processing goes awry preventing the definition
// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
// combining the two does work.
-# if !defined(_MSC_VER)
-# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+# if !defined(_MSC_VER)
+# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+# endif
# endif
# endif
-#endif
-#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
-# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
-#else
-# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
-#endif
+# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+# else
+# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+# endif
-#if __has_attribute(require_constant_initialization)
-# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
-#else
-# define _LIBCPP_SAFE_STATIC
-#endif
+# if _LIBCPP_STD_VER > 17
+# define _LIBCPP_CONSTINIT constinit
+# elif __has_attribute(require_constant_initialization)
+# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
+# else
+# define _LIBCPP_CONSTINIT
+# endif
-#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
-# define _LIBCPP_DIAGNOSE_WARNING(...) \
- __attribute__((diagnose_if(__VA_ARGS__, "warning")))
-# define _LIBCPP_DIAGNOSE_ERROR(...) \
- __attribute__((diagnose_if(__VA_ARGS__, "error")))
-#else
-# define _LIBCPP_DIAGNOSE_WARNING(...)
-# define _LIBCPP_DIAGNOSE_ERROR(...)
-#endif
+# if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
+# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning")))
+# define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error")))
+# else
+# define _LIBCPP_DIAGNOSE_WARNING(...)
+# define _LIBCPP_DIAGNOSE_ERROR(...)
+# endif
// Use a function like macro to imply that it must be followed by a semicolon
-#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
-# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
-#elif __has_cpp_attribute(clang::fallthrough)
-# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
-#elif __has_attribute(__fallthrough__)
-# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
-#else
-# define _LIBCPP_FALLTHROUGH() ((void)0)
-#endif
+# if __has_cpp_attribute(fallthrough)
+# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
+# elif __has_attribute(__fallthrough__)
+# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
+# else
+# define _LIBCPP_FALLTHROUGH() ((void)0)
+# endif
-#if __has_attribute(__nodebug__)
-#define _LIBCPP_NODEBUG __attribute__((__nodebug__))
-#else
-#define _LIBCPP_NODEBUG
-#endif
+# if __has_attribute(__nodebug__)
+# define _LIBCPP_NODEBUG __attribute__((__nodebug__))
+# else
+# define _LIBCPP_NODEBUG
+# endif
-#if __has_attribute(__standalone_debug__)
-#define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
-#else
-#define _LIBCPP_STANDALONE_DEBUG
-#endif
+# if __has_attribute(__standalone_debug__)
+# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
+# else
+# define _LIBCPP_STANDALONE_DEBUG
+# endif
-#if __has_attribute(__preferred_name__)
-#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
-#else
-#define _LIBCPP_PREFERRED_NAME(x)
-#endif
+# if __has_attribute(__preferred_name__)
+# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
+# else
+# define _LIBCPP_PREFERRED_NAME(x)
+# endif
// We often repeat things just for handling wide characters in the library.
// When wide characters are disabled, it can be useful to have a quick way of
// disabling it without having to resort to #if-#endif, which has a larger
// impact on readability.
-#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
-# define _LIBCPP_IF_WIDE_CHARACTERS(...)
-#else
-# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
-#endif
-
-#if defined(_LIBCPP_ABI_MICROSOFT) && \
- (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
-# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
-#else
-# define _LIBCPP_DECLSPEC_EMPTY_BASES
-#endif
-
-#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
-#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
-#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
-#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
-#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
-
-#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
-#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
-#define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
-#define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
-#define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
-#define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
-#endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
-
-#if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
-#define _LIBCPP_HAS_NO_CXX20_COROUTINES
-#endif
-
-#if defined(_LIBCPP_COMPILER_IBM)
-#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
-#endif
+# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+# define _LIBCPP_IF_WIDE_CHARACTERS(...)
+# else
+# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
+# endif
-#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
-# define _LIBCPP_PUSH_MACROS
-# define _LIBCPP_POP_MACROS
-#else
- // Don't warn about macro conflicts when we can restore them at the
- // end of the header.
-# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
-# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
-# endif
-# if defined(_LIBCPP_COMPILER_MSVC)
-# define _LIBCPP_PUSH_MACROS \
- __pragma(push_macro("min")) \
- __pragma(push_macro("max"))
-# define _LIBCPP_POP_MACROS \
- __pragma(pop_macro("min")) \
- __pragma(pop_macro("max"))
+# if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
+# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
# else
-# define _LIBCPP_PUSH_MACROS \
- _Pragma("push_macro(\"min\")") \
- _Pragma("push_macro(\"max\")")
-# define _LIBCPP_POP_MACROS \
- _Pragma("pop_macro(\"min\")") \
- _Pragma("pop_macro(\"max\")")
+# define _LIBCPP_DECLSPEC_EMPTY_BASES
# endif
-#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
-#ifndef _LIBCPP_NO_AUTO_LINK
-# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# pragma comment(lib, "c++.lib")
-# else
-# pragma comment(lib, "libc++.lib")
-# endif
-# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
-#endif // _LIBCPP_NO_AUTO_LINK
+# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
+# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
+# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
+# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
+# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+
+# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
+# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
+# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
+# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
+# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
+# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
+# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
+# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
+
+# if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
+# define _LIBCPP_HAS_NO_CXX20_COROUTINES
+# endif
+
+# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
+# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")
+
+# ifndef _LIBCPP_NO_AUTO_LINK
+# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# pragma comment(lib, "c++.lib")
+# else
+# pragma comment(lib, "libc++.lib")
+# endif
+# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+# endif // _LIBCPP_NO_AUTO_LINK
// Configures the fopen close-on-exec mode character, if any. This string will
// be appended to any mode string used by fstream for fopen/fdopen.
//
// Not all platforms support this, but it helps avoid fd-leaks on platforms that
// do.
-#if defined(__BIONIC__)
-# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
-#else
-# define _LIBCPP_FOPEN_CLOEXEC_MODE
-#endif
+# if defined(__BIONIC__)
+# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
+# else
+# define _LIBCPP_FOPEN_CLOEXEC_MODE
+# endif
// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
// of functions used in cstdio may not be available for low API levels when
// using 64-bit file offsets on LP32.
-#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
-#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
-#endif
+# if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
+# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
+# endif
-#if __has_attribute(init_priority)
- // TODO: Remove this once we drop support for building libc++ with old Clangs
-# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
- (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
-# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
-# else
-# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
-# endif
-#else
-# define _LIBCPP_INIT_PRIORITY_MAX
-#endif
+# if __has_attribute(init_priority)
+// TODO: Remove this once we drop support for building libc++ with old Clangs
+# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
+ (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+# else
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
+# endif
+# else
+# define _LIBCPP_INIT_PRIORITY_MAX
+# endif
-#if defined(__GNUC__) || defined(__clang__)
- // The attribute uses 1-based indices for ordinary and static member functions.
- // The attribute uses 2-based indices for non-static member functions.
-# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
- __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
-#else
-# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
-#endif
+# if defined(__GNUC__) || defined(__clang__)
+// The attribute uses 1-based indices for ordinary and static member functions.
+// The attribute uses 2-based indices for non-static member functions.
+# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
+ __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
+# else
+# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
+# endif
+
+# if __has_cpp_attribute(msvc::no_unique_address)
+// MSVC implements [[no_unique_address]] as a silent no-op currently.
+// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
+// However, MSVC implements [[msvc::no_unique_address]] which does what
+// [[no_unique_address]] is supposed to do, in general.
+
+// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
+// [[msvc::no_unique_address]] though. If/when it does implement
+// [[msvc::no_unique_address]], this should be preferred though.
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
+# elif __has_cpp_attribute(no_unique_address)
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
+# else
+# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
+// Note that this can be replaced by #error as soon as clang-cl
+// implements msvc::no_unique_address, since there should be no C++20
+// compiler that doesn't support one of the two attributes at that point.
+// We generally don't want to use this macro outside of C++20-only code,
+// because using it conditionally in one language version only would make
+// the ABI inconsistent.
+# endif
+
+# ifdef _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
+# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
+# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
+# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
+# elif defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
+# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
+# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
+# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
+# else
+# define _LIBCPP_DIAGNOSTIC_PUSH
+# define _LIBCPP_DIAGNOSTIC_POP
+# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
+# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
+# endif
+
+# if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)")
+# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)")
+# else
+# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */
+# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */
+# endif
+
+# if __has_attribute(__packed__)
+# define _LIBCPP_PACKED __attribute__((__packed__))
+# else
+# define _LIBCPP_PACKED
+# endif
#endif // __cplusplus
-#endif // _LIBCPP_CONFIG
+#endif // _LIBCPP___CONFIG
lib/libcxx/include/__debug
@@ -7,80 +7,37 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_DEBUG_H
-#define _LIBCPP_DEBUG_H
+#ifndef _LIBCPP___DEBUG
+#define _LIBCPP___DEBUG
+#include <__assert>
#include <__config>
-#include <iosfwd>
+#include <cstddef>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-#if defined(_LIBCPP_HAS_NO_NULLPTR)
-# include <cstddef>
+// Catch invalid uses of the legacy _LIBCPP_DEBUG toggle.
+#if defined(_LIBCPP_DEBUG) && _LIBCPP_DEBUG != 0 && !defined(_LIBCPP_ENABLE_DEBUG_MODE)
+# error "Enabling the debug mode now requires having configured the library with support for the debug mode"
#endif
-#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
-# include <cstddef>
-# include <cstdio>
-# include <cstdlib>
+#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
+# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
#endif
-#if _LIBCPP_DEBUG_LEVEL == 0
-# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
-# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
-#elif _LIBCPP_DEBUG_LEVEL == 1
-# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
-# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
-#elif _LIBCPP_DEBUG_LEVEL == 2
-# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(__libcpp_is_constant_evaluated() || (x), m)
-# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
#else
-# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
+# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
#endif
-#if !defined(_LIBCPP_ASSERT)
-# define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m)
-#endif
+#if defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY)
_LIBCPP_BEGIN_NAMESPACE_STD
-struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- __libcpp_debug_info()
- : __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
- : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
-
- _LIBCPP_FUNC_VIS string what() const;
-
- const char* __file_;
- int __line_;
- const char* __pred_;
- const char* __msg_;
-};
-
-/// __libcpp_debug_function_type - The type of the assertion failure handler.
-typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&);
-
-/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
-/// fails.
-extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_function;
-
-/// __libcpp_abort_debug_function - A debug handler that aborts when called.
-_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
-void __libcpp_abort_debug_function(__libcpp_debug_info const&);
-
-/// __libcpp_set_debug_function - Set the debug handler to the specified
-/// function.
-_LIBCPP_FUNC_VIS
-bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
-
-#if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
-
struct _LIBCPP_TYPE_VIS __c_node;
struct _LIBCPP_TYPE_VIS __i_node
@@ -89,15 +46,9 @@ struct _LIBCPP_TYPE_VIS __i_node
__i_node* __next_;
__c_node* __c_;
-#ifndef _LIBCPP_CXX03_LANG
__i_node(const __i_node&) = delete;
__i_node& operator=(const __i_node&) = delete;
-#else
-private:
- __i_node(const __i_node&);
- __i_node& operator=(const __i_node&);
-public:
-#endif
+
_LIBCPP_INLINE_VISIBILITY
__i_node(void* __i, __i_node* __next, __c_node* __c)
: __i_(__i), __next_(__next), __c_(__c) {}
@@ -112,17 +63,11 @@ struct _LIBCPP_TYPE_VIS __c_node
__i_node** end_;
__i_node** cap_;
-#ifndef _LIBCPP_CXX03_LANG
__c_node(const __c_node&) = delete;
__c_node& operator=(const __c_node&) = delete;
-#else
-private:
- __c_node(const __c_node&);
- __c_node& operator=(const __c_node&);
-public:
-#endif
+
_LIBCPP_INLINE_VISIBILITY
- __c_node(void* __c, __c_node* __next)
+ explicit __c_node(void* __c, __c_node* __next)
: __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {}
virtual ~__c_node();
@@ -139,7 +84,7 @@ template <class _Cont>
struct _C_node
: public __c_node
{
- _C_node(void* __c, __c_node* __n)
+ explicit _C_node(void* __c, __c_node* __n)
: __c_node(__c, __n) {}
virtual bool __dereferenceable(const void*) const;
@@ -197,17 +142,11 @@ class _LIBCPP_TYPE_VIS __libcpp_db
__i_node** __iend_;
size_t __isz_;
- __libcpp_db();
+ explicit __libcpp_db();
public:
-#ifndef _LIBCPP_CXX03_LANG
__libcpp_db(const __libcpp_db&) = delete;
__libcpp_db& operator=(const __libcpp_db&) = delete;
-#else
-private:
- __libcpp_db(const __libcpp_db&);
- __libcpp_db& operator=(const __libcpp_db&);
-public:
-#endif
+
~__libcpp_db();
class __db_c_iterator;
@@ -266,12 +205,15 @@ private:
_LIBCPP_FUNC_VIS __libcpp_db* __get_db();
_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
+_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
+#endif // defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__insert_c(__c);
#else
@@ -281,7 +223,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__insert_i(__i);
#else
@@ -289,6 +231,37 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
#endif
}
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase_c(_Tp* __c) {
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__erase_c(__c);
+#else
+ (void)(__c);
+#endif
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) {
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->swap(__lhs, __rhs);
+#else
+ (void)(__lhs);
+ (void)(__rhs);
+#endif
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_invalidate_all(_Tp* __c) {
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__invalidate_all(__c);
+#else
+ (void)(__c);
+#endif
+}
+
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_DEBUG_H
+#endif // _LIBCPP___DEBUG
lib/libcxx/include/__errc
@@ -104,7 +104,7 @@ enum class errc
#include <cerrno>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__functional_base
@@ -1,32 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_FUNCTIONAL_BASE
-#define _LIBCPP_FUNCTIONAL_BASE
-
-#include <__config>
-#include <__functional/binary_function.h>
-#include <__functional/invoke.h>
-#include <__functional/operations.h>
-#include <__functional/reference_wrapper.h>
-#include <__functional/unary_function.h>
-#include <__functional/weak_result_type.h>
-#include <__memory/allocator_arg_t.h>
-#include <__memory/uses_allocator.h>
-#include <exception>
-#include <new>
-#include <type_traits>
-#include <typeinfo>
-#include <utility>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-#endif // _LIBCPP_FUNCTIONAL_BASE
lib/libcxx/include/__hash_table
@@ -7,22 +7,26 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP__HASH_TABLE
-#define _LIBCPP__HASH_TABLE
+#ifndef _LIBCPP___HASH_TABLE
+#define _LIBCPP___HASH_TABLE
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
+#include <__assert>
#include <__bits> // __libcpp_clz
#include <__config>
#include <__debug>
-#include <algorithm>
+#include <__functional/hash.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/swap_allocator.h>
+#include <__utility/swap.h>
#include <cmath>
#include <initializer_list>
-#include <iterator>
#include <memory>
#include <type_traits>
-#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -44,7 +48,7 @@ template <class ..._Args>
struct __is_hash_value_type : false_type {};
template <class _One>
-struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};
+struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__uncvref_t<_One> > {};
_LIBCPP_FUNC_VIS
size_t __next_prime(size_t __n);
@@ -175,16 +179,14 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
- static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
- __container_value_type const&>::type
+ static __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, __container_value_type const&>
__get_value(_Up& __t) {
return __t.__get_value();
}
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
- static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
- __container_value_type const&>::type
+ static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&>
__get_value(_Up& __t) {
return __t;
}
@@ -291,7 +293,7 @@ public:
_VSTD::__debug_db_insert_i(this);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__hash_iterator(const __hash_iterator& __i)
: __node_(__i.__node_)
@@ -315,7 +317,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -357,19 +359,15 @@ public:
{return !(__x == __y);}
private:
-#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
- __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
+ explicit __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
: __node_(__node)
{
+ (void)__c;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
- }
-#else
- _LIBCPP_INLINE_VISIBILITY
- __hash_iterator(__next_pointer __node) _NOEXCEPT
- : __node_(__node)
- {}
#endif
+ }
template <class, class, class, class> friend class __hash_table;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
@@ -405,12 +403,12 @@ public:
__hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
: __node_(__x.__node_)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(const __hash_const_iterator& __i)
: __node_(__i.__node_)
@@ -434,7 +432,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -475,19 +473,15 @@ public:
{return !(__x == __y);}
private:
-#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
- __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
+ explicit __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
: __node_(__node)
{
+ (void)__c;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
- }
-#else
- _LIBCPP_INLINE_VISIBILITY
- __hash_const_iterator(__next_pointer __node) _NOEXCEPT
- : __node_(__node)
- {}
#endif
+ }
template <class, class, class, class> friend class __hash_table;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
@@ -516,7 +510,7 @@ public:
_VSTD::__debug_db_insert_i(this);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__hash_local_iterator(const __hash_local_iterator& __i)
: __node_(__i.__node_),
@@ -544,7 +538,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -588,30 +582,20 @@ public:
{return !(__x == __y);}
private:
-#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
- __hash_local_iterator(__next_pointer __node, size_t __bucket,
- size_t __bucket_count, const void* __c) _NOEXCEPT
+ explicit __hash_local_iterator(__next_pointer __node, size_t __bucket,
+ size_t __bucket_count, const void* __c) _NOEXCEPT
: __node_(__node),
__bucket_(__bucket),
__bucket_count_(__bucket_count)
{
+ (void)__c;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
+#endif
if (__node_ != nullptr)
__node_ = __node_->__next_;
}
-#else
- _LIBCPP_INLINE_VISIBILITY
- __hash_local_iterator(__next_pointer __node, size_t __bucket,
- size_t __bucket_count) _NOEXCEPT
- : __node_(__node),
- __bucket_(__bucket),
- __bucket_count_(__bucket_count)
- {
- if (__node_ != nullptr)
- __node_ = __node_->__next_;
- }
-#endif
template <class, class, class, class> friend class __hash_table;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
@@ -654,12 +638,12 @@ public:
__bucket_(__x.__bucket_),
__bucket_count_(__x.__bucket_count_)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__hash_const_local_iterator(const __hash_const_local_iterator& __i)
: __node_(__i.__node_),
@@ -687,7 +671,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -731,30 +715,20 @@ public:
{return !(__x == __y);}
private:
-#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
- __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
- size_t __bucket_count, const void* __c) _NOEXCEPT
+ explicit __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
+ size_t __bucket_count, const void* __c) _NOEXCEPT
: __node_(__node_ptr),
__bucket_(__bucket),
__bucket_count_(__bucket_count)
{
+ (void)__c;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
+#endif
if (__node_ != nullptr)
__node_ = __node_->__next_;
}
-#else
- _LIBCPP_INLINE_VISIBILITY
- __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
- size_t __bucket_count) _NOEXCEPT
- : __node_(__node_ptr),
- __bucket_(__bucket),
- __bucket_count_(__bucket_count)
- {
- if (__node_ != nullptr)
- __node_ = __node_->__next_;
- }
-#endif
template <class, class, class, class> friend class __hash_table;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
};
@@ -1074,10 +1048,8 @@ public:
template <class _First, class _Second>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<
- __can_extract_map_key<_First, key_type, __container_value_type>::value,
- pair<iterator, bool>
- >::type __emplace_unique(_First&& __f, _Second&& __s) {
+ __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> >
+ __emplace_unique(_First&& __f, _Second&& __s) {
return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
_VSTD::forward<_Second>(__s));
}
@@ -1121,9 +1093,7 @@ public:
return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x));
}
- template <class _Pp, class = typename enable_if<
- !__is_same_uncvref<_Pp, __container_value_type>::value
- >::type>
+ template <class _Pp, class = __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value> >
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __insert_unique(_Pp&& __x) {
return __emplace_unique(_VSTD::forward<_Pp>(__x));
@@ -1177,9 +1147,16 @@ public:
#endif
void clear() _NOEXCEPT;
- void rehash(size_type __n);
- _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)
- {rehash(static_cast<size_type>(ceil(__n / max_load_factor())));}
+ _LIBCPP_INLINE_VISIBILITY void __rehash_unique(size_type __n) { __rehash<true>(__n); }
+ _LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash<false>(__n); }
+ _LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n)
+ {
+ __rehash_unique(static_cast<size_type>(ceil(__n / max_load_factor())));
+ }
+ _LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n)
+ {
+ __rehash_multi(static_cast<size_type>(ceil(__n / max_load_factor())));
+ }
_LIBCPP_INLINE_VISIBILITY
size_type bucket_count() const _NOEXCEPT
@@ -1276,11 +1253,7 @@ public:
{
_LIBCPP_ASSERT(__n < bucket_count(),
"unordered container::begin(n) called with n >= bucket_count()");
-#if _LIBCPP_DEBUG_LEVEL == 2
return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
-#else
- return local_iterator(__bucket_list_[__n], __n, bucket_count());
-#endif
}
_LIBCPP_INLINE_VISIBILITY
@@ -1289,11 +1262,7 @@ public:
{
_LIBCPP_ASSERT(__n < bucket_count(),
"unordered container::end(n) called with n >= bucket_count()");
-#if _LIBCPP_DEBUG_LEVEL == 2
return local_iterator(nullptr, __n, bucket_count(), this);
-#else
- return local_iterator(nullptr, __n, bucket_count());
-#endif
}
_LIBCPP_INLINE_VISIBILITY
@@ -1302,11 +1271,7 @@ public:
{
_LIBCPP_ASSERT(__n < bucket_count(),
"unordered container::cbegin(n) called with n >= bucket_count()");
-#if _LIBCPP_DEBUG_LEVEL == 2
return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
-#else
- return const_local_iterator(__bucket_list_[__n], __n, bucket_count());
-#endif
}
_LIBCPP_INLINE_VISIBILITY
@@ -1315,24 +1280,21 @@ public:
{
_LIBCPP_ASSERT(__n < bucket_count(),
"unordered container::cend(n) called with n >= bucket_count()");
-#if _LIBCPP_DEBUG_LEVEL == 2
return const_local_iterator(nullptr, __n, bucket_count(), this);
-#else
- return const_local_iterator(nullptr, __n, bucket_count());
-#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
- void __rehash(size_type __n);
+ template <bool _UniqueKeys> void __rehash(size_type __n);
+ template <bool _UniqueKeys> void __do_rehash(size_type __n);
template <class ..._Args>
__node_holder __construct_node(_Args&& ...__args);
@@ -1509,9 +1471,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
#endif
__deallocate_node(__p1_.first().__next_);
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__erase_c(this);
-#endif
+ std::__debug_db_erase_c(this);
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -1553,7 +1513,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
while (__np != nullptr)
{
__next_pointer __next = __np->__next_;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1614,9 +1574,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
__u.__p1_.first().__next_ = nullptr;
__u.size() = 0;
}
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -1766,11 +1724,7 @@ inline
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__p1_.first().__next_, this);
-#else
- return iterator(__p1_.first().__next_);
-#endif
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -1778,11 +1732,7 @@ inline
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(nullptr, this);
-#else
- return iterator(nullptr);
-#endif
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -1790,11 +1740,7 @@ inline
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(__p1_.first().__next_, this);
-#else
- return const_iterator(__p1_.first().__next_);
-#endif
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -1802,11 +1748,7 @@ inline
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(nullptr, this);
-#else
- return const_iterator(nullptr);
-#endif
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -1857,7 +1799,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
}
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
- rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
+ __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
size_type(ceil(float(size() + 1) / max_load_factor()))));
}
return nullptr;
@@ -1911,11 +1853,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __
__existing_node = __nd->__ptr();
__inserted = true;
}
-#if _LIBCPP_DEBUG_LEVEL == 2
return pair<iterator, bool>(iterator(__existing_node, this), __inserted);
-#else
- return pair<iterator, bool>(iterator(__existing_node), __inserted);
-#endif
}
// Prepare the container for an insertion of the value __cp_val with the hash
@@ -1933,7 +1871,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(
size_type __bc = bucket_count();
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
- rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
+ __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
size_type(ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
}
@@ -2009,11 +1947,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c
__next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_);
__node_insert_multi_perform(__cp, __pn);
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__cp->__ptr(), this);
-#else
- return iterator(__cp->__ptr());
-#endif
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -2031,7 +1965,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
size_type __bc = bucket_count();
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
- rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
+ __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
size_type(ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
}
@@ -2042,11 +1976,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
__cp->__next_ = __np;
__pp->__next_ = static_cast<__next_pointer>(__cp);
++size();
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(static_cast<__next_pointer>(__cp), this);
-#else
- return iterator(static_cast<__next_pointer>(__cp));
-#endif
}
return __node_insert_multi(__cp);
}
@@ -2083,7 +2013,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
__node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
- rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
+ __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
size_type(ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
__chash = __constrain_hash(__hash, __bc);
@@ -2112,11 +2042,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
__inserted = true;
}
__done:
-#if _LIBCPP_DEBUG_LEVEL == 2
return pair<iterator, bool>(iterator(__nd, this), __inserted);
-#else
- return pair<iterator, bool>(iterator(__nd), __inserted);
-#endif
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -2290,8 +2216,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(
#endif // _LIBCPP_STD_VER > 14
template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <bool _UniqueKeys>
void
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n)
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
{
if (__n == 1)
@@ -2300,7 +2227,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
__n = __next_prime(__n);
size_type __bc = bucket_count();
if (__n > __bc)
- __rehash(__n);
+ __do_rehash<_UniqueKeys>(__n);
else if (__n < __bc)
{
__n = _VSTD::max<size_type>
@@ -2310,17 +2237,16 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
__next_prime(size_t(ceil(float(size()) / max_load_factor())))
);
if (__n < __bc)
- __rehash(__n);
+ __do_rehash<_UniqueKeys>(__n);
}
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <bool _UniqueKeys>
void
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__invalidate_all(this);
-#endif
+ std::__debug_db_invalidate_all(this);
__pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();
__bucket_list_.reset(__nbc > 0 ?
__pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);
@@ -2353,11 +2279,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
else
{
__next_pointer __np = __cp;
- for (; __np->__next_ != nullptr &&
- key_eq()(__cp->__upcast()->__value_,
- __np->__next_->__upcast()->__value_);
- __np = __np->__next_)
- ;
+ if _LIBCPP_CONSTEXPR_AFTER_CXX14 (!_UniqueKeys)
+ {
+ for (; __np->__next_ != nullptr &&
+ key_eq()(__cp->__upcast()->__value_,
+ __np->__next_->__upcast()->__value_);
+ __np = __np->__next_)
+ ;
+ }
__pp->__next_ = __np->__next_;
__np->__next_ = __bucket_list_[__chash]->__next_;
__bucket_list_[__chash]->__next_ = __cp;
@@ -2389,11 +2318,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
{
if ((__nd->__hash() == __hash)
&& key_eq()(__nd->__upcast()->__value_, __k))
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__nd, this);
-#else
- return iterator(__nd);
-#endif
}
}
}
@@ -2420,11 +2345,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
{
if ((__nd->__hash() == __hash)
&& key_eq()(__nd->__upcast()->__value_, __k))
-#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(__nd, this);
-#else
- return const_iterator(__nd);
-#endif
}
}
@@ -2475,13 +2396,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
"unordered container erase(iterator) called with an iterator not"
" referring to this container");
- _LIBCPP_DEBUG_ASSERT(__p != end(),
- "unordered container erase(iterator) called with a non-dereferenceable iterator");
-#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__p != end(),
+ "unordered container erase(iterator) called with a non-dereferenceable iterator");
iterator __r(__np, this);
-#else
- iterator __r(__np);
-#endif
++__r;
remove(__p);
return __r;
@@ -2504,11 +2421,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
erase(__p);
}
__next_pointer __np = __last.__node_;
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator (__np, this);
-#else
- return iterator (__np);
-#endif
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -2575,7 +2488,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
__pn->__next_ = __cn->__next_;
__cn->__next_ = nullptr;
--size();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __dp = __c->end_; __dp != __c->beg_; )
{
@@ -2726,9 +2639,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
if (__u.size() > 0)
__u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
__u.__p1_.first().__ptr();
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
@@ -2760,7 +2671,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
__x.swap(__y);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Hash, class _Equal, class _Alloc>
bool
@@ -2790,10 +2701,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*,
return false;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP__HASH_TABLE
+#endif // _LIBCPP___HASH_TABLE
lib/libcxx/include/__libcpp_version
@@ -1,1 +0,0 @@
-14000
lib/libcxx/include/__locale
@@ -18,24 +18,22 @@
#include <memory>
#include <mutex>
#include <string>
-#include <utility>
#if defined(_LIBCPP_MSVCRT_LIKE)
-# include <cstring>
# include <__support/win32/locale_win32.h>
+# include <cstring>
#elif defined(_AIX) || defined(__MVS__)
# include <__support/ibm/xlocale.h>
#elif defined(__ANDROID__)
# include <__support/android/locale_bionic.h>
#elif defined(__sun__)
-# include <xlocale.h>
# include <__support/solaris/xlocale.h>
+# include <xlocale.h>
#elif defined(_NEWLIB_VERSION)
# include <__support/newlib/xlocale.h>
#elif defined(__OpenBSD__)
# include <__support/openbsd/xlocale.h>
-#elif (defined(__APPLE__) || defined(__FreeBSD__) \
- || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
+#elif (defined(__APPLE__) || defined(__FreeBSD__))
# include <xlocale.h>
#elif defined(__Fuchsia__)
# include <__support/fuchsia/xlocale.h>
@@ -47,7 +45,7 @@
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -339,9 +337,9 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
return static_cast<long>(__h);
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>;
#endif
// template <class CharT> class collate_byname;
@@ -454,6 +452,7 @@ public:
static const mask blank = _BLANK;
static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
+# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
# ifdef __APPLE__
typedef __uint32_t mask;
@@ -493,7 +492,11 @@ public:
static const mask punct = _ISPUNCT;
static const mask xdigit = _ISXDIGIT;
static const mask blank = _ISBLANK;
+# if defined(_AIX)
+ static const mask __regex_word = 0x8000;
+# else
static const mask __regex_word = 0x80;
+# endif
#elif defined(_NEWLIB_VERSION)
// Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
typedef char mask;
@@ -546,11 +549,8 @@ public:
_LIBCPP_INLINE_VISIBILITY ctype_base() {}
-// TODO: Remove the ifndef when the assert no longer fails on AIX.
-#ifndef _AIX
static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word,
"__regex_word can't overlap other bits");
-#endif
};
template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
@@ -1498,15 +1498,15 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;
#endif
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) // deprecated in C++20
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) // deprecated in C++20
+extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
+extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
#ifndef _LIBCPP_HAS_NO_CHAR8_T
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>) // C++20
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>) // C++20
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20
#endif
template <size_t _Np>
lib/libcxx/include/__mbstate_t.h
@@ -13,7 +13,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
// TODO(ldionne):
lib/libcxx/include/__mutex_base
@@ -10,15 +10,18 @@
#ifndef _LIBCPP___MUTEX_BASE
#define _LIBCPP___MUTEX_BASE
+#include <__chrono/duration.h>
+#include <__chrono/steady_clock.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
#include <__config>
#include <__threading_support>
-#include <chrono>
#include <ratio>
#include <system_error>
#include <time.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -335,11 +338,7 @@ private:
template <class _Rep, class _Period>
inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_floating_point<_Rep>::value,
- chrono::nanoseconds
->::type
+__enable_if_t<is_floating_point<_Rep>::value, chrono::nanoseconds>
__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
{
using namespace chrono;
@@ -362,11 +361,7 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
template <class _Rep, class _Period>
inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_floating_point<_Rep>::value,
- chrono::nanoseconds
->::type
+__enable_if_t<!is_floating_point<_Rep>::value, chrono::nanoseconds>
__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d)
{
using namespace chrono;
lib/libcxx/include/__node_handle
@@ -58,13 +58,13 @@ public:
*/
+#include <__assert>
#include <__config>
-#include <__debug>
#include <memory>
#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__nullptr
@@ -1,61 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_NULLPTR
-#define _LIBCPP_NULLPTR
-
-#include <__config>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-#ifdef _LIBCPP_HAS_NO_NULLPTR
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-struct _LIBCPP_TEMPLATE_VIS nullptr_t
-{
- void* __lx;
-
- struct __nat {int __for_bool_;};
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
-
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- operator _Tp* () const {return 0;}
-
- template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY
- operator _Tp _Up::* () const {return 0;}
-
- friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
- friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
-};
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
-
-#define nullptr _VSTD::__get_nullptr_t()
-
-_LIBCPP_END_NAMESPACE_STD
-
-#else // _LIBCPP_HAS_NO_NULLPTR
-
-namespace std
-{
- typedef decltype(nullptr) nullptr_t;
-} // namespace std
-
-#endif // _LIBCPP_HAS_NO_NULLPTR
-
-#endif // _LIBCPP_NULLPTR
lib/libcxx/include/__split_buffer
@@ -1,14 +1,31 @@
// -*- C++ -*-
-#ifndef _LIBCPP_SPLIT_BUFFER
-#define _LIBCPP_SPLIT_BUFFER
-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___SPLIT_BUFFER
+#define _LIBCPP___SPLIT_BUFFER
+
+#include <__algorithm/max.h>
+#include <__algorithm/move.h>
+#include <__algorithm/move_backward.h>
#include <__config>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/move_iterator.h>
+#include <__memory/allocator.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/swap_allocator.h>
#include <__utility/forward.h>
-#include <algorithm>
+#include <memory>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -45,116 +62,107 @@ public:
typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
- _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
explicit __split_buffer(__alloc_rr& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
explicit __split_buffer(const __alloc_rr& __a);
- __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
- ~__split_buffer();
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer();
- __split_buffer(__split_buffer&& __c)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
- __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
- __split_buffer& operator=(__split_buffer&& __c)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c)
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
!__alloc_traits::propagate_on_container_move_assignment::value);
- _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
- _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
- _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
- _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{__destruct_at_end(__begin_);}
- _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
- _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
- _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
- _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
- _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
-
- _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
- _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
- _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
- _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
-
- void reserve(size_type __n);
- void shrink_to_fit() _NOEXCEPT;
- void push_front(const_reference __x);
- _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
- void push_front(value_type&& __x);
- void push_back(value_type&& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x);
template <class... _Args>
- void emplace_back(_Args&&... __args);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void emplace_back(_Args&&... __args);
- _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
- _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
- void __construct_at_end(size_type __n);
- void __construct_at_end(size_type __n, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x);
template <class _InputIter>
- typename enable_if
- <
- __is_cpp17_input_iterator<_InputIter>::value &&
- !__is_cpp17_forward_iterator<_InputIter>::value,
- void
- >::type
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
__construct_at_end(_InputIter __first, _InputIter __last);
template <class _ForwardIterator>
- typename enable_if
- <
- __is_cpp17_forward_iterator<_ForwardIterator>::value,
- void
- >::type
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
- _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
{__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_begin(pointer __new_begin, false_type);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_begin(pointer __new_begin, true_type);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{__destruct_at_end(__new_last, false_type());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
- void swap(__split_buffer& __x)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__split_buffer& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
__is_nothrow_swappable<__alloc_rr>::value);
- bool __invariants() const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__split_buffer& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
{}
struct _ConstructTransaction {
- explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
: __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
}
- ~_ConstructTransaction() {
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
*__dest_ = __pos_;
}
pointer __pos_;
@@ -165,6 +173,7 @@ private:
};
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
bool
__split_buffer<_Tp, _Allocator>::__invariants() const
{
@@ -195,6 +204,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
@@ -211,6 +221,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
@@ -223,12 +234,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
template <class _Tp, class _Allocator>
template <class _InputIter>
-typename enable_if
-<
- __is_cpp17_input_iterator<_InputIter>::value &&
- !__is_cpp17_forward_iterator<_InputIter>::value,
- void
->::type
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
{
__alloc_rr& __a = this->__alloc();
@@ -251,11 +257,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
-typename enable_if
-<
- __is_cpp17_forward_iterator<_ForwardIterator>::value,
- void
->::type
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
_ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
@@ -266,6 +268,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
@@ -275,6 +278,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
@@ -283,6 +287,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
@@ -292,6 +297,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
@@ -300,15 +306,23 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
: __end_cap_(nullptr, __a)
{
- __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
+ if (__cap == 0) {
+ __first_ = nullptr;
+ } else {
+ auto __allocation = std::__allocate_at_least(__alloc(), __cap);
+ __first_ = __allocation.ptr;
+ __cap = __allocation.count;
+ }
__begin_ = __end_ = __first_ + __start;
__end_cap() = __first_ + __cap;
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
@@ -317,6 +331,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@@ -324,6 +339,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@@ -331,6 +347,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::~__split_buffer()
{
clear();
@@ -339,6 +356,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
: __first_(_VSTD::move(__c.__first_)),
@@ -353,6 +371,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
: __end_cap_(nullptr, __a)
{
@@ -369,16 +388,17 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al
}
else
{
- size_type __cap = __c.size();
- __first_ = __alloc_traits::allocate(__alloc(), __cap);
+ auto __allocation = std::__allocate_at_least(__alloc(), __c.size());
+ __first_ = __allocation.ptr;
__begin_ = __end_ = __first_;
- __end_cap() = __first_ + __cap;
+ __end_cap() = __first_ + __allocation.count;
typedef move_iterator<iterator> _Ip;
__construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
}
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>&
__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
@@ -399,6 +419,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
@@ -412,6 +433,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
{
@@ -428,6 +450,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@@ -455,6 +478,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
{
@@ -484,6 +508,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
{
@@ -514,6 +539,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
@@ -544,6 +570,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
{
@@ -575,6 +602,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
@@ -605,6 +633,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
@@ -617,4 +646,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_SPLIT_BUFFER
+#endif // _LIBCPP___SPLIT_BUFFER
lib/libcxx/include/__std_stream
@@ -17,7 +17,7 @@
#include <ostream>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/__threading_support
@@ -7,13 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_THREADING_SUPPORT
-#define _LIBCPP_THREADING_SUPPORT
+#ifndef _LIBCPP___THREADING_SUPPORT
+#define _LIBCPP___THREADING_SUPPORT
#include <__availability>
+#include <__chrono/convert_to_timespec.h>
+#include <__chrono/duration.h>
#include <__config>
#include <__thread/poll_with_backoff.h>
-#include <chrono>
#include <errno.h>
#include <iosfwd>
#include <limits>
@@ -23,7 +24,7 @@
#endif
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
@@ -200,15 +201,15 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
// Execute once
_LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
- void (*init_routine)());
+int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
+ void (*__init_routine)());
// Thread id
_LIBCPP_THREAD_ABI_VISIBILITY
-bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
+bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2);
_LIBCPP_THREAD_ABI_VISIBILITY
-bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
+bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2);
// Thread
_LIBCPP_THREAD_ABI_VISIBILITY
@@ -346,22 +347,22 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
}
// Execute once
-int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
- void (*init_routine)()) {
- return pthread_once(flag, init_routine);
+int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
+ void (*__init_routine)()) {
+ return pthread_once(__flag, __init_routine);
}
// 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)
+bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2)
{
- return t1 == t2;
+ return __t1 == __t2;
}
// Returns non-zero if t1 < t2, otherwise 0
-bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
+bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2)
{
- return t1 < t2;
+ return __t1 < __t2;
}
// Thread
@@ -673,4 +674,4 @@ get_id() _NOEXCEPT
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_THREADING_SUPPORT
+#endif // _LIBCPP___THREADING_SUPPORT
lib/libcxx/include/__tree
@@ -10,16 +10,22 @@
#ifndef _LIBCPP___TREE
#define _LIBCPP___TREE
+#include <__algorithm/min.h>
+#include <__assert>
#include <__config>
+#include <__debug>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/swap_allocator.h>
#include <__utility/forward.h>
-#include <algorithm>
-#include <iterator>
+#include <__utility/swap.h>
#include <limits>
#include <memory>
#include <stdexcept>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -28,12 +34,10 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if defined(__GNUC__) && !defined(__clang__) // gcc.gnu.org/PR37804
template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS multimap;
template <class, class, class> class _LIBCPP_TEMPLATE_VIS set;
template <class, class, class> class _LIBCPP_TEMPLATE_VIS multiset;
-#endif
template <class _Tp, class _Compare, class _Allocator> class __tree;
template <class _Tp, class _NodePtr, class _DiffType>
@@ -140,35 +144,35 @@ __tree_invariant(_NodePtr __root)
}
// Returns: pointer to the left-most node under __x.
-// Precondition: __x != nullptr.
template <class _NodePtr>
inline _LIBCPP_INLINE_VISIBILITY
_NodePtr
__tree_min(_NodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__x != nullptr, "Root node shouldn't be null");
while (__x->__left_ != nullptr)
__x = __x->__left_;
return __x;
}
// Returns: pointer to the right-most node under __x.
-// Precondition: __x != nullptr.
template <class _NodePtr>
inline _LIBCPP_INLINE_VISIBILITY
_NodePtr
__tree_max(_NodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__x != nullptr, "Root node shouldn't be null");
while (__x->__right_ != nullptr)
__x = __x->__right_;
return __x;
}
// Returns: pointer to the next in-order node after __x.
-// Precondition: __x != nullptr.
template <class _NodePtr>
_NodePtr
__tree_next(_NodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
if (__x->__right_ != nullptr)
return _VSTD::__tree_min(__x->__right_);
while (!_VSTD::__tree_is_left_child(__x))
@@ -181,6 +185,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_EndNodePtr
__tree_next_iter(_NodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
if (__x->__right_ != nullptr)
return static_cast<_EndNodePtr>(_VSTD::__tree_min(__x->__right_));
while (!_VSTD::__tree_is_left_child(__x))
@@ -189,13 +194,13 @@ __tree_next_iter(_NodePtr __x) _NOEXCEPT
}
// Returns: pointer to the previous in-order node before __x.
-// Precondition: __x != nullptr.
// Note: __x may be the end node.
template <class _NodePtr, class _EndNodePtr>
inline _LIBCPP_INLINE_VISIBILITY
_NodePtr
__tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
if (__x->__left_ != nullptr)
return _VSTD::__tree_max(__x->__left_);
_NodePtr __xx = static_cast<_NodePtr>(__x);
@@ -205,11 +210,11 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
}
// Returns: pointer to a node which has no children
-// Precondition: __x != nullptr.
template <class _NodePtr>
_NodePtr
__tree_leaf(_NodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
while (true)
{
if (__x->__left_ != nullptr)
@@ -229,11 +234,12 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT
// Effects: Makes __x->__right_ the subtree root with __x as its left child
// while preserving in-order order.
-// Precondition: __x->__right_ != nullptr
template <class _NodePtr>
void
__tree_left_rotate(_NodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
+ _LIBCPP_ASSERT(__x->__right_ != nullptr, "node should have a right child");
_NodePtr __y = __x->__right_;
__x->__right_ = __y->__left_;
if (__x->__right_ != nullptr)
@@ -249,11 +255,12 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT
// Effects: Makes __x->__left_ the subtree root with __x as its right child
// while preserving in-order order.
-// Precondition: __x->__left_ != nullptr
template <class _NodePtr>
void
__tree_right_rotate(_NodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
+ _LIBCPP_ASSERT(__x->__left_ != nullptr, "node should have a left child");
_NodePtr __y = __x->__left_;
__x->__left_ = __y->__right_;
if (__x->__left_ != nullptr)
@@ -268,8 +275,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT
}
// Effects: Rebalances __root after attaching __x to a leaf.
-// Precondition: __root != nulptr && __x != nullptr.
-// __x has no children.
+// Precondition: __x has no children.
// __x == __root or == a direct or indirect child of __root.
// If __x were to be unlinked from __root (setting __root to
// nullptr if __root == __x), __tree_invariant(__root) == true.
@@ -279,6 +285,8 @@ template <class _NodePtr>
void
__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__root != nullptr, "Root of the tree shouldn't be null");
+ _LIBCPP_ASSERT(__x != nullptr, "Can't attach null node to a leaf");
__x->__is_black_ = __x == __root;
while (__x != __root && !__x->__parent_unsafe()->__is_black_)
{
@@ -338,9 +346,7 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
}
}
-// Precondition: __root != nullptr && __z != nullptr.
-// __tree_invariant(__root) == true.
-// __z == __root or == a direct or indirect child of __root.
+// Precondition: __z == __root or == a direct or indirect child of __root.
// Effects: unlinks __z from the tree rooted at __root, rebalancing as needed.
// Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_
// nor any of its children refer to __z. end_node->__left_
@@ -349,6 +355,9 @@ template <class _NodePtr>
void
__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
{
+ _LIBCPP_ASSERT(__root != nullptr, "Root node should not be null");
+ _LIBCPP_ASSERT(__z != nullptr, "The node to remove should not be null");
+ _LIBCPP_DEBUG_ASSERT(__tree_invariant(__root), "The tree invariants should hold");
// __z will be removed from the tree. Client still needs to destruct/deallocate it
// __y is either __z, or if __z has two children, __tree_next(__z).
// __y will have at most one child.
@@ -545,7 +554,7 @@ template <class ..._Args>
struct __is_tree_value_type : false_type {};
template <class _One>
-struct __is_tree_value_type<_One> : __is_tree_value_type_imp<typename __uncvref<_One>::type> {};
+struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__uncvref_t<_One> > {};
template <class _Tp>
struct __tree_key_value_types {
@@ -589,8 +598,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
- static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
- key_type const&>::type
+ static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, key_type const&>
__get_key(_Up& __t) {
return __t.first;
}
@@ -603,8 +611,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
- static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
- __container_value_type const&>::type
+ static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&>
__get_value(_Up& __t) {
return __t;
}
@@ -1167,10 +1174,8 @@ public:
template <class _First, class _Second>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<
- __can_extract_map_key<_First, key_type, __container_value_type>::value,
- pair<iterator, bool>
- >::type __emplace_unique(_First&& __f, _Second&& __s) {
+ __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> >
+ __emplace_unique(_First&& __f, _Second&& __s) {
return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
_VSTD::forward<_Second>(__s));
}
@@ -1211,10 +1216,8 @@ public:
template <class _First, class _Second>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<
- __can_extract_map_key<_First, key_type, __container_value_type>::value,
- iterator
- >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
+ __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, iterator>
+ __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
return __emplace_hint_unique_key_args(__p, __f,
_VSTD::forward<_First>(__f),
_VSTD::forward<_Second>(__s)).first;
@@ -1267,21 +1270,15 @@ public:
return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)).first;
}
- template <class _Vp, class = typename enable_if<
- !is_same<typename __unconstref<_Vp>::type,
- __container_value_type
- >::value
- >::type>
+ template <class _Vp,
+ class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> >
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __insert_unique(_Vp&& __v) {
return __emplace_unique(_VSTD::forward<_Vp>(__v));
}
- template <class _Vp, class = typename enable_if<
- !is_same<typename __unconstref<_Vp>::type,
- __container_value_type
- >::value
- >::type>
+ template <class _Vp,
+ class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> >
_LIBCPP_INLINE_VISIBILITY
iterator __insert_unique(const_iterator __p, _Vp&& __v) {
return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v));
lib/libcxx/include/__tuple
@@ -15,7 +15,7 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
@@ -30,14 +30,14 @@ using __enable_if_tuple_size_imp = _Tp;
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
const _Tp,
- typename enable_if<!is_volatile<_Tp>::value>::type,
+ __enable_if_t<!is_volatile<_Tp>::value>,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
volatile _Tp,
- typename enable_if<!is_const<_Tp>::value>::type,
+ __enable_if_t<!is_const<_Tp>::value>,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
@@ -278,7 +278,7 @@ using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
#endif
template <size_t _Ip, class ..._Types>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> >
{
static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
@@ -393,7 +393,7 @@ struct __tuple_sfinae_base {
template <template <class, class...> class _Trait,
class ..._LArgs, class ..._RArgs>
static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
- -> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>;
+ -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
template <template <class...> class>
static auto __do_test(...) -> false_type;
@@ -469,8 +469,7 @@ template <class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
: integral_constant<bool, _SizeTrait::value == _Expected> {};
-template <class _Tuple, size_t _ExpectedSize,
- class _RawTuple = typename __uncvref<_Tuple>::type>
+template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __uncvref_t<_Tuple> >
using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
__tuple_like<_RawTuple>::value,
tuple_size<_RawTuple>, _ExpectedSize
lib/libcxx/include/__undef_macros
@@ -7,27 +7,10 @@
//
//===----------------------------------------------------------------------===//
-
#ifdef min
-#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_LIBCPP_WARNING)
-_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
- "before any Windows header. #undefing min")
-#else
-#warning: macro min is incompatible with C++. #undefing min
-#endif
-#endif
-#undef min
+# undef min
#endif
#ifdef max
-#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_LIBCPP_WARNING)
-_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX "
- "before any Windows header. #undefing max")
-#else
-#warning: macro max is incompatible with C++. #undefing max
-#endif
-#endif
-#undef max
+# undef max
#endif
lib/libcxx/include/__verbose_abort
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___VERBOSE_ABORT
+#define _LIBCPP___VERBOSE_ABORT
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
+void __libcpp_verbose_abort(const char *__format, ...);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___VERBOSE_ABORT
lib/libcxx/include/algorithm
@@ -19,14 +19,901 @@ namespace std
{
namespace ranges {
+
+ // [algorithms.results], algorithm result types
+ template <class I, class F>
+ struct in_fun_result; // since C++20
+
template <class I1, class I2>
- struct in_in_result; // since C++20
+ struct in_in_result; // since C++20
+
+ template <class I, class O>
+ struct in_out_result; // since C++20
template <class I1, class I2, class O>
- struct in_in_out_result; // since C++20
+ struct in_in_out_result; // since C++20
+
+ template <class I, class O1, class O2>
+ struct in_out_out_result; // since C++20
+
+ template <class I1, class I2>
+ struct min_max_result; // since C++20
+
+ template <class I>
+ struct in_found_result; // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
+ constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
+
+ template<forward_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
+ constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
+
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+ constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<class I1, class I2>
+ using mismatch_result = in_in_result<I1, I2>;
+
+ template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
+ class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
+ constexpr mismatch_result<_I1, _I2>
+ mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
+
+ template <input_range R1, input_range R2,
+ class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
+ constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
+ mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
+
+ requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
+ constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
+
+ template<input_range R, class T, class Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
+ constexpr borrowed_iterator_t<R>
+ find(R&& r, const T& value, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr borrowed_iterator_t<R>
+ find_if(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr borrowed_iterator_t<R>
+ find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<class T, class Proj = identity,
+ indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
+ constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<copyable T, class Proj = identity,
+ indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
+ constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
+ constexpr range_value_t<R>
+ min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<class T, class Proj = identity,
+ indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
+ constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<copyable T, class Proj = identity,
+ indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
+ constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
+ constexpr range_value_t<R>
+ max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<class I, class O>
+ using unary_transform_result = in_out_result<I, O>; // since C++20
+
+ template<class I1, class I2, class O>
+ using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
+ copy_constructible F, class Proj = identity>
+ requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
+ constexpr ranges::unary_transform_result<I, O>
+ transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20
+
+ template<input_range R, weakly_incrementable O, copy_constructible F,
+ class Proj = identity>
+ requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
+ constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
+ transform(R&& r, O result, F op, Proj proj = {}); // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ weakly_incrementable O, copy_constructible F, class Proj1 = identity,
+ class Proj2 = identity>
+ requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
+ projected<I2, Proj2>>>
+ constexpr ranges::binary_transform_result<I1, I2, O>
+ transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
+ F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, input_range R2, weakly_incrementable O,
+ copy_constructible F, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
+ projected<iterator_t<R2>, Proj2>>>
+ constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
+ transform(R1&& r1, R2&& r2, O result,
+ F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
+ constexpr iter_difference_t<I>
+ count(I first, S last, const T& value, Proj proj = {}); // since C++20
+
+ template<input_range R, class T, class Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
+ constexpr range_difference_t<R>
+ count(R&& r, const T& value, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr iter_difference_t<I>
+ count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr range_difference_t<R>
+ count_if(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<class T>
+ using minmax_result = min_max_result<T>;
+
+ template<class T, class Proj = identity,
+ indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
+ constexpr ranges::minmax_result<const T&>
+ minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<copyable T, class Proj = identity,
+ indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
+ constexpr ranges::minmax_result<T>
+ minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
+ constexpr ranges::minmax_result<range_value_t<R>>
+ minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<class I>
+ using minmax_element_result = min_max_result<I>;
+
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+ constexpr ranges::minmax_element_result<I>
+ minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
+ minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<class I, class O>
+ using copy_result = in_out_result<I, O>; // since C++20
+
+ template<class I, class O>
+ using copy_n_result = in_out_result<I, O>; // since C++20
+
+ template<class I, class O>
+ using copy_if_result = in_out_result<I, O>; // since C++20
+
+ template<class I1, class I2>
+ using copy_backward_result = in_out_result<I1, I2>; // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
+ requires indirectly_copyable<I, O>
+ constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20
+
+ template<input_range R, weakly_incrementable O>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20
+
+ template<input_iterator I, weakly_incrementable O>
+ requires indirectly_copyable<I, O>
+ constexpr ranges::copy_n_result<I, O>
+ ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires indirectly_copyable<I, O>
+ constexpr ranges::copy_if_result<I, O>
+ ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, weakly_incrementable O, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
+ ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
+
+ template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
+ requires indirectly_copyable<I1, I2>
+ constexpr ranges::copy_backward_result<I1, I2>
+ ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20
+
+ template<bidirectional_range R, bidirectional_iterator I>
+ requires indirectly_copyable<iterator_t<R>, I>
+ constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I>
+ ranges::copy_backward(R&& r, I result); // since C++20
+
+ template<class I, class F>
+ using for_each_result = in_fun_result<I, F>; // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirectly_unary_invocable<projected<I, Proj>> Fun>
+ constexpr ranges::for_each_result<I, Fun>
+ ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
+ constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
+ ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20
+
+ template<input_iterator I, class Proj = identity,
+ indirectly_unary_invocable<projected<I, Proj>> Fun>
+ constexpr ranges::for_each_n_result<I, Fun>
+ ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr I
+ ranges::push_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr borrowed_iterator_t<R>
+ ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr I
+ ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr borrowed_iterator_t<R>
+ ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr I
+ ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr borrowed_iterator_t<R>
+ ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr I
+ ranges::sort_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr borrowed_iterator_t<R>
+ ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+ constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<random_access_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+ constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<random_access_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ constexpr borrowed_iterator_t<R>
+ is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S>
+ requires permutable<I>
+ constexpr I ranges::reverse(I first, S last); // since C++20
+
+ template<bidirectional_range R>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_iterator_t<R> ranges::reverse(R&& r); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr I
+ ranges::sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr borrowed_iterator_t<R>
+ ranges::sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ borrowed_iterator_t<R>
+ ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr I
+ ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr borrowed_iterator_t<R>
+ ranges::partial_sort(R&& r, iterator_t<R> middle, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<class T, output_iterator<const T&> O, sentinel_for<O> S>
+ constexpr O ranges::fill(O first, S last, const T& value); // since C++20
+
+ template<class T, output_range<const T&> R>
+ constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value); // since C++20
+
+ template<class T, output_iterator<const T&> O>
+ constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20
+
+ template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F>
+ requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
+ constexpr O generate(O first, S last, F gen); // Since C++20
+
+ template<class R, copy_constructible F>
+ requires invocable<F&> && output_range<R, invoke_result_t<F&>>
+ constexpr borrowed_iterator_t<R> generate(R&& r, F gen); // Since C++20
+
+ template<input_or_output_iterator O, copy_constructible F>
+ requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
+ constexpr O generate_n(O first, iter_difference_t<O> n, F gen); // Since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
+ constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2,
+ Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, input_range R2, class Pred = ranges::equal_to,
+ class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
+ constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1,
+ random_access_iterator I2, sentinel_for<I2> S2,
+ class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> &&
+ indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
+ constexpr partial_sort_copy_result<I1, I2>
+ partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<input_range R1, random_access_range R2, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> &&
+ sortable<iterator_t<R2>, Comp, Proj2> &&
+ indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>,
+ projected<iterator_t<R2>, Proj2>>
+ constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
+ partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+ constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+ constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+ constexpr borrowed_iterator_t<R>
+ ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr I
+ ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr borrowed_iterator_t<R>
+ ranges::nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
+ indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
+ constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_range R, class T, class Proj = identity,
+ indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
+ ranges::less>
+ constexpr borrowed_iterator_t<R>
+ upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
+ indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
+ constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
+ Proj proj = {}); // since C++20
+ template<forward_range R, class T, class Proj = identity,
+ indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
+ ranges::less>
+ constexpr borrowed_iterator_t<R>
+ lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
+ indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
+ constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
+ Proj proj = {}); // since C++20
+
+ template<forward_range R, class T, class Proj = identity,
+ indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
+ ranges::less>
+ constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
+ Proj proj = {}); // since C++20
+
+ template<permutable I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr subrange<I>
+ partition(I first, S last, Pred pred, Proj proj = {}); // Since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_subrange_t<R>
+ partition(R&& r, Pred pred, Proj proj = {}); // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires permutable<I>
+ subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {}); // Since C++20
+
+ template<bidirectional_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires permutable<iterator_t<R>>
+ borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {}); // Since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
+ class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
+ constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
+ Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, forward_range R2,
+ class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
+ constexpr borrowed_iterator_t<R1>
+ ranges::find_first_of(R1&& r1, R2&& r2,
+ Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_binary_predicate<projected<I, Proj>,
+ projected<I, Proj>> Pred = ranges::equal_to>
+ constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C+20
+
+ template<forward_range R, class Proj = identity,
+ indirect_binary_predicate<projected<iterator_t<R>, Proj>,
+ projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
+ constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class T1, class T2, class Proj = identity>
+ requires indirectly_writable<I, const T2&> &&
+ indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
+ constexpr I
+ ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
+
+ template<input_range R, class T1, class T2, class Proj = identity>
+ requires indirectly_writable<iterator_t<R>, const T2&> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
+ constexpr borrowed_iterator_t<R>
+ ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires indirectly_writable<I, const T&>
+ constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20
+
+ template<input_range R, class T, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires indirectly_writable<iterator_t<R>, const T&>
+ constexpr borrowed_iterator_t<R>
+ ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ class Proj1 = identity, class Proj2 = identity,
+ indirect_strict_weak_order<projected<I1, Proj1>,
+ projected<I2, Proj2>> Comp = ranges::less>
+ constexpr bool
+ ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, input_range R2, class Proj1 = identity,
+ class Proj2 = identity,
+ indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
+ projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
+ constexpr bool
+ ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
+ requires indirectly_movable<I1, I2>
+ constexpr ranges::move_backward_result<I1, I2>
+ ranges::move_backward(I1 first, S1 last, I2 result); // since C++20
+
+ template<bidirectional_range R, bidirectional_iterator I>
+ requires indirectly_movable<iterator_t<R>, I>
+ constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I>
+ ranges::move_backward(R&& r, I result); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
+ requires indirectly_movable<I, O>
+ constexpr ranges::move_result<I, O>
+ ranges::move(I first, S last, O result); // since C++20
+
+ template<input_range R, weakly_incrementable O>
+ requires indirectly_movable<iterator_t<R>, O>
+ constexpr ranges::move_result<borrowed_iterator_t<R>, O>
+ ranges::move(R&& r, O result); // since C++20
+
+ template<class I, class O1, class O2>
+ using partition_copy_result = in_out_out_result<I, O1, O2>; // since C++20
+
+ template<input_iterator I, sentinel_for<I> S,
+ weakly_incrementable O1, weakly_incrementable O2,
+ class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires indirectly_copyable<I, O1> && indirectly_copyable<I, O2>
+ constexpr partition_copy_result<I, O1, O2>
+ partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred,
+ Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O1, weakly_incrementable O2,
+ class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires indirectly_copyable<iterator_t<R>, O1> &&
+ indirectly_copyable<iterator_t<R>, O2>
+ constexpr partition_copy_result<borrowed_iterator_t<R>, O1, O2>
+ partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // Since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr I partition_point(I first, S last, Pred pred, Proj proj = {}); // Since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr borrowed_iterator_t<R>
+ partition_point(R&& r, Pred pred, Proj proj = {}); // Since C++20
+
+ template<class I1, class I2, class O>
+ using merge_result = in_in_out_result<I1, I2, O>; // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity,
+ class Proj2 = identity>
+ requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
+ constexpr merge_result<I1, I2, O>
+ merge(I1 first1, S1 last1, I2 first2, S2 last2, O result,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, input_range R2, weakly_incrementable O, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
+ constexpr merge_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
+ merge(R1&& r1, R2&& r2, O result,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<permutable I, sentinel_for<I> S, class T, class Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
+ constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {}); // since C++20
+
+ template<forward_range R, class T, class Proj = identity>
+ requires permutable<iterator_t<R>> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
+ constexpr borrowed_subrange_t<R>
+ ranges::remove(R&& r, const T& value, Proj proj = {}); // since C++20
+
+ template<permutable I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_subrange_t<R>
+ ranges::remove_if(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<class I, class O>
+ using set_difference_result = in_out_result<I, O>; // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ weakly_incrementable O, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
+ constexpr set_difference_result<I1, O>
+ set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, input_range R2, weakly_incrementable O,
+ class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
+ constexpr set_difference_result<borrowed_iterator_t<R1>, O>
+ set_difference(R1&& r1, R2&& r2, O result,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<class I1, class I2, class O>
+ using set_intersection_result = in_in_out_result<I1, I2, O>; // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ weakly_incrementable O, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
+ constexpr set_intersection_result<I1, I2, O>
+ set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ weakly_incrementable O, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
+ constexpr set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
+ set_intersection(R1&& r1, R2&& r2, O result,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template <class _InIter, class _OutIter>
+ using reverse_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, weakly_incrementable O>
+ requires indirectly_copyable<I, O>
+ constexpr ranges::reverse_copy_result<I, O>
+ ranges::reverse_copy(I first, S last, O result); // since C++20
+
+ template<bidirectional_range R, weakly_incrementable O>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O>
+ ranges::reverse_copy(R&& r, O result); // since C++20
+
+ template <class _InIter, class _OutIter>
+ using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, weakly_incrementable O>
+ requires indirectly_copyable<I, O>
+ constexpr ranges::rotate_copy_result<I, O>
+ ranges::rotate_copy(I first, I middle, S last, O result); // since C++20
+
+ template<forward_range R, weakly_incrementable O>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
+ ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Gen>
+ requires permutable<I> &&
+ uniform_random_bit_generator<remove_reference_t<Gen>>
+ I shuffle(I first, S last, Gen&& g); // Since C++20
+
+ template<random_access_range R, class Gen>
+ requires permutable<iterator_t<R>> &&
+ uniform_random_bit_generator<remove_reference_t<Gen>>
+ borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // Since C++20
+
+ template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
+ sentinel_for<I2> S2, class Pred = ranges::equal_to,
+ class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
+ constexpr subrange<I1>
+ ranges::search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<forward_range R1, forward_range R2, class Pred = ranges::equal_to,
+ class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
+ constexpr borrowed_subrange_t<R1>
+ ranges::search(R1&& r1, R2&& r2, Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class T,
+ class Pred = ranges::equal_to, class Proj = identity>
+ requires indirectly_comparable<I, const T*, Pred, Proj>
+ constexpr subrange<I>
+ ranges::search_n(I first, S last, iter_difference_t<I> count,
+ const T& value, Pred pred = {}, Proj proj = {}); // since C++20
+
+ template<forward_range R, class T, class Pred = ranges::equal_to,
+ class Proj = identity>
+ requires indirectly_comparable<iterator_t<R>, const T*, Pred, Proj>
+ constexpr borrowed_subrange_t<R>
+ ranges::search_n(R&& r, range_difference_t<R> count,
+ const T& value, Pred pred = {}, Proj proj = {}); // since C++20
+
+ template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
+ class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
+ constexpr subrange<I1>
+ ranges::find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<forward_range R1, forward_range R2,
+ class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
+ constexpr borrowed_subrange_t<R1>
+ ranges::find_end(R1&& r1, R2&& r2, Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<class I1, class I2, class O>
+ using set_symmetric_difference_result = in_in_out_result<I1, I2, O>; // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ weakly_incrementable O, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
+ constexpr set_symmetric_difference_result<I1, I2, O>
+ set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
+ Comp comp = {}, Proj1 proj1 = {},
+ Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, input_range R2, weakly_incrementable O,
+ class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
+ constexpr set_symmetric_difference_result<borrowed_iterator_t<R1>,
+ borrowed_iterator_t<R2>, O>
+ set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
+ indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
+ constexpr subrange<I>
+ equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<forward_range R, class T, class Proj = identity,
+ indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
+ ranges::less>
+ constexpr borrowed_subrange_t<R>
+ equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<class I1, class I2, class O>
+ using set_union_result = in_in_out_result<I1, I2, O>; // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ weakly_incrementable O, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
+ constexpr set_union_result<I1, I2, O>
+ set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, input_range R2, weakly_incrementable O,
+ class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
+ constexpr set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
+ set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ class Proj1 = identity, class Proj2 = identity,
+ indirect_strict_weak_order<projected<I1, Proj1>, projected<I2, Proj2>> Comp =
+ ranges::less>
+ constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<input_range R1, input_range R2, class Proj1 = identity,
+ class Proj2 = identity,
+ indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
+ projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
+ constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ borrowed_iterator_t<R>
+ inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
+ Proj proj = {}); // Since C++20
+
+ template<permutable I, sentinel_for<I> S, class Proj = identity,
+ indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
+ constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_subrange_t<R>
+ unique(R&& r, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
+ indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
+ requires indirectly_copyable<I, O> &&
+ (forward_iterator<I> ||
+ (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
+ indirectly_copyable_storable<I, O>)
+ constexpr unique_copy_result<I, O>
+ unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
+ requires indirectly_copyable<iterator_t<R>, O> &&
+ (forward_iterator<iterator_t<R>> ||
+ (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
+ indirectly_copyable_storable<iterator_t<R>, O>)
+ constexpr unique_copy_result<borrowed_iterator_t<R>, O>
+ unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20
}
-template <class InputIterator, class Predicate>
constexpr bool // constexpr in C++20
all_of(InputIterator first, InputIterator last, Predicate pred);
@@ -192,10 +1079,35 @@ template <class BidirectionalIterator1, class BidirectionalIterator2>
copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
BidirectionalIterator2 result);
+// [alg.move], move
+template<class InputIterator, class OutputIterator>
+ constexpr OutputIterator move(InputIterator first, InputIterator last,
+ OutputIterator result);
+
+template<class BidirectionalIterator1, class BidirectionalIterator2>
+ constexpr BidirectionalIterator2
+ move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
+ BidirectionalIterator2 result);
+
template <class ForwardIterator1, class ForwardIterator2>
constexpr ForwardIterator2 // constexpr in C++20
swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
+namespace ranges {
+ template<class I1, class I2>
+ using swap_ranges_result = in_in_result<I1, I2>;
+
+template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
+ requires indirectly_swappable<I1, I2>
+ constexpr ranges::swap_ranges_result<I1, I2>
+ swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
+
+template<input_range R1, input_range R2>
+ requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
+ constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
+ swap_ranges(R1&& r1, R2&& r2);
+}
+
template <class ForwardIterator1, class ForwardIterator2>
constexpr void // constexpr in C++20
iter_swap(ForwardIterator1 a, ForwardIterator2 b);
@@ -648,28 +1560,18 @@ template <class BidirectionalIterator>
template <class BidirectionalIterator, class Compare>
constexpr bool // constexpr in C++20
prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
-
-namespace ranges {
-// [algorithms.results], algorithm result types
-template<class InputIterator, class OutputIterator>
- struct in_out_result;
-}
-
} // std
*/
-#include <__bits> // __libcpp_clz
+#include <__assert> // all public C++ headers provide the assertion handler
+#include <__bits>
#include <__config>
#include <__debug>
#include <cstddef>
#include <cstring>
-#include <functional>
-#include <initializer_list>
-#include <iterator>
#include <memory>
#include <type_traits>
-#include <utility> // swap_ranges
#include <version>
#include <__algorithm/adjacent_find.h>
@@ -699,8 +1601,11 @@ template<class InputIterator, class OutputIterator>
#include <__algorithm/generate.h>
#include <__algorithm/generate_n.h>
#include <__algorithm/half_positive.h>
+#include <__algorithm/in_found_result.h>
+#include <__algorithm/in_fun_result.h>
#include <__algorithm/in_in_out_result.h>
#include <__algorithm/in_in_result.h>
+#include <__algorithm/in_out_out_result.h>
#include <__algorithm/in_out_result.h>
#include <__algorithm/includes.h>
#include <__algorithm/inplace_merge.h>
@@ -719,6 +1624,7 @@ template<class InputIterator, class OutputIterator>
#include <__algorithm/merge.h>
#include <__algorithm/min.h>
#include <__algorithm/min_element.h>
+#include <__algorithm/min_max_result.h>
#include <__algorithm/minmax.h>
#include <__algorithm/minmax_element.h>
#include <__algorithm/mismatch.h>
@@ -735,6 +1641,81 @@ template<class InputIterator, class OutputIterator>
#include <__algorithm/pop_heap.h>
#include <__algorithm/prev_permutation.h>
#include <__algorithm/push_heap.h>
+#include <__algorithm/ranges_adjacent_find.h>
+#include <__algorithm/ranges_all_of.h>
+#include <__algorithm/ranges_any_of.h>
+#include <__algorithm/ranges_binary_search.h>
+#include <__algorithm/ranges_copy.h>
+#include <__algorithm/ranges_copy_backward.h>
+#include <__algorithm/ranges_copy_if.h>
+#include <__algorithm/ranges_copy_n.h>
+#include <__algorithm/ranges_count.h>
+#include <__algorithm/ranges_count_if.h>
+#include <__algorithm/ranges_equal.h>
+#include <__algorithm/ranges_equal_range.h>
+#include <__algorithm/ranges_fill.h>
+#include <__algorithm/ranges_fill_n.h>
+#include <__algorithm/ranges_find.h>
+#include <__algorithm/ranges_find_end.h>
+#include <__algorithm/ranges_find_first_of.h>
+#include <__algorithm/ranges_find_if.h>
+#include <__algorithm/ranges_find_if_not.h>
+#include <__algorithm/ranges_for_each.h>
+#include <__algorithm/ranges_for_each_n.h>
+#include <__algorithm/ranges_generate.h>
+#include <__algorithm/ranges_generate_n.h>
+#include <__algorithm/ranges_includes.h>
+#include <__algorithm/ranges_inplace_merge.h>
+#include <__algorithm/ranges_is_heap.h>
+#include <__algorithm/ranges_is_heap_until.h>
+#include <__algorithm/ranges_is_partitioned.h>
+#include <__algorithm/ranges_is_sorted.h>
+#include <__algorithm/ranges_is_sorted_until.h>
+#include <__algorithm/ranges_lexicographical_compare.h>
+#include <__algorithm/ranges_lower_bound.h>
+#include <__algorithm/ranges_make_heap.h>
+#include <__algorithm/ranges_max.h>
+#include <__algorithm/ranges_max_element.h>
+#include <__algorithm/ranges_merge.h>
+#include <__algorithm/ranges_min.h>
+#include <__algorithm/ranges_min_element.h>
+#include <__algorithm/ranges_minmax.h>
+#include <__algorithm/ranges_minmax_element.h>
+#include <__algorithm/ranges_mismatch.h>
+#include <__algorithm/ranges_move.h>
+#include <__algorithm/ranges_move_backward.h>
+#include <__algorithm/ranges_none_of.h>
+#include <__algorithm/ranges_nth_element.h>
+#include <__algorithm/ranges_partial_sort.h>
+#include <__algorithm/ranges_partial_sort_copy.h>
+#include <__algorithm/ranges_partition.h>
+#include <__algorithm/ranges_partition_copy.h>
+#include <__algorithm/ranges_partition_point.h>
+#include <__algorithm/ranges_pop_heap.h>
+#include <__algorithm/ranges_push_heap.h>
+#include <__algorithm/ranges_remove.h>
+#include <__algorithm/ranges_remove_if.h>
+#include <__algorithm/ranges_replace.h>
+#include <__algorithm/ranges_replace_if.h>
+#include <__algorithm/ranges_reverse.h>
+#include <__algorithm/ranges_reverse_copy.h>
+#include <__algorithm/ranges_rotate_copy.h>
+#include <__algorithm/ranges_search.h>
+#include <__algorithm/ranges_search_n.h>
+#include <__algorithm/ranges_set_difference.h>
+#include <__algorithm/ranges_set_intersection.h>
+#include <__algorithm/ranges_set_symmetric_difference.h>
+#include <__algorithm/ranges_set_union.h>
+#include <__algorithm/ranges_shuffle.h>
+#include <__algorithm/ranges_sort.h>
+#include <__algorithm/ranges_sort_heap.h>
+#include <__algorithm/ranges_stable_partition.h>
+#include <__algorithm/ranges_stable_sort.h>
+#include <__algorithm/ranges_swap_ranges.h>
+#include <__algorithm/ranges_transform.h>
+#include <__algorithm/ranges_unique.h>
+#include <__algorithm/ranges_unique_copy.h>
+#include <__algorithm/ranges_upper_bound.h>
#include <__algorithm/remove.h>
#include <__algorithm/remove_copy.h>
#include <__algorithm/remove_copy_if.h>
@@ -769,8 +1750,17 @@ template<class InputIterator, class OutputIterator>
#include <__algorithm/unwrap_iter.h>
#include <__algorithm/upper_bound.h>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <chrono>
+# include <iterator>
+# include <utility>
+#endif
+
+// standard-mandated includes
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
lib/libcxx/include/any
@@ -80,17 +80,26 @@ namespace std {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <__utility/unreachable.h>
#include <cstdlib>
+#include <initializer_list>
#include <memory>
#include <type_traits>
#include <typeinfo>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <chrono>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
namespace std {
@@ -262,7 +271,7 @@ public:
is_copy_constructible<_Tp>::value>
>
_LIBCPP_INLINE_VISIBILITY
- _Tp& emplace(_Args&&... args);
+ _Tp& emplace(_Args&&...);
template <class _ValueType, class _Up, class ..._Args,
class _Tp = decay_t<_ValueType>,
@@ -364,6 +373,7 @@ namespace __any_imp
case _Action::_TypeInfo:
return __type_info();
}
+ __libcpp_unreachable();
}
template <class ..._Args>
@@ -447,6 +457,7 @@ namespace __any_imp
case _Action::_TypeInfo:
return __type_info();
}
+ __libcpp_unreachable();
}
template <class ..._Args>
@@ -658,6 +669,7 @@ _RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept {
}
template <class _ValueType>
+_LIBCPP_HIDE_FROM_ABI
add_pointer_t<_ValueType>
any_cast(any * __any) _NOEXCEPT
{
lib/libcxx/include/array
@@ -108,19 +108,42 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
*/
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/swap_ranges.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__debug>
+#include <__iterator/reverse_iterator.h>
#include <__tuple>
-#include <algorithm>
-#include <cstdlib> // for _LIBCPP_UNREACHABLE
-#include <iterator>
+#include <__utility/integer_sequence.h>
+#include <__utility/move.h>
+#include <__utility/unreachable.h>
#include <stdexcept>
#include <type_traits>
-#include <utility>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <iterator>
+# include <utility>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [array.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -309,54 +332,54 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reference operator[](size_type) _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const_reference operator[](size_type) const _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reference at(size_type) {
__throw_out_of_range("array<T, 0>::at");
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const_reference at(size_type) const {
__throw_out_of_range("array<T, 0>::at");
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reference front() _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const_reference front() const _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reference back() _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const_reference back() const _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
};
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER > 14
template<class _Tp, class... _Args,
class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value>
>
@@ -415,12 +438,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
template <class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-typename enable_if
-<
- _Size == 0 ||
- __is_swappable<_Tp>::value,
- void
->::type
+__enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void>
swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
_NOEXCEPT_(noexcept(__x.swap(__y)))
{
lib/libcxx/include/atomic
@@ -518,7 +518,9 @@ template <class T>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
+#include <__chrono/duration.h>
#include <__config>
#include <__thread/poll_with_backoff.h>
#include <__thread/timed_backoff_policy.h>
@@ -532,15 +534,19 @@ template <class T>
# include <__threading_support>
#endif
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <chrono>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER
# error <atomic> is not implemented
#endif
#ifdef kill_dependency
-# error C++ standard library is incompatible with <stdatomic.h>
+# error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23.
#endif
#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \
@@ -900,8 +906,8 @@ struct __cxx_atomic_base_impl {
#else
__cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT
- : __a_value(value) {}
+ _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT
+ : __a_value(__value) {}
_LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;
};
@@ -1445,15 +1451,15 @@ struct __cxx_atomic_impl : public _Base {
"std::atomic<T> requires that 'T' be a trivially copyable type");
_LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT = default;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp value) _NOEXCEPT
- : _Base(value) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT
+ : _Base(__value) {}
};
-#ifdef __linux__
+#if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__))
using __cxx_contention_t = int32_t;
#else
using __cxx_contention_t = int64_t;
-#endif //__linux__
+#endif // __linux__ || (_AIX && !__64BIT__)
using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
@@ -1651,13 +1657,7 @@ struct __atomic_base // false
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
-#ifndef _LIBCPP_CXX03_LANG
__atomic_base(const __atomic_base&) = delete;
-#else
-private:
- _LIBCPP_INLINE_VISIBILITY
- __atomic_base(const __atomic_base&);
-#endif
};
#if defined(__cpp_lib_atomic_is_always_lock_free)
@@ -2439,19 +2439,10 @@ typedef struct atomic_flag
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
-#ifndef _LIBCPP_CXX03_LANG
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) volatile = delete;
-#else
-private:
- _LIBCPP_INLINE_VISIBILITY
- atomic_flag(const atomic_flag&);
- _LIBCPP_INLINE_VISIBILITY
- atomic_flag& operator=(const atomic_flag&);
- _LIBCPP_INLINE_VISIBILITY
- atomic_flag& operator=(const atomic_flag&) volatile;
-#endif
+
} atomic_flag;
@@ -2705,7 +2696,6 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1400
-# pragma clang deprecated(ATOMIC_FLAG_INIT)
# pragma clang deprecated(ATOMIC_VAR_INIT)
# endif
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
lib/libcxx/include/barrier
@@ -45,20 +45,20 @@ namespace std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <__thread/timed_backoff_policy.h>
#include <atomic>
-#ifndef _LIBCPP_HAS_NO_TREE_BARRIER
-# include <memory>
-#endif
+#include <limits>
+#include <memory>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef _LIBCPP_HAS_NO_THREADS
-# error <barrier> is not supported on this single threaded system
+# error "<barrier> is not supported since libc++ has been configured without support for threads."
#endif
_LIBCPP_PUSH_MACROS
@@ -108,12 +108,12 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);
template<class _CompletionF>
class __barrier_base {
- ptrdiff_t __expected;
+ ptrdiff_t __expected_;
unique_ptr<__barrier_algorithm_base,
- void (*)(__barrier_algorithm_base*)> __base;
- __atomic_base<ptrdiff_t> __expected_adjustment;
- _CompletionF __completion;
- __atomic_base<__barrier_phase_t> __phase;
+ void (*)(__barrier_algorithm_base*)> __base_;
+ __atomic_base<ptrdiff_t> __expected_adjustment_;
+ _CompletionF __completion_;
+ __atomic_base<__barrier_phase_t> __phase_;
public:
using arrival_token = __barrier_phase_t;
@@ -124,22 +124,22 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
__barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
- : __expected(__expected), __base(__construct_barrier_algorithm_base(this->__expected),
- &__destroy_barrier_algorithm_base),
- __expected_adjustment(0), __completion(move(__completion)), __phase(0)
+ : __expected_(__expected), __base_(__construct_barrier_algorithm_base(this->__expected_),
+ &__destroy_barrier_algorithm_base),
+ __expected_adjustment_(0), __completion_(std::move(__completion)), __phase_(0)
{
}
[[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
- arrival_token arrive(ptrdiff_t update)
+ arrival_token arrive(ptrdiff_t __update)
{
- auto const __old_phase = __phase.load(memory_order_relaxed);
- for(; update; --update)
- if(__arrive_barrier_algorithm_base(__base.get(), __old_phase)) {
- __completion();
- __expected += __expected_adjustment.load(memory_order_relaxed);
- __expected_adjustment.store(0, memory_order_relaxed);
- __phase.store(__old_phase + 2, memory_order_release);
- __phase.notify_all();
+ auto const __old_phase = __phase_.load(memory_order_relaxed);
+ for(; __update; --__update)
+ if(__arrive_barrier_algorithm_base(__base_.get(), __old_phase)) {
+ __completion_();
+ __expected_ += __expected_adjustment_.load(memory_order_relaxed);
+ __expected_adjustment_.store(0, memory_order_relaxed);
+ __phase_.store(__old_phase + 2, memory_order_release);
+ __phase_.notify_all();
}
return __old_phase;
}
@@ -147,14 +147,14 @@ public:
void wait(arrival_token&& __old_phase) const
{
auto const __test_fn = [this, __old_phase]() -> bool {
- return __phase.load(memory_order_acquire) != __old_phase;
+ return __phase_.load(memory_order_acquire) != __old_phase;
};
__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
{
- __expected_adjustment.fetch_sub(1, memory_order_relaxed);
+ __expected_adjustment_.fetch_sub(1, memory_order_relaxed);
(void)arrive(1);
}
};
@@ -190,7 +190,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
- : __expected(__expected), __arrived(__expected), __completion(move(__completion)), __phase(false)
+ : __expected(__expected), __arrived(__expected), __completion(std::move(__completion)), __phase(false)
{
}
[[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
@@ -278,7 +278,7 @@ public:
}
};
-#endif //_LIBCPP_HAS_NO_TREE_BARRIER
+#endif // !_LIBCPP_HAS_NO_TREE_BARRIER
template<class _CompletionF = __empty_completion>
class barrier {
@@ -300,9 +300,9 @@ public:
barrier& operator=(barrier const&) = delete;
[[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
- arrival_token arrive(ptrdiff_t update = 1)
+ arrival_token arrive(ptrdiff_t __update = 1)
{
- return __b.arrive(update);
+ return __b.arrive(__update);
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __phase) const
lib/libcxx/include/bit
@@ -30,7 +30,7 @@ namespace std {
template <class T>
constexpr T bit_floor(T x) noexcept; // C++20
template <class T>
- constexpr T bit_width(T x) noexcept; // C++20
+ constexpr int bit_width(T x) noexcept; // C++20
// [bit.rotate], rotating
template<class T>
@@ -61,24 +61,26 @@ namespace std {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__bit/bit_cast.h>
#include <__bit/byteswap.h>
#include <__bits> // __libcpp_clz
+#include <__concepts/arithmetic.h>
#include <__config>
-#include <__debug>
#include <limits>
#include <type_traits>
#include <version>
-#if defined(__IBMCPP__)
-#include "__support/ibm/support.h"
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iosfwd>
#endif
+
#if defined(_LIBCPP_COMPILER_MSVC)
-#include <intrin.h>
+# include <intrin.h>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -87,18 +89,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp __rotl(_Tp __t, unsigned int __cnt) _NOEXCEPT
-{
- static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");
- const unsigned int __dig = numeric_limits<_Tp>::digits;
- if ((__cnt % __dig) == 0)
- return __t;
- return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
-}
-
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
{
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
@@ -109,34 +100,7 @@ _Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
}
template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-int __countr_zero(_Tp __t) _NOEXCEPT
-{
- static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero requires an unsigned integer type");
- if (__t == 0)
- return numeric_limits<_Tp>::digits;
-
- if (sizeof(_Tp) <= sizeof(unsigned int))
- return __libcpp_ctz(static_cast<unsigned int>(__t));
- else if (sizeof(_Tp) <= sizeof(unsigned long))
- return __libcpp_ctz(static_cast<unsigned long>(__t));
- else if (sizeof(_Tp) <= sizeof(unsigned long long))
- return __libcpp_ctz(static_cast<unsigned long long>(__t));
- else
- {
- int __ret = 0;
- const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
- while (static_cast<unsigned long long>(__t) == 0uLL)
- {
- __ret += __ulldigits;
- __t >>= __ulldigits;
- }
- return __ret + __libcpp_ctz(static_cast<unsigned long long>(__t));
- }
-}
-
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
int __countl_zero(_Tp __t) _NOEXCEPT
{
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
@@ -144,13 +108,13 @@ int __countl_zero(_Tp __t) _NOEXCEPT
return numeric_limits<_Tp>::digits;
if (sizeof(_Tp) <= sizeof(unsigned int))
- return __libcpp_clz(static_cast<unsigned int>(__t))
+ return std::__libcpp_clz(static_cast<unsigned int>(__t))
- (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
else if (sizeof(_Tp) <= sizeof(unsigned long))
- return __libcpp_clz(static_cast<unsigned long>(__t))
+ return std::__libcpp_clz(static_cast<unsigned long>(__t))
- (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);
else if (sizeof(_Tp) <= sizeof(unsigned long long))
- return __libcpp_clz(static_cast<unsigned long long>(__t))
+ return std::__libcpp_clz(static_cast<unsigned long long>(__t))
- (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);
else
{
@@ -158,8 +122,8 @@ int __countl_zero(_Tp __t) _NOEXCEPT
int __iter = 0;
const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
while (true) {
- __t = __rotr(__t, __ulldigits);
- if ((__iter = __countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
+ __t = std::__rotr(__t, __ulldigits);
+ if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
break;
__ret += __iter;
}
@@ -167,178 +131,123 @@ int __countl_zero(_Tp __t) _NOEXCEPT
}
}
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-int __countl_one(_Tp __t) _NOEXCEPT
-{
- static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_one requires an unsigned integer type");
- return __t != numeric_limits<_Tp>::max()
- ? __countl_zero(static_cast<_Tp>(~__t))
- : numeric_limits<_Tp>::digits;
-}
-
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-int __countr_one(_Tp __t) _NOEXCEPT
-{
- static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_one requires an unsigned integer type");
- return __t != numeric_limits<_Tp>::max()
- ? __countr_zero(static_cast<_Tp>(~__t))
- : numeric_limits<_Tp>::digits;
-}
-
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-int __popcount(_Tp __t) _NOEXCEPT
-{
- static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__popcount requires an unsigned integer type");
- if (sizeof(_Tp) <= sizeof(unsigned int))
- return __libcpp_popcount(static_cast<unsigned int>(__t));
- else if (sizeof(_Tp) <= sizeof(unsigned long))
- return __libcpp_popcount(static_cast<unsigned long>(__t));
- else if (sizeof(_Tp) <= sizeof(unsigned long long))
- return __libcpp_popcount(static_cast<unsigned long long>(__t));
- else
- {
- int __ret = 0;
- while (__t != 0)
- {
- __ret += __libcpp_popcount(static_cast<unsigned long long>(__t));
- __t >>= numeric_limits<unsigned long long>::digits;
- }
- return __ret;
- }
-}
-
-// integral log base 2
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-unsigned __bit_log2(_Tp __t) _NOEXCEPT
-{
- static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type");
- return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
-}
-
-template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-bool __has_single_bit(_Tp __t) _NOEXCEPT
-{
- static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__has_single_bit requires an unsigned integer type");
- return __t != 0 && (((__t & (__t - 1)) == 0));
-}
-
#if _LIBCPP_STD_VER > 17
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
-rotl(_Tp __t, unsigned int __cnt) noexcept
-{
- return __rotl(__t, __cnt);
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept {
+ const unsigned int __dig = numeric_limits<_Tp>::digits;
+ if ((__cnt % __dig) == 0)
+ return __t;
+ return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
}
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
-rotr(_Tp __t, unsigned int __cnt) noexcept
-{
- return __rotr(__t, __cnt);
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept {
+ return std::__rotr(__t, __cnt);
}
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
-countl_zero(_Tp __t) noexcept
-{
- return __countl_zero(__t);
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
+ return std::__countl_zero(__t);
}
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
-countl_one(_Tp __t) noexcept
-{
- return __countl_one(__t);
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
+ return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
}
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
-countr_zero(_Tp __t) noexcept
-{
- return __countr_zero(__t);
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
+ if (__t == 0)
+ return numeric_limits<_Tp>::digits;
+
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return std::__libcpp_ctz(static_cast<unsigned int>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return std::__libcpp_ctz(static_cast<unsigned long>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return std::__libcpp_ctz(static_cast<unsigned long long>(__t));
+ else {
+ int __ret = 0;
+ const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
+ while (static_cast<unsigned long long>(__t) == 0uLL) {
+ __ret += __ulldigits;
+ __t >>= __ulldigits;
+ }
+ return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
+ }
}
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
-countr_one(_Tp __t) noexcept
-{
- return __countr_one(__t);
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
+ return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
}
-template<class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
-popcount(_Tp __t) noexcept
-{
- return __popcount(__t);
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return std::__libcpp_popcount(static_cast<unsigned int>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return std::__libcpp_popcount(static_cast<unsigned long>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return std::__libcpp_popcount(static_cast<unsigned long long>(__t));
+ else {
+ int __ret = 0;
+ while (__t != 0) {
+ __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t));
+ __t >>= numeric_limits<unsigned long long>::digits;
+ }
+ return __ret;
+ }
}
-template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, bool>
-has_single_bit(_Tp __t) noexcept
-{
- return __has_single_bit(__t);
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
+ return __t != 0 && (((__t & (__t - 1)) == 0));
}
-template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
-bit_floor(_Tp __t) noexcept
-{
- return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
+// integral log base 2
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {
+ return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t);
}
-template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
-bit_ceil(_Tp __t) noexcept
-{
- if (__t < 2) return 1;
- const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));
- _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
+ return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);
+}
- if constexpr (sizeof(_Tp) >= sizeof(unsigned))
- return _Tp{1} << __n;
- else
- {
- const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits;
- const unsigned __retVal = 1u << (__n + __extra);
- return (_Tp) (__retVal >> __extra);
- }
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
+ if (__t < 2)
+ return 1;
+ const unsigned __n = numeric_limits<_Tp>::digits - std::countl_zero((_Tp)(__t - 1u));
+ _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
+
+ if constexpr (sizeof(_Tp) >= sizeof(unsigned))
+ return _Tp{1} << __n;
+ else {
+ const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits;
+ const unsigned __retVal = 1u << (__n + __extra);
+ return (_Tp)(__retVal >> __extra);
+ }
}
-template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
-bit_width(_Tp __t) noexcept
-{
- return __t == 0 ? 0 : __bit_log2(__t) + 1;
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
+ return __t == 0 ? 0 : std::__bit_log2(__t) + 1;
}
-enum class endian
-{
- little = 0xDEAD,
- big = 0xFACE,
-#if defined(_LIBCPP_LITTLE_ENDIAN)
- native = little
-#elif defined(_LIBCPP_BIG_ENDIAN)
- native = big
-#else
- native = 0xCAFE
-#endif
+enum class endian {
+ little = 0xDEAD,
+ big = 0xFACE,
+# if defined(_LIBCPP_LITTLE_ENDIAN)
+ native = little
+# elif defined(_LIBCPP_BIG_ENDIAN)
+ native = big
+# else
+ native = 0xCAFE
+# endif
};
#endif // _LIBCPP_STD_VER > 17
lib/libcxx/include/bitset
@@ -112,18 +112,23 @@ template <size_t N> struct hash<std::bitset<N>>;
*/
+#include <__algorithm/fill.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__bit_reference>
#include <__config>
-#include <__functional_base>
+#include <__functional/hash.h>
+#include <__functional/unary_function.h>
#include <climits>
#include <cstddef>
-#include <iosfwd>
#include <stdexcept>
-#include <string>
#include <version>
+// standard-mandated includes
+#include <iosfwd>
+#include <string>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -713,9 +718,12 @@ public:
bitset& flip(size_t __pos);
// element access:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
- _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);}
+#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const {return base::__make_ref(__p);}
+#else
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
+#endif
+ _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __p) {return base::__make_ref(__p);}
_LIBCPP_INLINE_VISIBILITY
unsigned long to_ulong() const;
_LIBCPP_INLINE_VISIBILITY
@@ -946,7 +954,7 @@ basic_string<_CharT, _Traits, _Allocator>
bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
{
basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);
- for (size_t __i = 0; __i < _Size; ++__i)
+ for (size_t __i = 0; __i != _Size; ++__i)
{
if ((*this)[__i])
__r[_Size - 1 - __i] = __one;
@@ -1082,7 +1090,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
template <size_t _Size>
struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
- : public unary_function<bitset<_Size>, size_t>
+ : public __unary_function<bitset<_Size>, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT
lib/libcxx/include/cassert
@@ -16,9 +16,10 @@ Macros:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <assert.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
lib/libcxx/include/ccomplex
@@ -17,12 +17,11 @@
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <complex>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-// hh 080623 Created
-
#endif // _LIBCPP_CCOMPLEX
lib/libcxx/include/cctype
@@ -34,11 +34,12 @@ int toupper(int c);
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <ctype.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cerrno
@@ -22,11 +22,12 @@ Macros:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <errno.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_CERRNO
lib/libcxx/include/cfenv
@@ -52,11 +52,12 @@ int feupdateenv(const fenv_t* envp);
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <fenv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cfloat
@@ -69,11 +69,12 @@ Macros:
LDBL_TRUE_MIN // C11
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <float.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_CFLOAT
lib/libcxx/include/charconv
@@ -77,24 +77,32 @@ namespace std {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__bits>
#include <__charconv/chars_format.h>
#include <__charconv/from_chars_result.h>
+#include <__charconv/tables.h>
+#include <__charconv/to_chars_base_10.h>
#include <__charconv/to_chars_result.h>
#include <__config>
+#include <__debug>
#include <__errc>
+#include <__type_traits/make_32_64_or_128_bit.h>
+#include <__utility/unreachable.h>
#include <cmath> // for log2f
#include <cstdint>
-#include <cstdlib> // for _LIBCPP_UNREACHABLE
+#include <cstdlib>
#include <cstring>
#include <limits>
#include <type_traits>
-#include <__debug>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iosfwd>
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -102,11 +110,6 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-namespace __itoa {
-_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT;
-_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT;
-} // namespace __itoa
-
#ifndef _LIBCPP_CXX03_LANG
to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
@@ -115,79 +118,93 @@ from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
namespace __itoa
{
-static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = {
- UINT64_C(0),
- UINT64_C(10),
- UINT64_C(100),
- UINT64_C(1000),
- UINT64_C(10000),
- UINT64_C(100000),
- UINT64_C(1000000),
- UINT64_C(10000000),
- UINT64_C(100000000),
- UINT64_C(1000000000),
- UINT64_C(10000000000),
- UINT64_C(100000000000),
- UINT64_C(1000000000000),
- UINT64_C(10000000000000),
- UINT64_C(100000000000000),
- UINT64_C(1000000000000000),
- UINT64_C(10000000000000000),
- UINT64_C(100000000000000000),
- UINT64_C(1000000000000000000),
- UINT64_C(10000000000000000000),
-};
-
-static _LIBCPP_CONSTEXPR uint32_t __pow10_32[] = {
- UINT32_C(0), UINT32_C(10), UINT32_C(100),
- UINT32_C(1000), UINT32_C(10000), UINT32_C(100000),
- UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000),
- UINT32_C(1000000000),
-};
-
template <typename _Tp, typename = void>
-struct _LIBCPP_HIDDEN __traits_base
+struct _LIBCPP_HIDDEN __traits_base;
+
+template <typename _Tp>
+struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uint32_t)>>
{
- using type = uint64_t;
+ using type = uint32_t;
- static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
+ /// The width estimation using a log10 algorithm.
+ ///
+ /// The algorithm is based on
+ /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
+ /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
+ /// function requires its input to have at least one bit set the value of
+ /// zero is set to one. This means the first element of the lookup table is
+ /// zero.
+ static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v)
{
- auto __t = (64 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
- return __t - (__v < __pow10_64[__t]) + 1;
+ auto __t = (32 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
+ return __t - (__v < __table<>::__pow10_32[__t]) + 1;
}
- _LIBCPP_AVAILABILITY_TO_CHARS
- static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
+ static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v)
{
- return __u64toa(__v, __p);
+ return __itoa::__base_10_u32(__p, __v);
}
- static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_64)& __pow() { return __pow10_64; }
+ static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_32)& __pow() { return __table<>::__pow10_32; }
};
template <typename _Tp>
struct _LIBCPP_HIDDEN
- __traits_base<_Tp, decltype(void(uint32_t{declval<_Tp>()}))>
-{
- using type = uint32_t;
+ __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uint64_t)>> {
+ using type = uint64_t;
+
+ /// The width estimation using a log10 algorithm.
+ ///
+ /// The algorithm is based on
+ /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
+ /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
+ /// function requires its input to have at least one bit set the value of
+ /// zero is set to one. This means the first element of the lookup table is
+ /// zero.
+ static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
+ auto __t = (64 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
+ return __t - (__v < __table<>::__pow10_64[__t]) + 1;
+ }
- static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
- {
- auto __t = (32 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
- return __t - (__v < __pow10_32[__t]) + 1;
- }
+ static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u64(__p, __v); }
- _LIBCPP_AVAILABILITY_TO_CHARS
- static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
- {
- return __u32toa(__v, __p);
- }
+ static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_64)& __pow() { return __table<>::__pow10_64; }
+};
+
+
+# ifndef _LIBCPP_HAS_NO_INT128
+template <typename _Tp>
+struct _LIBCPP_HIDDEN
+ __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__uint128_t)> > {
+ using type = __uint128_t;
+
+ /// The width estimation using a log10 algorithm.
+ ///
+ /// The algorithm is based on
+ /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
+ /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
+ /// function requires its input to have at least one bit set the value of
+ /// zero is set to one. This means the first element of the lookup table is
+ /// zero.
+ static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
+ _LIBCPP_ASSERT(__v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
+ // There's always a bit set in the upper 64-bits.
+ auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;
+ _LIBCPP_ASSERT(__t >= __table<>::__pow10_128_offset, "Index out of bounds");
+ // __t is adjusted since the lookup table misses the lower entries.
+ return __t - (__v < __table<>::__pow10_128[__t - __table<>::__pow10_128_offset]) + 1;
+ }
+
+ static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u128(__p, __v); }
- static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_32)& __pow() { return __pow10_32; }
+ // TODO FMT This pow function should get an index.
+ // By moving this to its own header it can be reused by the pow function in to_chars_base_10.
+ static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_128)& __pow() { return __table<>::__pow10_128; }
};
+#endif
template <typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY bool
+inline _LIBCPP_HIDE_FROM_ABI bool
__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
{
auto __c = __a * __b;
@@ -196,7 +213,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
}
template <typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY bool
+inline _LIBCPP_HIDE_FROM_ABI bool
__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
{
auto __c = __a * __b;
@@ -205,7 +222,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
}
template <typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY bool
+inline _LIBCPP_HIDE_FROM_ABI bool
__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
{
static_assert(is_unsigned<_Tp>::value, "");
@@ -219,7 +236,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
}
template <typename _Tp, typename _Up>
-inline _LIBCPP_INLINE_VISIBILITY bool
+inline _LIBCPP_HIDE_FROM_ABI bool
__mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
{
return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);
@@ -228,12 +245,12 @@ __mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
template <typename _Tp>
struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
{
- static _LIBCPP_CONSTEXPR int digits = numeric_limits<_Tp>::digits10 + 1;
+ static constexpr int digits = numeric_limits<_Tp>::digits10 + 1;
using __traits_base<_Tp>::__pow;
using typename __traits_base<_Tp>::type;
// precondition: at least one non-zero character available
- static _LIBCPP_INLINE_VISIBILITY char const*
+ static _LIBCPP_HIDE_FROM_ABI char const*
__read(char const* __p, char const* __ep, type& __a, type& __b)
{
type __cprod[digits];
@@ -254,7 +271,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
}
template <typename _It1, typename _It2, class _Up>
- static _LIBCPP_INLINE_VISIBILITY _Up
+ static _LIBCPP_HIDE_FROM_ABI _Up
__inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
{
for (; __first1 < __last1; ++__first1, ++__first2)
@@ -266,7 +283,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
} // namespace __itoa
template <typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _Tp
+inline _LIBCPP_HIDE_FROM_ABI _Tp
__complement(_Tp __x)
{
static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
@@ -274,8 +291,7 @@ __complement(_Tp __x)
}
template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS
-inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+inline _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
{
auto __x = __to_unsigned_like(__value);
@@ -289,22 +305,42 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
}
template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS
-inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+inline _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
{
using __tx = __itoa::__traits<_Tp>;
auto __diff = __last - __first;
if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
- return {__tx::__convert(__value, __first), errc(0)};
+ return {__tx::__convert(__first, __value), errc(0)};
+ else
+ return {__last, errc::value_too_large};
+}
+
+# ifndef _LIBCPP_HAS_NO_INT128
+template <>
+inline _LIBCPP_HIDE_FROM_ABI to_chars_result
+__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)
+{
+ // When the value fits in 64-bits use the 64-bit code path. This reduces
+ // the number of expensive calculations on 128-bit values.
+ //
+ // NOTE the 128-bit code path requires this optimization.
+ if(__value <= numeric_limits<uint64_t>::max())
+ return __to_chars_itoa(__first, __last, static_cast<uint64_t>(__value), false_type());
+
+ using __tx = __itoa::__traits<__uint128_t>;
+ auto __diff = __last - __first;
+
+ if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
+ return {__tx::__convert(__first, __value), errc(0)};
else
return {__last, errc::value_too_large};
}
+#endif
template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS
-inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+inline _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
true_type)
{
@@ -318,8 +354,151 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
return __to_chars_integral(__first, __last, __x, __base, false_type());
}
+namespace __itoa {
+
+template <unsigned _Base>
+struct _LIBCPP_HIDDEN __integral;
+
+template <>
+struct _LIBCPP_HIDDEN __integral<2> {
+ template <typename _Tp>
+ _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
+ // If value == 0 still need one digit. If the value != this has no
+ // effect since the code scans for the most significant bit set. (Note
+ // that __libcpp_clz doesn't work for 0.)
+ return numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1);
+ }
+
+ template <typename _Tp>
+ _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
+ ptrdiff_t __cap = __last - __first;
+ int __n = __width(__value);
+ if (__n > __cap)
+ return {__last, errc::value_too_large};
+
+ __last = __first + __n;
+ char* __p = __last;
+ const unsigned __divisor = 16;
+ while (__value > __divisor) {
+ unsigned __c = __value % __divisor;
+ __value /= __divisor;
+ __p -= 4;
+ std::memcpy(__p, &__table<>::__base_2_lut[4 * __c], 4);
+ }
+ do {
+ unsigned __c = __value % 2;
+ __value /= 2;
+ *--__p = "01"[__c];
+ } while (__value != 0);
+ return {__last, errc(0)};
+ }
+};
+
+template <>
+struct _LIBCPP_HIDDEN __integral<8> {
+ template <typename _Tp>
+ _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
+ // If value == 0 still need one digit. If the value != this has no
+ // effect since the code scans for the most significat bit set. (Note
+ // that __libcpp_clz doesn't work for 0.)
+ return ((numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1)) + 2) / 3;
+ }
+
+ template <typename _Tp>
+ _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
+ ptrdiff_t __cap = __last - __first;
+ int __n = __width(__value);
+ if (__n > __cap)
+ return {__last, errc::value_too_large};
+
+ __last = __first + __n;
+ char* __p = __last;
+ unsigned __divisor = 64;
+ while (__value > __divisor) {
+ unsigned __c = __value % __divisor;
+ __value /= __divisor;
+ __p -= 2;
+ std::memcpy(__p, &__table<>::__base_8_lut[2 * __c], 2);
+ }
+ do {
+ unsigned __c = __value % 8;
+ __value /= 8;
+ *--__p = "01234567"[__c];
+ } while (__value != 0);
+ return {__last, errc(0)};
+ }
+
+};
+
+template <>
+struct _LIBCPP_HIDDEN __integral<16> {
+ template <typename _Tp>
+ _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {
+ // If value == 0 still need one digit. If the value != this has no
+ // effect since the code scans for the most significat bit set. (Note
+ // that __libcpp_clz doesn't work for 0.)
+ return (numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1) + 3) / 4;
+ }
+
+ template <typename _Tp>
+ _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
+ ptrdiff_t __cap = __last - __first;
+ int __n = __width(__value);
+ if (__n > __cap)
+ return {__last, errc::value_too_large};
+
+ __last = __first + __n;
+ char* __p = __last;
+ unsigned __divisor = 256;
+ while (__value > __divisor) {
+ unsigned __c = __value % __divisor;
+ __value /= __divisor;
+ __p -= 2;
+ std::memcpy(__p, &__table<>::__base_16_lut[2 * __c], 2);
+ }
+ if (__first != __last)
+ do {
+ unsigned __c = __value % 16;
+ __value /= 16;
+ *--__p = "0123456789abcdef"[__c];
+ } while (__value != 0);
+ return {__last, errc(0)};
+ }
+};
+
+} // namespace __itoa
+
+template <unsigned _Base, typename _Tp,
+ typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
+_LIBCPP_HIDE_FROM_ABI int
+__to_chars_integral_width(_Tp __value) {
+ return __itoa::__integral<_Base>::__width(__value);
+}
+
+template <unsigned _Base, typename _Tp,
+ typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
+_LIBCPP_HIDE_FROM_ABI int
+__to_chars_integral_width(_Tp __value) {
+ return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value));
+}
+
+template <unsigned _Base, typename _Tp,
+ typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
+_LIBCPP_HIDE_FROM_ABI to_chars_result
+__to_chars_integral(char* __first, char* __last, _Tp __value) {
+ return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);
+}
+
+template <unsigned _Base, typename _Tp,
+ typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
+_LIBCPP_HIDE_FROM_ABI to_chars_result
+__to_chars_integral(char* __first, char* __last, _Tp __value) {
+ return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));
+}
+
template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_width(_Tp __value, unsigned __base) {
+_LIBCPP_HIDE_FROM_ABI int
+__to_chars_integral_width(_Tp __value, unsigned __base) {
_LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
unsigned __base_2 = __base * __base;
@@ -341,18 +520,26 @@ _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_
__r += 4;
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS
-inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+inline _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
false_type)
{
- if (__base == 10)
+ if (__base == 10) [[likely]]
return __to_chars_itoa(__first, __last, __value, false_type());
+ switch (__base) {
+ case 2:
+ return __to_chars_integral<2>(__first, __last, __value);
+ case 8:
+ return __to_chars_integral<8>(__first, __last, __value);
+ case 16:
+ return __to_chars_integral<16>(__first, __last, __value);
+ }
+
ptrdiff_t __cap = __last - __first;
int __n = __to_chars_integral_width(__value, __base);
if (__n > __cap)
@@ -369,25 +556,26 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
}
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-_LIBCPP_AVAILABILITY_TO_CHARS
-inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+inline _LIBCPP_HIDE_FROM_ABI to_chars_result
to_chars(char* __first, char* __last, _Tp __value)
{
- return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>());
+ using _Type = __make_32_64_or_128_bit_t<_Tp>;
+ static_assert(!is_same<_Type, void>::value, "unsupported integral type used in to_chars");
+ return std::__to_chars_itoa(__first, __last, static_cast<_Type>(__value), is_signed<_Tp>());
}
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-_LIBCPP_AVAILABILITY_TO_CHARS
-inline _LIBCPP_INLINE_VISIBILITY to_chars_result
+inline _LIBCPP_HIDE_FROM_ABI to_chars_result
to_chars(char* __first, char* __last, _Tp __value, int __base)
{
- _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
- return __to_chars_integral(__first, __last, __value, __base,
- is_signed<_Tp>());
+ _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
+
+ using _Type = __make_32_64_or_128_bit_t<_Tp>;
+ return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base, is_signed<_Tp>());
}
template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
-inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+inline _LIBCPP_HIDE_FROM_ABI from_chars_result
__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
{
using __tl = numeric_limits<_Tp>;
@@ -410,13 +598,13 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
if (__x <= __complement(__to_unsigned_like(__tl::min())))
{
__x = __complement(__x);
- _VSTD::memcpy(&__value, &__x, sizeof(__x));
+ std::memcpy(&__value, &__x, sizeof(__x));
return __r;
}
}
else
{
- if (__x <= __tl::max())
+ if (__x <= __to_unsigned_like(__tl::max()))
{
__value = __x;
return __r;
@@ -427,7 +615,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
}
template <typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY bool
+inline _LIBCPP_HIDE_FROM_ABI bool
__in_pattern(_Tp __c)
{
return '0' <= __c && __c <= '9';
@@ -438,11 +626,11 @@ struct _LIBCPP_HIDDEN __in_pattern_result
bool __ok;
int __val;
- explicit _LIBCPP_INLINE_VISIBILITY operator bool() const { return __ok; }
+ explicit _LIBCPP_HIDE_FROM_ABI operator bool() const { return __ok; }
};
template <typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY __in_pattern_result
+inline _LIBCPP_HIDE_FROM_ABI __in_pattern_result
__in_pattern(_Tp __c, int __base)
{
if (__base <= 10)
@@ -456,15 +644,15 @@ __in_pattern(_Tp __c, int __base)
}
template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
-inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+inline _LIBCPP_HIDE_FROM_ABI from_chars_result
__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
_Ts... __args)
{
- auto __find_non_zero = [](_It __first, _It __last) {
- for (; __first != __last; ++__first)
- if (*__first != '0')
+ auto __find_non_zero = [](_It __firstit, _It __lastit) {
+ for (; __firstit != __lastit; ++__firstit)
+ if (*__firstit != '0')
break;
- return __first;
+ return __firstit;
};
auto __p = __find_non_zero(__first, __last);
@@ -493,7 +681,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
}
template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
-inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+inline _LIBCPP_HIDE_FROM_ABI from_chars_result
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
{
using __tx = __itoa::__traits<_Tp>;
@@ -501,16 +689,16 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
return __subject_seq_combinator(
__first, __last, __value,
- [](const char* __first, const char* __last,
- _Tp& __value) -> from_chars_result {
+ [](const char* __f, const char* __l,
+ _Tp& __val) -> from_chars_result {
__output_type __a, __b;
- auto __p = __tx::__read(__first, __last, __a, __b);
- if (__p == __last || !__in_pattern(*__p))
+ auto __p = __tx::__read(__f, __l, __a, __b);
+ if (__p == __l || !__in_pattern(*__p))
{
__output_type __m = numeric_limits<_Tp>::max();
if (__m >= __a && __m - __a >= __b)
{
- __value = __a + __b;
+ __val = __a + __b;
return {__p, {}};
}
}
@@ -519,7 +707,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
}
template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
-inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+inline _LIBCPP_HIDE_FROM_ABI from_chars_result
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
{
using __t = decltype(__to_unsigned_like(__value));
@@ -527,7 +715,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
}
template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
-inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+inline _LIBCPP_HIDE_FROM_ABI from_chars_result
__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
int __base)
{
@@ -536,23 +724,23 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
return __subject_seq_combinator(
__first, __last, __value,
- [](const char* __p, const char* __lastx, _Tp& __value,
- int __base) -> from_chars_result {
+ [](const char* __p, const char* __lastp, _Tp& __val,
+ int __b) -> from_chars_result {
using __tl = numeric_limits<_Tp>;
- auto __digits = __tl::digits / log2f(float(__base));
- _Tp __a = __in_pattern(*__p++, __base).__val, __b = 0;
+ auto __digits = __tl::digits / log2f(float(__b));
+ _Tp __x = __in_pattern(*__p++, __b).__val, __y = 0;
- for (int __i = 1; __p != __lastx; ++__i, ++__p)
+ for (int __i = 1; __p != __lastp; ++__i, ++__p)
{
- if (auto __c = __in_pattern(*__p, __base))
+ if (auto __c = __in_pattern(*__p, __b))
{
if (__i < __digits - 1)
- __a = __a * __base + __c.__val;
+ __x = __x * __b + __c.__val;
else
{
- if (!__itoa::__mul_overflowed(__a, __base, __a))
+ if (!__itoa::__mul_overflowed(__x, __b, __x))
++__p;
- __b = __c.__val;
+ __y = __c.__val;
break;
}
}
@@ -560,11 +748,11 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
break;
}
- if (__p == __lastx || !__in_pattern(*__p, __base))
+ if (__p == __lastp || !__in_pattern(*__p, __b))
{
- if (__tl::max() - __a >= __b)
+ if (__tl::max() - __x >= __y)
{
- __value = __a + __b;
+ __val = __x + __y;
return {__p, {}};
}
}
@@ -574,7 +762,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
}
template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
-inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+inline _LIBCPP_HIDE_FROM_ABI from_chars_result
__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
int __base)
{
@@ -584,14 +772,14 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
}
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+inline _LIBCPP_HIDE_FROM_ABI from_chars_result
from_chars(const char* __first, const char* __last, _Tp& __value)
{
return __from_chars_atoi(__first, __last, __value);
}
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-inline _LIBCPP_INLINE_VISIBILITY from_chars_result
+inline _LIBCPP_HIDE_FROM_ABI from_chars_result
from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
{
_LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
lib/libcxx/include/chrono
@@ -13,6 +13,8 @@
/*
chrono synopsis
+#include <compare> // C++20
+
namespace std
{
namespace chrono
@@ -325,11 +327,7 @@ struct last_spec;
class day;
constexpr bool operator==(const day& x, const day& y) noexcept;
-constexpr bool operator!=(const day& x, const day& y) noexcept;
-constexpr bool operator< (const day& x, const day& y) noexcept;
-constexpr bool operator> (const day& x, const day& y) noexcept;
-constexpr bool operator<=(const day& x, const day& y) noexcept;
-constexpr bool operator>=(const day& x, const day& y) noexcept;
+constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
constexpr day operator+(const day& x, const days& y) noexcept;
constexpr day operator+(const days& x, const day& y) noexcept;
constexpr day operator-(const day& x, const days& y) noexcept;
@@ -694,20 +692,34 @@ constexpr chrono::year operator ""y(unsigned lo
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__chrono/calendar.h>
#include <__chrono/convert_to_timespec.h>
+#include <__chrono/day.h>
#include <__chrono/duration.h>
#include <__chrono/file_clock.h>
+#include <__chrono/hh_mm_ss.h>
#include <__chrono/high_resolution_clock.h>
+#include <__chrono/literals.h>
+#include <__chrono/month.h>
+#include <__chrono/month_weekday.h>
+#include <__chrono/monthday.h>
#include <__chrono/steady_clock.h>
#include <__chrono/system_clock.h>
#include <__chrono/time_point.h>
+#include <__chrono/weekday.h>
+#include <__chrono/year.h>
+#include <__chrono/year_month.h>
+#include <__chrono/year_month_day.h>
+#include <__chrono/year_month_weekday.h>
#include <__config>
-#include <compare>
#include <version>
+// standard-mandated includes
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_CHRONO
lib/libcxx/include/cinttypes
@@ -234,12 +234,13 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cstdint>
#include <inttypes.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/ciso646
@@ -15,10 +15,11 @@
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_CISO646
lib/libcxx/include/climits
@@ -37,11 +37,12 @@ Macros:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <limits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_CLIMITS
lib/libcxx/include/clocale
@@ -34,11 +34,12 @@ lconv* localeconv();
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <locale.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cmath
@@ -304,13 +304,14 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <math.h>
#include <type_traits>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -529,9 +530,9 @@ using ::tgammal _LIBCPP_USING_IF_EXISTS;
using ::truncl _LIBCPP_USING_IF_EXISTS;
#if _LIBCPP_STD_VER > 14
-inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
-inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }
-inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
+inline _LIBCPP_INLINE_VISIBILITY float hypot( float __x, float __y, float __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
+inline _LIBCPP_INLINE_VISIBILITY double hypot( double __x, double __y, double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
+inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
template <class _A1, class _A2, class _A3>
inline _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/codecvt
@@ -54,17 +54,18 @@ class codecvt_utf8_utf16
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__locale>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-enum codecvt_mode
+enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode
{
consume_header = 4,
generate_header = 2,
@@ -81,17 +82,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
: public codecvt<wchar_t, char, mbstate_t>
{
unsigned long _Maxcode_;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
codecvt_mode _Mode_;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef wchar_t intern_type;
typedef char extern_type;
typedef mbstate_t state_type;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
virtual result
do_out(state_type& __st,
@@ -125,10 +130,10 @@ public:
typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -163,10 +168,10 @@ public:
typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -188,9 +193,10 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0>
-class _LIBCPP_TEMPLATE_VIS codecvt_utf8
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8
: public __codecvt_utf8<_Elem>
{
public:
@@ -201,6 +207,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
~codecvt_utf8() {}
};
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// codecvt_utf16
@@ -212,17 +219,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
: public codecvt<wchar_t, char, mbstate_t>
{
unsigned long _Maxcode_;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
codecvt_mode _Mode_;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef wchar_t intern_type;
typedef char extern_type;
typedef mbstate_t state_type;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
virtual result
do_out(state_type& __st,
@@ -247,17 +258,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
: public codecvt<wchar_t, char, mbstate_t>
{
unsigned long _Maxcode_;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
codecvt_mode _Mode_;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef wchar_t intern_type;
typedef char extern_type;
typedef mbstate_t state_type;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
virtual result
do_out(state_type& __st,
@@ -291,10 +306,10 @@ public:
typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -329,10 +344,10 @@ public:
typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -367,10 +382,10 @@ public:
typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -405,10 +420,10 @@ public:
typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -430,9 +445,10 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0>
-class _LIBCPP_TEMPLATE_VIS codecvt_utf16
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16
: public __codecvt_utf16<_Elem, _Mode & little_endian>
{
public:
@@ -443,6 +459,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
~codecvt_utf16() {}
};
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// codecvt_utf8_utf16
@@ -454,17 +471,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
: public codecvt<wchar_t, char, mbstate_t>
{
unsigned long _Maxcode_;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
codecvt_mode _Mode_;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef wchar_t intern_type;
typedef char extern_type;
typedef mbstate_t state_type;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
virtual result
do_out(state_type& __st,
@@ -498,10 +519,10 @@ public:
typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -536,10 +557,10 @@ public:
typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY
- explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
- codecvt_mode _Mode)
- : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
- _Mode_(_Mode) {}
+ explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
+ codecvt_mode __mode)
+ : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
+ _Mode_(__mode) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -561,9 +582,10 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0>
-class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16
: public __codecvt_utf8_utf16<_Elem>
{
public:
@@ -574,6 +596,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
~codecvt_utf8_utf16() {}
};
+_LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/compare
@@ -140,6 +140,7 @@ namespace std {
}
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__compare/common_comparison_category.h>
#include <__compare/compare_partial_order_fallback.h>
#include <__compare/compare_strong_order_fallback.h>
@@ -156,7 +157,7 @@ namespace std {
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_COMPARE
lib/libcxx/include/complex
@@ -231,6 +231,7 @@ template<class T> complex<T> tanh (const complex<T>&);
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cmath>
#include <iosfwd>
@@ -243,7 +244,7 @@ template<class T> complex<T> tanh (const complex<T>&);
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/complex.h
@@ -20,7 +20,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef __cplusplus
lib/libcxx/include/concepts
@@ -129,6 +129,7 @@ namespace std {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__concepts/arithmetic.h>
#include <__concepts/assignable.h>
#include <__concepts/boolean_testable.h>
@@ -155,7 +156,7 @@ namespace std {
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_CONCEPTS
lib/libcxx/include/condition_variable
@@ -106,13 +106,14 @@ public:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__mutex_base>
#include <memory>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifndef _LIBCPP_HAS_NO_THREADS
@@ -260,7 +261,7 @@ condition_variable_any::wait_for(_Lock& __lock,
}
_LIBCPP_FUNC_VIS
-void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
+void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>);
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/coroutine
@@ -38,6 +38,7 @@ struct suspend_always;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__coroutine/coroutine_handle.h>
#include <__coroutine/coroutine_traits.h>
@@ -45,8 +46,15 @@ struct suspend_always;
#include <__coroutine/trivial_awaitables.h>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iosfwd>
+#endif
+
+// standard-mandated includes
+#include <compare>
+
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_COROUTINE
lib/libcxx/include/csetjmp
@@ -30,11 +30,12 @@ void longjmp(jmp_buf env, int val);
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <setjmp.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/csignal
@@ -39,11 +39,15 @@ int raise(int sig);
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <signal.h>
+
+#if __has_include(<signal.h>)
+# include <signal.h>
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cstdarg
@@ -31,11 +31,12 @@ Types:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <stdarg.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cstdbool
@@ -19,10 +19,11 @@ Macros:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#undef __bool_true_false_are_defined
lib/libcxx/include/cstddef
@@ -33,19 +33,21 @@ Types:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_integral.h>
+#include <stddef.h>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
-#include_next <stddef.h>
-#include <__nullptr>
-
_LIBCPP_BEGIN_NAMESPACE_STD
+using ::nullptr_t;
using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
using ::size_t _LIBCPP_USING_IF_EXISTS;
@@ -53,34 +55,6 @@ using ::size_t _LIBCPP_USING_IF_EXISTS;
using ::max_align_t _LIBCPP_USING_IF_EXISTS;
#endif
-template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
-template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
-#endif
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
-template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
-#endif
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; };
-#endif
-template <> struct __libcpp_is_integral<short> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<int> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<long> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
-#ifndef _LIBCPP_HAS_NO_INT128
-template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };
-template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
-#endif
-
_LIBCPP_END_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
@@ -88,11 +62,6 @@ namespace std // purposefully not versioned
{
enum class byte : unsigned char {};
-
-template <bool> struct __enable_if_integral_imp {};
-template <> struct __enable_if_integral_imp<true> { using type = byte; };
-template <class _Tp> using _EnableByteOverload = typename __enable_if_integral_imp<__libcpp_is_integral<_Tp>::value>::type;
-
constexpr byte operator| (byte __lhs, byte __rhs) noexcept
{
return static_cast<byte>(
@@ -133,6 +102,10 @@ constexpr byte operator~ (byte __b) noexcept
~static_cast<unsigned int>(__b)
));
}
+
+template <class _Tp>
+using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>;
+
template <class _Integer>
constexpr _EnableByteOverload<_Integer> &
operator<<=(byte& __lhs, _Integer __shift) noexcept
lib/libcxx/include/cstdint
@@ -140,11 +140,12 @@ Types:
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <stdint.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cstdio
@@ -95,11 +95,12 @@ void perror(const char* s);
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <stdio.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cstdlib
@@ -81,17 +81,12 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <stdlib.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-#ifdef __GNUC__
-#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
-#else
-#define _LIBCPP_UNREACHABLE() _VSTD::abort()
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -121,10 +116,8 @@ using ::abort _LIBCPP_USING_IF_EXISTS;
using ::atexit _LIBCPP_USING_IF_EXISTS;
using ::exit _LIBCPP_USING_IF_EXISTS;
using ::_Exit _LIBCPP_USING_IF_EXISTS;
-#ifndef _LIBCPP_WINDOWS_STORE_APP
using ::getenv _LIBCPP_USING_IF_EXISTS;
using ::system _LIBCPP_USING_IF_EXISTS;
-#endif
using ::bsearch _LIBCPP_USING_IF_EXISTS;
using ::qsort _LIBCPP_USING_IF_EXISTS;
using ::abs _LIBCPP_USING_IF_EXISTS;
@@ -138,11 +131,11 @@ using ::mbtowc _LIBCPP_USING_IF_EXISTS;
using ::wctomb _LIBCPP_USING_IF_EXISTS;
using ::mbstowcs _LIBCPP_USING_IF_EXISTS;
using ::wcstombs _LIBCPP_USING_IF_EXISTS;
-#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
+#if !defined(_LIBCPP_CXX03_LANG)
using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
using ::quick_exit _LIBCPP_USING_IF_EXISTS;
#endif
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC)
+#if _LIBCPP_STD_VER > 14
using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
#endif
lib/libcxx/include/cstring
@@ -56,11 +56,12 @@ size_t strlen(const char* s);
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <string.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/ctgmath
@@ -18,11 +18,12 @@
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <ccomplex>
#include <cmath>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_CTGMATH
lib/libcxx/include/ctime
@@ -45,25 +45,12 @@ int timespec_get( struct timespec *ts, int base); // C++17
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <time.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-// FIXME:
-// Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This
-// should be fixed in future SDKs, but for the time being we need to avoid
-// trying to use that declaration when the SDK doesn't provide it. Note that
-// we're detecting this here instead of in <__config> because we can't include
-// system headers from <__config>, since it leads to circular module dependencies.
-// This is also meant to be a very temporary workaround until the SDKs are fixed.
-#if defined(__APPLE__) && !__has_attribute(using_if_exists)
-# include <sys/cdefs.h>
-# if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
-# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
-# endif
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -72,7 +59,7 @@ using ::clock_t _LIBCPP_USING_IF_EXISTS;
using ::size_t _LIBCPP_USING_IF_EXISTS;
using ::time_t _LIBCPP_USING_IF_EXISTS;
using ::tm _LIBCPP_USING_IF_EXISTS;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
+#if _LIBCPP_STD_VER > 14
using ::timespec _LIBCPP_USING_IF_EXISTS;
#endif
using ::clock _LIBCPP_USING_IF_EXISTS;
@@ -84,7 +71,7 @@ using ::ctime _LIBCPP_USING_IF_EXISTS;
using ::gmtime _LIBCPP_USING_IF_EXISTS;
using ::localtime _LIBCPP_USING_IF_EXISTS;
using ::strftime _LIBCPP_USING_IF_EXISTS;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)
+#if _LIBCPP_STD_VER > 14
using ::timespec_get _LIBCPP_USING_IF_EXISTS;
#endif
lib/libcxx/include/ctype.h
@@ -32,7 +32,7 @@ int toupper(int c);
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <ctype.h>
lib/libcxx/include/cuchar
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_CUCHAR
+#define _LIBCPP_CUCHAR
+
+/*
+ cuchar synopsis // since C++11
+
+Macros:
+
+ __STDC_UTF_16__
+ __STDC_UTF_32__
+
+namespace std {
+
+Types:
+
+ mbstate_t
+ size_t
+
+size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
+size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
+size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
+size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
+
+} // std
+
+*/
+
+#include <__assert> // all public C++ headers provide the assertion handler
+#include <__config>
+#include <uchar.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+
+using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;
+using ::c16rtomb _LIBCPP_USING_IF_EXISTS;
+using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;
+using ::c32rtomb _LIBCPP_USING_IF_EXISTS;
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CUCHAR
lib/libcxx/include/cwchar
@@ -102,12 +102,13 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cwctype>
#include <wchar.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/cwctype
@@ -49,12 +49,13 @@ wctrans_t wctrans(const char* property);
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cctype>
#include <wctype.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/deque
@@ -160,22 +160,52 @@ template <class T, class Allocator, class Predicate>
*/
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_backward.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__debug>
+#include <__format/enable_insertable.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/prev.h>
+#include <__iterator/reverse_iterator.h>
#include <__split_buffer>
#include <__utility/forward.h>
-#include <algorithm>
-#include <compare>
-#include <initializer_list>
-#include <iterator>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <limits>
#include <stdexcept>
#include <type_traits>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <functional>
+# include <iterator>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [deque.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -442,7 +472,7 @@ public:
{return !(__x < __y);}
private:
- _LIBCPP_INLINE_VISIBILITY __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
: __m_iter_(__m), __ptr_(__p) {}
template <class _Tp, class _Ap> friend class __deque_base;
@@ -1304,7 +1334,7 @@ public:
deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
deque(const deque& __c);
- deque(const deque& __c, const __identity_t<allocator_type>& __a);
+ deque(const deque& __c, const __type_identity_t<allocator_type>& __a);
deque& operator=(const deque& __c);
@@ -1318,7 +1348,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);
_LIBCPP_INLINE_VISIBILITY
- deque(deque&& __c, const __identity_t<allocator_type>& __a);
+ deque(deque&& __c, const __type_identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
deque& operator=(deque&& __c)
_NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
@@ -1434,12 +1464,10 @@ 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_cpp17_input_iterator<_InputIter>::value
- &&!__is_cpp17_forward_iterator<_InputIter>::value>::type* = 0);
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type* = 0);
template <class _ForwardIterator>
iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
- typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value
- &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type* = 0);
+ typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
template <class _BiIter>
iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0);
@@ -1526,8 +1554,7 @@ public:
template <class _InpIter>
void __append(_InpIter __f, _InpIter __l,
- typename enable_if<__is_cpp17_input_iterator<_InpIter>::value &&
- !__is_cpp17_forward_iterator<_InpIter>::value>::type* = 0);
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type* = 0);
template <class _ForIter>
void __append(_ForIter __f, _ForIter __l,
typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0);
@@ -1640,7 +1667,7 @@ deque<_Tp, _Allocator>::deque(const deque& __c)
}
template <class _Tp, class _Allocator>
-deque<_Tp, _Allocator>::deque(const deque& __c, const __identity_t<allocator_type>& __a)
+deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a)
: __base(__a)
{
__append(__c.begin(), __c.end());
@@ -1683,7 +1710,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c)
template <class _Tp, class _Allocator>
inline
-deque<_Tp, _Allocator>::deque(deque&& __c, const __identity_t<allocator_type>& __a)
+deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a)
: __base(_VSTD::move(__c), __a)
{
if (__a != __c.__alloc())
@@ -2236,8 +2263,7 @@ 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_cpp17_input_iterator<_InputIter>::value
- &&!__is_cpp17_forward_iterator<_InputIter>::value>::type*)
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type*)
{
__split_buffer<value_type, allocator_type&> __buf(__base::__alloc());
__buf.__construct_at_end(__f, __l);
@@ -2249,8 +2275,7 @@ 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_cpp17_forward_iterator<_ForwardIterator>::value
- &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type*)
+ typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
{
size_type __n = _VSTD::distance(__f, __l);
__split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc());
@@ -2332,8 +2357,7 @@ template <class _Tp, class _Allocator>
template <class _InpIter>
void
deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,
- typename enable_if<__is_cpp17_input_iterator<_InpIter>::value &&
- !__is_cpp17_forward_iterator<_InpIter>::value>::type*)
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type*)
{
for (; __f != __l; ++__f)
#ifdef _LIBCPP_CXX03_LANG
@@ -3019,8 +3043,15 @@ erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {
__c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());
return __old_size - __c.size();
}
+
+template <>
+inline constexpr bool __format::__enable_insertable<std::deque<char>> = true;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true;
#endif
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/errno.h
@@ -25,7 +25,7 @@ Macros:
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <errno.h>
lib/libcxx/include/exception
@@ -76,6 +76,7 @@ template <class E> void rethrow_if_nested(const E& e);
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <__memory/addressof.h>
@@ -89,7 +90,7 @@ template <class E> void rethrow_if_nested(const E& e);
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
namespace std // purposefully not using versioning namespace
@@ -189,15 +190,11 @@ make_exception_ptr(_Ep __e) _NOEXCEPT
class _LIBCPP_TYPE_VIS exception_ptr
{
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunused-private-field"
-#endif
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field")
void* __ptr1_;
void* __ptr2_;
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
+_LIBCPP_DIAGNOSTIC_POP
public:
exception_ptr() _NOEXCEPT;
exception_ptr(nullptr_t) _NOEXCEPT;
@@ -219,7 +216,7 @@ _LIBCPP_FUNC_VIS void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;
_LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__except, const void* __ptr);
_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
-_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr p);
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
// This is a built-in template function which automagically extracts the required
// information.
@@ -304,16 +301,16 @@ throw_with_nested(_Tp&& __t)
}
template <class _From, class _To>
-struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT(
+struct __can_dynamic_cast : _BoolConstant<
is_polymorphic<_From>::value &&
(!is_base_of<_To, _From>::value ||
- is_convertible<const _From*, const _To*>::value)) {};
+ is_convertible<const _From*, const _To*>::value)> {};
template <class _Ep>
inline _LIBCPP_INLINE_VISIBILITY
void
rethrow_if_nested(const _Ep& __e,
- typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)
+ __enable_if_t< __can_dynamic_cast<_Ep, nested_exception>::value>* = 0)
{
const nested_exception* __nep = dynamic_cast<const nested_exception*>(_VSTD::addressof(__e));
if (__nep)
@@ -324,7 +321,7 @@ template <class _Ep>
inline _LIBCPP_INLINE_VISIBILITY
void
rethrow_if_nested(const _Ep&,
- typename enable_if<!__can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)
+ __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value>* = 0)
{
}
lib/libcxx/include/execution
@@ -10,6 +10,7 @@
#ifndef _LIBCPP_EXECUTION
#define _LIBCPP_EXECUTION
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <version>
@@ -18,7 +19,7 @@
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_EXECUTION
lib/libcxx/include/fenv.h
@@ -53,7 +53,7 @@ int feupdateenv(const fenv_t* envp);
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <fenv.h>
lib/libcxx/include/filesystem
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_FILESYSTEM
#define _LIBCPP_FILESYSTEM
+
/*
filesystem synopsis
@@ -238,6 +239,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__filesystem/copy_options.h>
#include <__filesystem/directory_entry.h>
@@ -255,15 +257,17 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
#include <__filesystem/recursive_directory_iterator.h>
#include <__filesystem/space_info.h>
#include <__filesystem/u8path.h>
-#include <compare>
#include <version>
+// standard-mandated includes
+#include <compare>
+
#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
-# error "The Filesystem library is not supported since libc++ has been configured with LIBCXX_ENABLE_FILESYSTEM disabled"
+# error "The <filesystem> library is not supported since libc++ has been configured without support for a filesystem."
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_FILESYSTEM
lib/libcxx/include/float.h
@@ -73,7 +73,7 @@ Macros:
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <float.h>
lib/libcxx/include/format
@@ -23,15 +23,26 @@ namespace std {
using format_args = basic_format_args<format_context>;
using wformat_args = basic_format_args<wformat_context>;
+ // [format.fmt.string], class template basic-format-string
+ template<class charT, class... Args>
+ struct basic-format-string; // exposition only
+
+ template<class... Args>
+ using format-string = // exposition only
+ basic-format-string<char, type_identity_t<Args>...>;
+ template<class... Args>
+ using wformat-string = // exposition only
+ basic-format-string<wchar_t, type_identity_t<Args>...>;
+
// [format.functions], formatting functions
template<class... Args>
- string format(string_view fmt, const Args&... args);
+ string format(format-string<Args...> fmt, Args&&... args);
template<class... Args>
- wstring format(wstring_view fmt, const Args&... args);
+ wstring format(wformat-string<Args...> fmt, Args&&... args);
template<class... Args>
- string format(const locale& loc, string_view fmt, const Args&... args);
+ string format(const locale& loc, format-string<Args...> fmt, Args&&... args);
template<class... Args>
- wstring format(const locale& loc, wstring_view fmt, const Args&... args);
+ wstring format(const locale& loc, wformat-string<Args...> fmt, Args&&... args);
string vformat(string_view fmt, format_args args);
wstring vformat(wstring_view fmt, wformat_args args);
@@ -39,13 +50,13 @@ namespace std {
wstring vformat(const locale& loc, wstring_view fmt, wformat_args args);
template<class Out, class... Args>
- Out format_to(Out out, string_view fmt, const Args&... args);
+ Out format_to(Out out, format-string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
- Out format_to(Out out, wstring_view fmt, const Args&... args);
+ Out format_to(Out out, wformat-string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
- Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args);
+ Out format_to(Out out, const locale& loc, format-string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
- Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);
+ Out format_to(Out out, const locale& loc, wformat-string<Args...> fmt, Args&&... args);
template<class Out>
Out vformat_to(Out out, string_view fmt, format_args args);
@@ -64,27 +75,27 @@ namespace std {
};
template<class Out, class... Args>
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
- string_view fmt, const Args&... args);
+ format-string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
- wstring_view fmt, const Args&... args);
+ wformat-string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
- const locale& loc, string_view fmt,
- const Args&... args);
+ const locale& loc, format-string<Args...> fmt,
+ Args&&... args);
template<class Out, class... Args>
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
- const locale& loc, wstring_view fmt,
- const Args&... args);
+ const locale& loc, wformat-string<Args...> fmt,
+ Args&&... args);
template<class... Args>
- size_t formatted_size(string_view fmt, const Args&... args);
+ size_t formatted_size(format-string<Args...> fmt, Args&&... args);
template<class... Args>
- size_t formatted_size(wstring_view fmt, const Args&... args);
+ size_t formatted_size(wformat-string<Args...> fmt, Args&&... args);
template<class... Args>
- size_t formatted_size(const locale& loc, string_view fmt, const Args&... args);
+ size_t formatted_size(const locale& loc, format-string<Args...> fmt, Args&&... args);
template<class... Args>
- size_t formatted_size(const locale& loc, wstring_view fmt, const Args&... args);
+ size_t formatted_size(const locale& loc, wformat-string<Args...> fmt, Args&&... args);
// [format.formatter], formatter
template<class T, class charT = char> struct formatter;
@@ -106,10 +117,10 @@ namespace std {
template<class Context = format_context, class... Args>
format-arg-store<Context, Args...>
- make_format_args(const Args&... args);
+ make_format_args(Args&&... args);
template<class... Args>
format-arg-store<wformat_context, Args...>
- make_wformat_args(const Args&... args);
+ make_wformat_args(Args&&... args);
// [format.error], class format_error
class format_error;
@@ -117,14 +128,20 @@ namespace std {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
// Make sure all feature-test macros are available.
#include <version>
-// Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES.
+// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+#include <__algorithm/clamp.h>
#include <__config>
#include <__debug>
+#include <__format/buffer.h>
+#include <__format/concepts.h>
+#include <__format/enable_insertable.h>
#include <__format/format_arg.h>
+#include <__format/format_arg_store.h>
#include <__format/format_args.h>
#include <__format/format_context.h>
#include <__format/format_error.h>
@@ -140,6 +157,9 @@ namespace std {
#include <__format/formatter_pointer.h>
#include <__format/formatter_string.h>
#include <__format/parser_std_format_spec.h>
+#include <__format/unicode.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/incrementable_traits.h>
#include <__variant/monostate.h>
#include <array>
#include <concepts>
@@ -152,22 +172,13 @@ namespace std {
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// TODO FMT Remove this once we require compilers with proper C++20 support.
-// If the compiler has no concepts support, the format header will be disabled.
-// Without concepts support enable_if needs to be used and that too much effort
-// to support compilers with partial C++20 support.
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
// TODO FMT Move the implementation in this file to its own granular headers.
// TODO FMT Evaluate which templates should be external templates. This
@@ -180,35 +191,193 @@ using format_args = basic_format_args<format_context>;
using wformat_args = basic_format_args<wformat_context>;
#endif
-template <class _Context, class... _Args>
-struct _LIBCPP_TEMPLATE_VIS __format_arg_store {
- // TODO FMT Use a built-in array.
- array<basic_format_arg<_Context>, sizeof...(_Args)> __args;
-};
-
template <class _Context = format_context, class... _Args>
-_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...>
-make_format_args(const _Args&... __args) {
- return {basic_format_arg<_Context>(__args)...};
+_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
+ return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...>
-make_wformat_args(const _Args&... __args) {
- return _VSTD::make_format_args<wformat_context>(__args...);
+_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) {
+ return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
}
#endif
namespace __format {
+/// Helper class parse and handle argument.
+///
+/// When parsing a handle which is not enabled the code is ill-formed.
+/// This helper uses the parser of the appropriate formatter for the stored type.
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __compile_time_handle {
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); }
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI constexpr void __enable() {
+ __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) {
+ formatter<_Tp, _CharT> __f;
+ __parse_ctx.advance_to(__f.parse(__parse_ctx));
+ };
+ }
+
+ // Before calling __parse the proper handler needs to be set with __enable.
+ // The default handler isn't a core constant expression.
+ _LIBCPP_HIDE_FROM_ABI constexpr __compile_time_handle()
+ : __parse_([](basic_format_parse_context<_CharT>&) { __throw_format_error("Not a handle"); }) {}
+
+private:
+ void (*__parse_)(basic_format_parse_context<_CharT>&);
+};
+
+// Dummy format_context only providing the parts used during constant
+// validation of the basic-format-string.
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {
+public:
+ using char_type = _CharT;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __compile_time_basic_format_context(
+ const __arg_t* __args, const __compile_time_handle<_CharT>* __handles, size_t __size)
+ : __args_(__args), __handles_(__handles), __size_(__size) {}
+
+ // During the compile-time validation nothing needs to be written.
+ // Therefore all operations of this iterator are a NOP.
+ struct iterator {
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator=(_CharT) { return *this; }
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator*() { return *this; }
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator operator++(int) { return *this; }
+ };
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __arg_t arg(size_t __id) const {
+ if (__id >= __size_)
+ __throw_format_error("Argument index out of bounds");
+ return __args_[__id];
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const __compile_time_handle<_CharT>& __handle(size_t __id) const {
+ if (__id >= __size_)
+ __throw_format_error("Argument index out of bounds");
+ return __handles_[__id];
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator out() { return {}; }
+ _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(iterator) {}
+
+private:
+ const __arg_t* __args_;
+ const __compile_time_handle<_CharT>* __handles_;
+ size_t __size_;
+};
+
+_LIBCPP_HIDE_FROM_ABI
+constexpr void __compile_time_validate_integral(__arg_t __type) {
+ switch (__type) {
+ case __arg_t::__int:
+ case __arg_t::__long_long:
+ case __arg_t::__i128:
+ case __arg_t::__unsigned:
+ case __arg_t::__unsigned_long_long:
+ case __arg_t::__u128:
+ return;
+
+ default:
+ __throw_format_error("Argument isn't an integral type");
+ }
+}
+
+// _HasPrecision does the formatter have a precision?
+template <class _CharT, class _Tp, bool _HasPrecision = false>
+_LIBCPP_HIDE_FROM_ABI constexpr void
+__compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx,
+ __compile_time_basic_format_context<_CharT>& __ctx) {
+ formatter<_Tp, _CharT> __formatter;
+ __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
+ // [format.string.std]/7
+ // ... If the corresponding formatting argument is not of integral type, or
+ // its value is negative for precision or non-positive for width, an
+ // exception of type format_error is thrown.
+ //
+ // Validate whether the arguments are integrals.
+ if constexpr (requires(formatter<_Tp, _CharT> __f) { __f.__width_needs_substitution(); }) {
+ // TODO FMT Remove this when parser v1 has been phased out.
+ if (__formatter.__width_needs_substitution())
+ __format::__compile_time_validate_integral(__ctx.arg(__formatter.__width));
+
+ if constexpr (_HasPrecision)
+ if (__formatter.__precision_needs_substitution())
+ __format::__compile_time_validate_integral(__ctx.arg(__formatter.__precision));
+ } else {
+ if (__formatter.__parser_.__width_as_arg_)
+ __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_));
+
+ if constexpr (_HasPrecision)
+ if (__formatter.__parser_.__precision_as_arg_)
+ __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_));
+ }
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(basic_format_parse_context<_CharT>& __parse_ctx,
+ __compile_time_basic_format_context<_CharT>& __ctx,
+ __arg_t __type) {
+ switch (__type) {
+ case __arg_t::__none:
+ __throw_format_error("Invalid argument");
+ case __arg_t::__boolean:
+ return __format::__compile_time_validate_argument<_CharT, bool>(__parse_ctx, __ctx);
+ case __arg_t::__char_type:
+ return __format::__compile_time_validate_argument<_CharT, _CharT>(__parse_ctx, __ctx);
+ case __arg_t::__int:
+ return __format::__compile_time_validate_argument<_CharT, int>(__parse_ctx, __ctx);
+ case __arg_t::__long_long:
+ return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);
+ case __arg_t::__i128:
+# ifndef _LIBCPP_HAS_NO_INT128
+ return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);
+# else
+ __throw_format_error("Invalid argument");
+# endif
+ return;
+ case __arg_t::__unsigned:
+ return __format::__compile_time_validate_argument<_CharT, unsigned>(__parse_ctx, __ctx);
+ case __arg_t::__unsigned_long_long:
+ return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);
+ case __arg_t::__u128:
+# ifndef _LIBCPP_HAS_NO_INT128
+ return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);
+# else
+ __throw_format_error("Invalid argument");
+# endif
+ return;
+ case __arg_t::__float:
+ return __format::__compile_time_validate_argument<_CharT, float, true>(__parse_ctx, __ctx);
+ case __arg_t::__double:
+ return __format::__compile_time_validate_argument<_CharT, double, true>(__parse_ctx, __ctx);
+ case __arg_t::__long_double:
+ return __format::__compile_time_validate_argument<_CharT, long double, true>(__parse_ctx, __ctx);
+ case __arg_t::__const_char_type_ptr:
+ return __format::__compile_time_validate_argument<_CharT, const _CharT*, true>(__parse_ctx, __ctx);
+ case __arg_t::__string_view:
+ return __format::__compile_time_validate_argument<_CharT, basic_string_view<_CharT>, true>(__parse_ctx, __ctx);
+ case __arg_t::__ptr:
+ return __format::__compile_time_validate_argument<_CharT, const void*>(__parse_ctx, __ctx);
+ case __arg_t::__handle:
+ __throw_format_error("Handle should use __compile_time_validate_handle_argument");
+ }
+ __throw_format_error("Invalid argument");
+}
+
template <class _CharT, class _ParseCtx, class _Ctx>
-_LIBCPP_HIDE_FROM_ABI const _CharT*
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
__handle_replacement_field(const _CharT* __begin, const _CharT* __end,
_ParseCtx& __parse_ctx, _Ctx& __ctx) {
__format::__parse_number_result __r =
__format::__parse_arg_id(__begin, __end, __parse_ctx);
+ bool __parse = *__r.__ptr == _CharT(':');
switch (*__r.__ptr) {
case _CharT(':'):
// The arg-id has a format-specifier, advance the input to the format-spec.
@@ -223,19 +392,27 @@ __handle_replacement_field(const _CharT* __begin, const _CharT* __end,
"The replacement field arg-id should terminate at a ':' or '}'");
}
- _VSTD::visit_format_arg(
- [&](auto __arg) {
- if constexpr (same_as<decltype(__arg), monostate>)
- __throw_format_error("Argument index out of bounds");
- else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>)
- __arg.format(__parse_ctx, __ctx);
- else {
- formatter<decltype(__arg), _CharT> __formatter;
- __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
- __ctx.advance_to(__formatter.format(__arg, __ctx));
- }
- },
- __ctx.arg(__r.__value));
+ if constexpr (same_as<_Ctx, __compile_time_basic_format_context<_CharT>>) {
+ __arg_t __type = __ctx.arg(__r.__value);
+ if (__type == __arg_t::__handle)
+ __ctx.__handle(__r.__value).__parse(__parse_ctx);
+ else
+ __format::__compile_time_visit_format_arg(__parse_ctx, __ctx, __type);
+ } else
+ _VSTD::visit_format_arg(
+ [&](auto __arg) {
+ if constexpr (same_as<decltype(__arg), monostate>)
+ __throw_format_error("Argument index out of bounds");
+ else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>)
+ __arg.format(__parse_ctx, __ctx);
+ else {
+ formatter<decltype(__arg), _CharT> __formatter;
+ if (__parse)
+ __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
+ __ctx.advance_to(__formatter.format(__arg, __ctx));
+ }
+ },
+ __ctx.arg(__r.__value));
__begin = __parse_ctx.begin();
if (__begin == __end || *__begin != _CharT('}'))
@@ -245,7 +422,7 @@ __handle_replacement_field(const _CharT* __begin, const _CharT* __end,
}
template <class _ParseCtx, class _Ctx>
-_LIBCPP_HIDE_FROM_ABI typename _Ctx::iterator
+_LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator
__vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
using _CharT = typename _ParseCtx::char_type;
static_assert(same_as<typename _Ctx::char_type, _CharT>);
@@ -290,6 +467,56 @@ __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
} // namespace __format
+template <class _CharT, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS __basic_format_string {
+ basic_string_view<_CharT> __str_;
+
+ template <class _Tp>
+ requires convertible_to<const _Tp&, basic_string_view<_CharT>>
+ consteval __basic_format_string(const _Tp& __str) : __str_{__str} {
+ __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)},
+ _Context{__types_.data(), __handles_.data(), sizeof...(_Args)});
+ }
+
+private:
+ using _Context = __format::__compile_time_basic_format_context<_CharT>;
+
+ static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
+ __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};
+
+ // TODO FMT remove this work-around when the AIX ICE has been resolved.
+# if defined(_AIX) && defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1400
+ template <class _Tp>
+ static constexpr __format::__compile_time_handle<_CharT> __get_handle() {
+ __format::__compile_time_handle<_CharT> __handle;
+ if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
+ __handle.template __enable<_Tp>();
+
+ return __handle;
+ }
+
+ static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{
+ __get_handle<_Args>()...};
+# else
+ static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] {
+ using _Tp = remove_cvref_t<_Args>;
+ __format::__compile_time_handle<_CharT> __handle;
+ if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
+ __handle.template __enable<_Tp>();
+
+ return __handle;
+ }()...};
+# endif
+};
+
+template <class... _Args>
+using __format_string_t = __basic_format_string<char, type_identity_t<_Args>...>;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+using __wformat_string_t = __basic_format_string<wchar_t, type_identity_t<_Args>...>;
+#endif
+
template <class _OutIt, class _CharT, class _FormatOutIt>
requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
__vformat_to(
@@ -300,14 +527,18 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
basic_format_parse_context{__fmt, __args.__size()},
_VSTD::__format_context_create(_VSTD::move(__out_it), __args));
else {
- basic_string<_CharT> __str;
+ __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
_VSTD::__format::__vformat_to(
basic_format_parse_context{__fmt, __args.__size()},
- _VSTD::__format_context_create(_VSTD::back_inserter(__str), __args));
- return _VSTD::copy_n(__str.begin(), __str.size(), _VSTD::move(__out_it));
+ _VSTD::__format_context_create(__buffer.make_output_iterator(),
+ __args));
+ return _VSTD::move(__buffer).out();
}
}
+// The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining
+// https://reviews.llvm.org/D110499#inline-1180704
+// TODO FMT Evaluate whether we want to file a Clang bug report regarding this.
template <output_iterator<const char&> _OutIt>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) {
@@ -324,16 +555,16 @@ vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
template <output_iterator<const char&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
-format_to(_OutIt __out_it, string_view __fmt, const _Args&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt,
+format_to(_OutIt __out_it, __format_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_,
_VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <output_iterator<const wchar_t&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
-format_to(_OutIt __out_it, wstring_view __fmt, const _Args&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt,
+format_to(_OutIt __out_it, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_,
_VSTD::make_wformat_args(__args...));
}
#endif
@@ -355,60 +586,63 @@ vformat(wstring_view __fmt, wformat_args __args) {
#endif
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
-format(string_view __fmt, const _Args&... __args) {
- return _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...));
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(__format_string_t<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::vformat(__fmt.__str_, _VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
-format(wstring_view __fmt, const _Args&... __args) {
- return _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...));
+format(__wformat_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat(__fmt.__str_, _VSTD::make_wformat_args(__args...));
}
#endif
+template <class _Context, class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
+ basic_string_view<_CharT> __fmt,
+ basic_format_args<_Context> __args) {
+ __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
+ _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.make_output_iterator(), __args));
+ return _VSTD::move(__buffer).result();
+}
+
template <output_iterator<const char&> _OutIt, class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, string_view __fmt,
- const _Args&... __args) {
- // TODO FMT Improve PoC: using std::string is inefficient.
- string __str = _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...));
- iter_difference_t<_OutIt> __s = __str.size();
- iter_difference_t<_OutIt> __m =
- _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
- __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
- return {_VSTD::move(__out_it), __s};
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __format_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <output_iterator<const wchar_t&> _OutIt, class... _Args>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wstring_view __fmt,
- const _Args&... __args) {
- // TODO FMT Improve PoC: using std::string is inefficient.
- wstring __str = _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...));
- iter_difference_t<_OutIt> __s = __str.size();
- iter_difference_t<_OutIt> __m =
- _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
- __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
- return {_VSTD::move(__out_it), __s};
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __wformat_string_t<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_wformat_args(__args...));
}
#endif
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, auto __args) {
+ __format::__formatted_size_buffer<_CharT> __buffer;
+ _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.make_output_iterator(), __args));
+ return _VSTD::move(__buffer).result();
+}
+
template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(string_view __fmt, const _Args&... __args) {
- // TODO FMT Improve PoC: using std::string is inefficient.
- return _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...)).size();
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(__format_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)});
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(wstring_view __fmt, const _Args&... __args) {
- // TODO FMT Improve PoC: using std::string is inefficient.
- return _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...)).size();
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(__wformat_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)});
}
#endif
@@ -425,12 +659,12 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
_VSTD::__format_context_create(_VSTD::move(__out_it), __args,
_VSTD::move(__loc)));
else {
- basic_string<_CharT> __str;
+ __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
_VSTD::__format::__vformat_to(
basic_format_parse_context{__fmt, __args.__size()},
- _VSTD::__format_context_create(_VSTD::back_inserter(__str), __args,
- _VSTD::move(__loc)));
- return _VSTD::copy_n(__str.begin(), __str.size(), _VSTD::move(__out_it));
+ _VSTD::__format_context_create(__buffer.make_output_iterator(),
+ __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).out();
}
}
@@ -451,17 +685,17 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt v
#endif
template <output_iterator<const char&> _OutIt, class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt format_to(
- _OutIt __out_it, locale __loc, string_view __fmt, const _Args&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+format_to(_OutIt __out_it, locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_,
_VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <output_iterator<const wchar_t&> _OutIt, class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt format_to(
- _OutIt __out_it, locale __loc, wstring_view __fmt, const _Args&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+format_to(_OutIt __out_it, locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_,
_VSTD::make_wformat_args(__args...));
}
#endif
@@ -485,80 +719,80 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
#endif
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
-format(locale __loc, string_view __fmt, const _Args&... __args) {
- return _VSTD::vformat(_VSTD::move(__loc), __fmt,
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc,
+ __format_string_t<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_,
_VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
-format(locale __loc, wstring_view __fmt, const _Args&... __args) {
- return _VSTD::vformat(_VSTD::move(__loc), __fmt,
+format(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_,
_VSTD::make_wformat_args(__args...));
}
#endif
+template <class _Context, class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
+ locale __loc, basic_string_view<_CharT> __fmt,
+ basic_format_args<_Context> __args) {
+ __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).result();
+}
+
template <output_iterator<const char&> _OutIt, class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc,
- string_view __fmt, const _Args&... __args) {
- // TODO FMT Improve PoC: using std::string is inefficient.
- string __str = _VSTD::vformat(_VSTD::move(__loc), __fmt,
- _VSTD::make_format_args(__args...));
- iter_difference_t<_OutIt> __s = __str.size();
- iter_difference_t<_OutIt> __m =
- _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
- __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
- return {_VSTD::move(__out_it), __s};
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __format_string_t<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_,
+ _VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <output_iterator<const wchar_t&> _OutIt, class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc,
- wstring_view __fmt, const _Args&... __args) {
- // TODO FMT Improve PoC: using std::string is inefficient.
- wstring __str = _VSTD::vformat(_VSTD::move(__loc), __fmt,
- _VSTD::make_wformat_args(__args...));
- iter_difference_t<_OutIt> __s = __str.size();
- iter_difference_t<_OutIt> __m =
- _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s);
- __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it));
- return {_VSTD::move(__out_it), __s};
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __wformat_string_t<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_,
+ _VSTD::make_wformat_args(__args...));
}
#endif
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_CharT> __fmt, auto __args) {
+ __format::__formatted_size_buffer<_CharT> __buffer;
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).result();
+}
+
template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(locale __loc, string_view __fmt, const _Args&... __args) {
- // TODO FMT Improve PoC: using std::string is inefficient.
- return _VSTD::vformat(_VSTD::move(__loc), __fmt,
- _VSTD::make_format_args(__args...))
- .size();
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)});
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(locale __loc, wstring_view __fmt, const _Args&... __args) {
- // TODO FMT Improve PoC: using std::string is inefficient.
- return _VSTD::vformat(_VSTD::move(__loc), __fmt,
- _VSTD::make_wformat_args(__args...))
- .size();
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)});
}
#endif
#endif // _LIBCPP_HAS_NO_LOCALIZATION
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
#endif // _LIBCPP_FORMAT
lib/libcxx/include/forward_list
@@ -179,18 +179,43 @@ template <class T, class Allocator, class Predicate>
*/
+#include <__algorithm/comp.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/move_iterator.h>
+#include <__iterator/next.h>
+#include <__memory/swap_allocator.h>
#include <__utility/forward.h>
-#include <algorithm>
-#include <initializer_list>
-#include <iterator>
#include <limits>
#include <memory>
#include <type_traits>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <functional>
+# include <iterator>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [forward.list.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -679,17 +704,13 @@ public:
template <class _InputIterator>
forward_list(_InputIterator __f, _InputIterator __l,
- typename enable_if<
- __is_cpp17_input_iterator<_InputIterator>::value
- >::type* = nullptr);
+ __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>* = nullptr);
template <class _InputIterator>
forward_list(_InputIterator __f, _InputIterator __l,
const allocator_type& __a,
- typename enable_if<
- __is_cpp17_input_iterator<_InputIterator>::value
- >::type* = nullptr);
+ __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>* = nullptr);
forward_list(const forward_list& __x);
- forward_list(const forward_list& __x, const __identity_t<allocator_type>& __a);
+ forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a);
forward_list& operator=(const forward_list& __x);
@@ -698,7 +719,7 @@ public:
forward_list(forward_list&& __x)
_NOEXCEPT_(is_nothrow_move_constructible<base>::value)
: base(_VSTD::move(__x)) {}
- forward_list(forward_list&& __x, const __identity_t<allocator_type>& __a);
+ forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a);
forward_list(initializer_list<value_type> __il);
forward_list(initializer_list<value_type> __il, const allocator_type& __a);
@@ -719,11 +740,7 @@ public:
// ~forward_list() = default;
template <class _InputIterator>
- typename enable_if
- <
- __is_cpp17_input_iterator<_InputIterator>::value,
- void
- >::type
+ __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>
assign(_InputIterator __f, _InputIterator __l);
void assign(size_type __n, const value_type& __v);
@@ -799,12 +816,8 @@ public:
iterator insert_after(const_iterator __p, const value_type& __v);
iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);
template <class _InputIterator>
- _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- __is_cpp17_input_iterator<_InputIterator>::value,
- iterator
- >::type
+ _LIBCPP_INLINE_VISIBILITY
+ __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, iterator>
insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
iterator erase_after(const_iterator __p);
@@ -953,9 +966,7 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v)
template <class _Tp, class _Alloc>
template <class _InputIterator>
forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
- typename enable_if<
- __is_cpp17_input_iterator<_InputIterator>::value
- >::type*)
+ __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>*)
{
insert_after(cbefore_begin(), __f, __l);
}
@@ -964,9 +975,7 @@ template <class _Tp, class _Alloc>
template <class _InputIterator>
forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
const allocator_type& __a,
- typename enable_if<
- __is_cpp17_input_iterator<_InputIterator>::value
- >::type*)
+ __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>*)
: base(__a)
{
insert_after(cbefore_begin(), __f, __l);
@@ -981,7 +990,7 @@ forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x,
- const __identity_t<allocator_type>& __a)
+ const __type_identity_t<allocator_type>& __a)
: base(__a)
{
insert_after(cbefore_begin(), __x.begin(), __x.end());
@@ -1002,7 +1011,7 @@ forward_list<_Tp, _Alloc>::operator=(const forward_list& __x)
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x,
- const __identity_t<allocator_type>& __a)
+ const __type_identity_t<allocator_type>& __a)
: base(_VSTD::move(__x), __a)
{
if (base::__alloc() != __x.__alloc())
@@ -1076,11 +1085,7 @@ forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
template <class _Tp, class _Alloc>
template <class _InputIterator>
-typename enable_if
-<
- __is_cpp17_input_iterator<_InputIterator>::value,
- void
->::type
+__enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>
forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)
{
iterator __i = before_begin();
@@ -1272,11 +1277,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
template <class _Tp, class _Alloc>
template <class _InputIterator>
-typename enable_if
-<
- __is_cpp17_input_iterator<_InputIterator>::value,
- typename forward_list<_Tp, _Alloc>::iterator
->::type
+__enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, typename forward_list<_Tp, _Alloc>::iterator>
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
_InputIterator __f, _InputIterator __l)
{
lib/libcxx/include/fstream
@@ -179,12 +179,17 @@ typedef basic_fstream<wchar_t> wfstream;
*/
+#include <__algorithm/max.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
-#include <__debug>
#include <__locale>
+#include <__utility/move.h>
+#include <__utility/swap.h>
+#include <__utility/unreachable.h>
#include <cstdio>
#include <cstdlib>
+#include <cstring>
#include <istream>
#include <ostream>
#include <version>
@@ -194,7 +199,7 @@ typedef basic_fstream<wchar_t> wfstream;
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -414,25 +419,38 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
basic_streambuf<char_type, traits_type>::swap(__rhs);
if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
{
- _VSTD::swap(__extbuf_, __rhs.__extbuf_);
- _VSTD::swap(__extbufnext_, __rhs.__extbufnext_);
- _VSTD::swap(__extbufend_, __rhs.__extbufend_);
+ // Neither *this nor __rhs uses the small buffer, so we can simply swap the pointers.
+ std::swap(__extbuf_, __rhs.__extbuf_);
+ std::swap(__extbufnext_, __rhs.__extbufnext_);
+ std::swap(__extbufend_, __rhs.__extbufend_);
}
else
{
- ptrdiff_t __ln = __extbufnext_ - __extbuf_;
- ptrdiff_t __le = __extbufend_ - __extbuf_;
- ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_;
- ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_;
+ ptrdiff_t __ln = __extbufnext_ ? __extbufnext_ - __extbuf_ : 0;
+ ptrdiff_t __le = __extbufend_ ? __extbufend_ - __extbuf_ : 0;
+ ptrdiff_t __rn = __rhs.__extbufnext_ ? __rhs.__extbufnext_ - __rhs.__extbuf_ : 0;
+ ptrdiff_t __re = __rhs.__extbufend_ ? __rhs.__extbufend_ - __rhs.__extbuf_ : 0;
if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
{
+ // *this uses the small buffer, but __rhs doesn't.
__extbuf_ = __rhs.__extbuf_;
__rhs.__extbuf_ = __rhs.__extbuf_min_;
+ std::memmove(__rhs.__extbuf_min_, __extbuf_min_, sizeof(__extbuf_min_));
}
else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_)
{
+ // *this doesn't use the small buffer, but __rhs does.
__rhs.__extbuf_ = __extbuf_;
__extbuf_ = __extbuf_min_;
+ std::memmove(__extbuf_min_, __rhs.__extbuf_min_, sizeof(__extbuf_min_));
+ }
+ else
+ {
+ // Both *this and __rhs use the small buffer.
+ char __tmp[sizeof(__extbuf_min_)];
+ std::memmove(__tmp, __extbuf_min_, sizeof(__extbuf_min_));
+ std::memmove(__extbuf_min_, __rhs.__extbuf_min_, sizeof(__extbuf_min_));
+ std::memmove(__rhs.__extbuf_min_, __tmp, sizeof(__extbuf_min_));
}
__extbufnext_ = __extbuf_ + __rn;
__extbufend_ = __extbuf_ + __re;
@@ -538,7 +556,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(
default:
return nullptr;
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
template <class _CharT, class _Traits>
@@ -1716,9 +1734,9 @@ basic_fstream<_CharT, _Traits>::close()
}
#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
#endif
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/functional
@@ -482,6 +482,16 @@ template <> struct hash<long double>;
template<class T> struct hash<T*>;
template <> struct hash<nullptr_t>; // C++17
+namespace ranges {
+ // [range.cmp], concept-constrained comparisons
+ struct equal_to;
+ struct not_equal_to;
+ struct greater;
+ struct less;
+ struct greater_equal;
+ struct less_equal;
+}
+
} // std
POLICY: For non-variadic implementations, the number of arguments is limited
@@ -491,6 +501,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
*/
#include <__algorithm/search.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__compare/compare_three_way.h>
#include <__config>
#include <__debug>
@@ -501,6 +512,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
#include <__functional/bind_front.h>
#include <__functional/binder1st.h>
#include <__functional/binder2nd.h>
+#include <__functional/boyer_moore_searcher.h>
#include <__functional/compose.h>
#include <__functional/default_searcher.h>
#include <__functional/function.h>
@@ -525,11 +537,14 @@ POLICY: For non-variadic implementations, the number of arguments is limited
#include <tuple>
#include <type_traits>
#include <typeinfo>
-#include <utility>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <utility>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_FUNCTIONAL
lib/libcxx/include/future
@@ -361,14 +361,16 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
#include <__config>
-#include <__debug>
#include <__memory/allocator_arg_t.h>
#include <__memory/uses_allocator.h>
#include <__utility/auto_cast.h>
#include <__utility/forward.h>
-#include <chrono>
+#include <__utility/move.h>
#include <exception>
#include <memory>
#include <mutex>
@@ -376,13 +378,17 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
#include <thread>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <chrono>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef _LIBCPP_HAS_NO_THREADS
-#error <future> is not supported on this single threaded system
-#else // !_LIBCPP_HAS_NO_THREADS
+# error "<future> is not supported since libc++ has been configured without support for threads."
+#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -399,7 +405,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
template <>
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};
-#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+#ifdef _LIBCPP_CXX03_LANG
template <>
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type { };
#endif
@@ -413,7 +419,7 @@ _LIBCPP_DECLARE_STRONG_ENUM(launch)
};
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
-#ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
+#ifndef _LIBCPP_CXX03_LANG
typedef underlying_type<launch>::type __launch_underlying_type;
@@ -473,7 +479,7 @@ operator^=(launch& __x, launch __y)
__x = __x ^ __y; return __x;
}
-#endif // !_LIBCPP_HAS_NO_STRONG_ENUMS
+#endif // !_LIBCPP_CXX03_LANG
//enum class future_status
_LIBCPP_DECLARE_STRONG_ENUM(future_status)
@@ -519,12 +525,12 @@ _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_NO_EXCEPTIONS
_LIBCPP_AVAILABILITY_FUTURE_ERROR
#endif
-void __throw_future_error(future_errc _Ev)
+void __throw_future_error(future_errc __ev)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- throw future_error(make_error_code(_Ev));
+ throw future_error(make_error_code(__ev));
#else
- ((void)_Ev);
+ ((void)__ev);
_VSTD::abort();
#endif
}
@@ -1100,7 +1106,7 @@ future<_Rp>::future(__assoc_state<_Rp>* __state)
struct __release_shared_count
{
- void operator()(__shared_count* p) {p->__release_shared();}
+ void operator()(__shared_count* __p) {__p->__release_shared();}
};
template <class _Rp>
@@ -1885,25 +1891,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
packaged_task() _NOEXCEPT : __p_(nullptr) {}
template <class _Fp,
- class = typename enable_if
- <
- !is_same<
- typename __uncvref<_Fp>::type,
- packaged_task
- >::value
- >::type
- >
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
_LIBCPP_INLINE_VISIBILITY
explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
template <class _Fp, class _Allocator,
- class = typename enable_if
- <
- !is_same<
- typename __uncvref<_Fp>::type,
- packaged_task
- >::value
- >::type
- >
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
_LIBCPP_INLINE_VISIBILITY
packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
@@ -2014,25 +2006,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
packaged_task() _NOEXCEPT : __p_(nullptr) {}
template <class _Fp,
- class = typename enable_if
- <
- !is_same<
- typename __uncvref<_Fp>::type,
- packaged_task
- >::value
- >::type
- >
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
_LIBCPP_INLINE_VISIBILITY
explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
template <class _Fp, class _Allocator,
- class = typename enable_if
- <
- !is_same<
- typename __uncvref<_Fp>::type,
- packaged_task
- >::value
- >::type
- >
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
_LIBCPP_INLINE_VISIBILITY
packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
@@ -2458,6 +2436,4 @@ future<void>::share() _NOEXCEPT
_LIBCPP_END_NAMESPACE_STD
-#endif // !_LIBCPP_HAS_NO_THREADS
-
#endif // _LIBCPP_FUTURE
lib/libcxx/include/initializer_list
@@ -42,11 +42,12 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
namespace std // purposefully not versioned
lib/libcxx/include/inttypes.h
@@ -238,7 +238,7 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
lib/libcxx/include/iomanip
@@ -42,13 +42,13 @@ template <class charT, class traits, class Allocator>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__string>
#include <istream>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -513,16 +513,17 @@ put_time(const tm* __tm, const _CharT* __fmt)
return __iom_t10<_CharT>(__tm, __fmt);
}
-template <class _CharT, class _Traits, class _ForwardIterator>
-basic_ostream<_CharT, _Traits> &
-__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
- _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
+#if _LIBCPP_STD_VER >= 11
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
+__quoted_output(basic_ostream<_CharT, _Traits>& __os,
+ const _CharT *__first, const _CharT *__last, _CharT __delim, _CharT __escape)
{
basic_string<_CharT, _Traits> __str;
__str.push_back(__delim);
- for ( ; __first != __last; ++ __first )
- {
- if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim))
+ for (; __first != __last; ++__first) {
+ if (_Traits::eq(*__first, __escape) || _Traits::eq(*__first, __delim))
__str.push_back(__escape);
__str.push_back(*__first);
}
@@ -531,139 +532,131 @@ __quoted_output ( basic_ostream<_CharT, _Traits> &__os,
}
template <class _CharT, class _Traits, class _String>
-basic_istream<_CharT, _Traits> &
-__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape )
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
+__quoted_input(basic_istream<_CharT, _Traits>& __is, _String& __string, _CharT __delim, _CharT __escape)
{
- __string.clear ();
+ __string.clear();
_CharT __c;
__is >> __c;
- if ( __is.fail ())
+ if (__is.fail())
return __is;
- if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string
- {
- __is.unget ();
+ if (!_Traits::eq(__c, __delim)) {
+ // no delimiter, read the whole string
+ __is.unget();
__is >> __string;
return __is;
}
- __save_flags<_CharT, _Traits> sf(__is);
- noskipws (__is);
- while (true)
- {
+ __save_flags<_CharT, _Traits> __sf(__is);
+ std::noskipws(__is);
+ while (true) {
__is >> __c;
- if ( __is.fail ())
+ if (__is.fail())
break;
- if (_Traits::eq (__c, __escape))
- {
+ if (_Traits::eq(__c, __escape)) {
__is >> __c;
- if ( __is.fail ())
+ if (__is.fail())
break;
- }
- else if (_Traits::eq (__c, __delim))
+ } else if (_Traits::eq(__c, __delim))
break;
- __string.push_back ( __c );
- }
+ __string.push_back(__c);
+ }
return __is;
}
-
-template <class _CharT, class _Traits, class _Iter>
-basic_ostream<_CharT, _Traits>& operator<<(
- basic_ostream<_CharT, _Traits>& __os,
- const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy)
+template <class _CharT, class _Traits>
+struct _LIBCPP_HIDDEN __quoted_output_proxy
{
- return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape);
-}
+ const _CharT *__first_;
+ const _CharT *__last_;
+ _CharT __delim_;
+ _CharT __escape_;
-template <class _CharT, class _Traits, class _Allocator>
-struct __quoted_proxy
-{
- basic_string<_CharT, _Traits, _Allocator> &__string;
- _CharT __delim;
- _CharT __escape;
+ _LIBCPP_HIDE_FROM_ABI
+ explicit __quoted_output_proxy(const _CharT *__f, const _CharT *__l, _CharT __d, _CharT __e)
+ : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {}
- __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e)
- : __string(__s), __delim(__d), __escape(__e) {}
+ template<class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value>* = nullptr>
+ friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _T2>&
+ operator<<(basic_ostream<_CharT, _T2>& __os, const __quoted_output_proxy& __p) {
+ return std::__quoted_output(__os, __p.__first_, __p.__last_, __p.__delim_, __p.__escape_);
+ }
};
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_INLINE_VISIBILITY
-basic_ostream<_CharT, _Traits>& operator<<(
- basic_ostream<_CharT, _Traits>& __os,
- const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
+struct _LIBCPP_HIDDEN __quoted_proxy
{
- return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape);
-}
-
-// extractor for non-const basic_string& proxies
-template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_INLINE_VISIBILITY
-basic_istream<_CharT, _Traits>& operator>>(
- basic_istream<_CharT, _Traits>& __is,
- const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
-{
- return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape );
-}
+ basic_string<_CharT, _Traits, _Allocator>& __string_;
+ _CharT __delim_;
+ _CharT __escape_;
+ _LIBCPP_HIDE_FROM_ABI
+ explicit __quoted_proxy(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __d, _CharT __e)
+ : __string_(__s), __delim_(__d), __escape_(__e) {}
-template <class _CharT>
-_LIBCPP_INLINE_VISIBILITY
-__quoted_output_proxy<_CharT, const _CharT *>
-quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\'))
-{
- const _CharT *__end = __s;
- while ( *__end ) ++__end;
- return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape );
-}
+ friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const __quoted_proxy& __p) {
+ return std::__quoted_output(__os, __p.__string_.data(), __p.__string_.data() + __p.__string_.size(), __p.__delim_, __p.__escape_);
+ }
+ friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, const __quoted_proxy& __p) {
+ return std::__quoted_input(__is, __p.__string_, __p.__delim_, __p.__escape_);
+ }
+};
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_INLINE_VISIBILITY
-__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
-__quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+_LIBCPP_HIDE_FROM_ABI
+__quoted_output_proxy<_CharT, _Traits>
+__quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
- return __quoted_output_proxy<_CharT,
- typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
- ( __s.cbegin(), __s.cend (), __delim, __escape );
+ return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape);
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
__quoted_proxy<_CharT, _Traits, _Allocator>
-__quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+__quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
- return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );
+ return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
}
+#endif // _LIBCPP_STD_VER >= 11
#if _LIBCPP_STD_VER > 11
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI
+auto quoted(const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
+{
+ const _CharT *__end = __s;
+ while (*__end) ++__end;
+ return __quoted_output_proxy<_CharT, void>(__s, __end, __delim, __escape);
+}
+
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_INLINE_VISIBILITY
-__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
-quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+_LIBCPP_HIDE_FROM_ABI
+auto quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
- return __quoted(__s, __delim, __escape);
+ return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape);
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_INLINE_VISIBILITY
-__quoted_proxy<_CharT, _Traits, _Allocator>
-quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+_LIBCPP_HIDE_FROM_ABI
+auto quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
- return __quoted(__s, __delim, __escape);
+ return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
}
template <class _CharT, class _Traits>
-__quoted_output_proxy<_CharT, const _CharT *, _Traits>
-quoted (basic_string_view <_CharT, _Traits> __sv,
- _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+_LIBCPP_HIDE_FROM_ABI
+auto quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
{
- return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
- ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
+ return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape);
}
-#endif
+
+#endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/ios
@@ -211,17 +211,27 @@ storage-class-specifier const error_category& iostream_category() noexcept;
*/
#include <__config>
+
+#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# error "The iostreams library is not supported since libc++ has been configured without support for localization."
+#endif
+
+#include <__assert> // all public C++ headers provide the assertion handler
+#include <__ios/fpos.h>
#include <__locale>
-#include <iosfwd>
+#include <__utility/swap.h>
#include <system_error>
#include <version>
+// standard-mandated includes
+#include <iosfwd>
+
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
#include <atomic> // for __xindex_
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -402,7 +412,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
template <>
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };
-#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+#ifdef _LIBCPP_CXX03_LANG
template <>
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };
#endif
@@ -780,6 +790,8 @@ inline _LIBCPP_INLINE_VISIBILITY
_CharT
basic_ios<_CharT, _Traits>::fill(char_type __ch)
{
+ if (traits_type::eq_int_type(traits_type::eof(), __fill_))
+ __fill_ = widen(' ');
char_type __r = __fill_;
__fill_ = __ch;
return __r;
lib/libcxx/include/iosfwd
@@ -94,12 +94,13 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__mbstate_t.h>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -231,10 +232,8 @@ typedef fpos<mbstate_t> wstreampos;
#ifndef _LIBCPP_HAS_NO_CHAR8_T
typedef fpos<mbstate_t> u8streampos;
#endif
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef fpos<mbstate_t> u16streampos;
typedef fpos<mbstate_t> u32streampos;
-#endif
#if defined(_NEWLIB_VERSION)
// On newlib, off_t is 'long int'
lib/libcxx/include/iostream
@@ -33,15 +33,18 @@ extern wostream wclog;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <version>
+
+// standard-mandated includes
#include <ios>
#include <istream>
#include <ostream>
#include <streambuf>
-#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/istream
@@ -158,13 +158,15 @@ template <class Stream, class T>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__iterator/istreambuf_iterator.h>
#include <__utility/forward.h>
#include <ostream>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -1592,7 +1594,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
size_t __c = 0;
_CharT __zero = __ct.widen('0');
_CharT __one = __ct.widen('1');
- while (__c < _Size)
+ while (__c != _Size)
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
@@ -1627,11 +1629,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
return __is;
}
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>;
#endif
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/iterator
@@ -136,6 +136,13 @@ template<class In, class Out>
template<class In, class Out>
concept indirectly_movable_storable = see below; // since C++20
+// [alg.req.ind.copy], concept indirectly_copyable
+template<class In, class Out>
+ concept indirectly_copyable = see below; // since C++20
+
+template<class In, class Out>
+ concept indirectly_copyable_storable = see below; // since C++20
+
// [alg.req.ind.swap], concept indirectly_swappable
template<class I1, class I2 = I1>
concept indirectly_swappable = see below; // since C++20
@@ -145,6 +152,19 @@ template<class I1, class I2, class R, class P1 = identity,
concept indirectly_comparable =
indirect_binary_predicate<R, projected<I1, P1>, projected<I2, P2>>; // since C++20
+// [alg.req.permutable], concept permutable
+template<class I>
+ concept permutable = see below; // since C++20
+
+ // [alg.req.mergeable], concept mergeable
+template<class I1, class I2, class Out,
+ class R = ranges::less, class P1 = identity, class P2 = identity>
+ concept mergeable = see below; // since C++20
+
+// [alg.req.sortable], concept sortable
+template<class I, class R = ranges::less, class P = identity>
+ concept sortable = see below; // since C++20
+
template<input_or_output_iterator I, sentinel_for<I> S>
requires (!same_as<I, S> && copyable<I>)
class common_iterator; // since C++20
@@ -165,6 +185,7 @@ struct output_iterator_tag {};
struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+struct contiguous_iterator_tag : public random_access_iterator_tag {};
// 27.4.3, iterator operations
template <class InputIterator, class Distance> // constexpr in C++17
@@ -204,10 +225,17 @@ class reverse_iterator
protected:
Iterator current;
public:
- typedef Iterator iterator_type;
- typedef typename iterator_traits<Iterator>::difference_type difference_type;
- typedef typename iterator_traits<Iterator>::reference reference;
- typedef typename iterator_traits<Iterator>::pointer pointer;
+ using iterator_type = Iterator;
+ using iterator_concept = see below; // since C++20
+ using iterator_category = typename iterator_traits<Iterator>::iterator_category; // since C++17, until C++20
+ using iterator_category = see below; // since C++20
+ using value_type = typename iterator_traits<Iterator>::value_type; // since C++17, until C++20
+ using value_type = iter_value_t<Iterator>; // since C++20
+ using difference_type = typename iterator_traits<Iterator>::difference_type; // until C++20
+ using difference_type = iter_difference_t<Iterator>; // since C++20
+ using pointer = typename iterator_traits<Iterator>::pointer;
+ using reference = typename iterator_traits<Iterator>::reference; // until C++20
+ using reference = iter_reference_t<Iterator>; // since C++20
constexpr reverse_iterator();
constexpr explicit reverse_iterator(Iterator x);
@@ -215,7 +243,8 @@ public:
template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u);
constexpr Iterator base() const;
constexpr reference operator*() const;
- constexpr pointer operator->() const;
+ constexpr pointer operator->() const; // until C++20
+ constexpr pointer operator->() const requires see below; // since C++20
constexpr reverse_iterator& operator++();
constexpr reverse_iterator operator++(int);
constexpr reverse_iterator& operator--();
@@ -224,7 +253,14 @@ public:
constexpr reverse_iterator& operator+=(difference_type n);
constexpr reverse_iterator operator- (difference_type n) const;
constexpr reverse_iterator& operator-=(difference_type n);
- constexpr reference operator[](difference_type n) const;
+ constexpr unspecified operator[](difference_type n) const;
+
+ friend constexpr iter_rvalue_reference_t<Iterator>
+ iter_move(const reverse_iterator& i) noexcept(see below);
+ template<indirectly_swappable<Iterator> Iterator2>
+ friend constexpr void
+ iter_swap(const reverse_iterator& x,
+ const reverse_iterator<Iterator2>& y) noexcept(see below);
};
template <class Iterator1, class Iterator2>
@@ -233,11 +269,11 @@ operator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
-operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
-operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
@@ -245,11 +281,16 @@ operator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
-operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
-operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template<class Iterator1, three_way_comparable_with<Iterator1> Iterator2>
+ constexpr compare_three_way_result_t<Iterator1, Iterator2>
+ operator<=>(const reverse_iterator<Iterator1>& x,
+ const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr auto
@@ -264,6 +305,11 @@ operator+(typename reverse_iterator<Iterator>::difference_type n,
template <class Iterator>
constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17
+template<class Iterator1, class Iterator2>
+ requires (!sized_sentinel_for<Iterator1, Iterator2>)
+ inline constexpr bool disable_sized_sentinel_for<reverse_iterator<Iterator1>,
+ reverse_iterator<Iterator2>> = true;
+
template <class Container>
class back_insert_iterator
: public iterator<output_iterator_tag, void, void, void, void> // until C++17
@@ -332,18 +378,21 @@ public:
insert_iterator& operator++(int); // constexpr in C++20
};
-template <class Container, class Iterator>
-insert_iterator<Container> inserter(Container& x, Iterator i); // constexpr in C++20
+template <class Container>
+insert_iterator<Container> inserter(Container& x, typename Container::iterator i); // until C++20
+template <class Container>
+constexpr insert_iterator<Container> inserter(Container& x, ranges::iterator_t<Container> i); // since C++20
template <class Iterator>
class move_iterator {
public:
- typedef Iterator iterator_type;
- typedef typename iterator_traits<Iterator>::difference_type difference_type;
- typedef Iterator pointer;
- typedef typename iterator_traits<Iterator>::value_type value_type;
- typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
- typedef value_type&& reference;
+ using iterator_type = Iterator;
+ using iterator_concept = input_iterator_tag; // From C++20
+ using iterator_category = see below; // not always present starting from C++20
+ using value_type = iter_value_t<Iterator>; // Until C++20, iterator_traits<Iterator>::value_type
+ using difference_type = iter_difference_t<Iterator>; // Until C++20, iterator_traits<Iterator>::difference_type;
+ using pointer = Iterator;
+ using reference = iter_rvalue_reference_t<Iterator>; // Until C++20, value_type&&
constexpr move_iterator(); // all the constexprs are in C++17
constexpr explicit move_iterator(Iterator i);
@@ -351,18 +400,40 @@ public:
constexpr move_iterator(const move_iterator<U>& u);
template <class U>
constexpr move_iterator& operator=(const move_iterator<U>& u);
- constexpr iterator_type base() const;
+
+ constexpr iterator_type base() const; // Until C++20
+ constexpr const Iterator& base() const & noexcept; // From C++20
+ constexpr Iterator base() &&; // From C++20
+
constexpr reference operator*() const;
- constexpr pointer operator->() const;
+ constexpr pointer operator->() const; // Deprecated in C++20
constexpr move_iterator& operator++();
- constexpr move_iterator operator++(int);
+ constexpr auto operator++(int); // Return type was move_iterator until C++20
constexpr move_iterator& operator--();
constexpr move_iterator operator--(int);
constexpr move_iterator operator+(difference_type n) const;
constexpr move_iterator& operator+=(difference_type n);
constexpr move_iterator operator-(difference_type n) const;
constexpr move_iterator& operator-=(difference_type n);
- constexpr unspecified operator[](difference_type n) const;
+ constexpr reference operator[](difference_type n) const; // Return type unspecified until C++20
+
+ template<sentinel_for<Iterator> S>
+ friend constexpr bool
+ operator==(const move_iterator& x, const move_sentinel<S>& y); // Since C++20
+ template<sized_sentinel_for<Iterator> S>
+ friend constexpr iter_difference_t<Iterator>
+ operator-(const move_sentinel<S>& x, const move_iterator& y); // Since C++20
+ template<sized_sentinel_for<Iterator> S>
+ friend constexpr iter_difference_t<Iterator>
+ operator-(const move_iterator& x, const move_sentinel<S>& y); // Since C++20
+ friend constexpr iter_rvalue_reference_t<Iterator>
+ iter_move(const move_iterator& i)
+ noexcept(noexcept(ranges::iter_move(i.current))); // Since C++20
+ template<indirectly_swappable<Iterator> Iterator2>
+ friend constexpr void
+ iter_swap(const move_iterator& x, const move_iterator<Iterator2>& y)
+ noexcept(noexcept(ranges::iter_swap(x.current, y.current))); // Since C++20
+
private:
Iterator current; // exposition only
};
@@ -404,6 +475,23 @@ constexpr move_iterator<Iterator> operator+( // constexpr in C++17
template <class Iterator> // constexpr in C++17
constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i);
+template<semiregular S>
+class move_sentinel {
+public:
+ constexpr move_sentinel();
+ constexpr explicit move_sentinel(S s);
+ template<class S2>
+ requires convertible_to<const S2&, S>
+ constexpr move_sentinel(const move_sentinel<S2>& s);
+ template<class S2>
+ requires assignable_from<S&, const S2&>
+ constexpr move_sentinel& operator=(const move_sentinel<S2>& s);
+
+ constexpr S base() const;
+private:
+ S last; // exposition only
+};
+
// [default.sentinel], default sentinel
struct default_sentinel_t;
inline constexpr default_sentinel_t default_sentinel{};
@@ -434,7 +522,8 @@ public:
typedef traits traits_type;
typedef basic_istream<charT, traits> istream_type;
- constexpr istream_iterator();
+ istream_iterator(); // constexpr since C++11
+ constexpr istream_iterator(default_sentinel_t); // since C++20
istream_iterator(istream_type& s);
istream_iterator(const istream_iterator& x);
~istream_iterator();
@@ -443,6 +532,7 @@ public:
const T* operator->() const;
istream_iterator& operator++();
istream_iterator operator++(int);
+ friend bool operator==(const istream_iterator& i, default_sentinel_t); // since C++20
};
template <class T, class charT, class traits, class Distance>
@@ -450,7 +540,7 @@ bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y);
template <class T, class charT, class traits, class Distance>
bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
- const istream_iterator<T,charT,traits,Distance>& y);
+ const istream_iterator<T,charT,traits,Distance>& y); // until C++20
template <class T, class charT = char, class traits = char_traits<charT> >
class ostream_iterator
@@ -496,7 +586,8 @@ public:
typedef basic_streambuf<charT, traits> streambuf_type;
typedef basic_istream<charT, traits> istream_type;
- istreambuf_iterator() noexcept;
+ istreambuf_iterator() noexcept; // constexpr since C++11
+ constexpr istreambuf_iterator(default_sentinel_t) noexcept; // since C++20
istreambuf_iterator(istream_type& s) noexcept;
istreambuf_iterator(streambuf_type* s) noexcept;
istreambuf_iterator(a-private-type) noexcept;
@@ -507,6 +598,7 @@ public:
a-private-type operator++(int);
bool equal(const istreambuf_iterator& b) const;
+ friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s); // since C++20
};
template <class charT, class traits>
@@ -514,7 +606,7 @@ bool operator==(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b);
template <class charT, class traits>
bool operator!=(const istreambuf_iterator<charT,traits>& a,
- const istreambuf_iterator<charT,traits>& b);
+ const istreambuf_iterator<charT,traits>& b); // until C++20
template <class charT, class traits = char_traits<charT> >
class ostreambuf_iterator
@@ -582,12 +674,13 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__debug>
-#include <__functional_base>
#include <__iterator/access.h>
#include <__iterator/advance.h>
#include <__iterator/back_insert_iterator.h>
+#include <__iterator/bounded_iter.h>
#include <__iterator/common_iterator.h>
#include <__iterator/concepts.h>
#include <__iterator/counted_iterator.h>
@@ -606,21 +699,24 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
#include <__iterator/iter_swap.h>
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/mergeable.h>
#include <__iterator/move_iterator.h>
+#include <__iterator/move_sentinel.h>
#include <__iterator/next.h>
#include <__iterator/ostream_iterator.h>
#include <__iterator/ostreambuf_iterator.h>
+#include <__iterator/permutable.h>
#include <__iterator/prev.h>
#include <__iterator/projected.h>
#include <__iterator/readable_traits.h>
#include <__iterator/reverse_access.h>
#include <__iterator/reverse_iterator.h>
#include <__iterator/size.h>
+#include <__iterator/sortable.h>
#include <__iterator/unreachable_sentinel.h>
#include <__iterator/wrap_iter.h>
#include <__memory/addressof.h>
#include <__memory/pointer_traits.h>
-#include <__utility/forward.h>
#include <compare>
#include <concepts> // Mandated by the Standard.
#include <cstddef>
@@ -628,8 +724,15 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
#include <type_traits>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <exception>
+# include <new>
+# include <typeinfo>
+# include <utility>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_ITERATOR
lib/libcxx/include/latch
@@ -40,17 +40,19 @@ namespace std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <atomic>
+#include <limits>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef _LIBCPP_HAS_NO_THREADS
-# error <latch> is not supported on this single threaded system
+# error "<latch> is not supported since libc++ has been configured without support for threads."
#endif
_LIBCPP_PUSH_MACROS
@@ -91,10 +93,9 @@ public:
inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait() const
{
- auto const __test_fn = [=]() -> bool {
+ __cxx_atomic_wait(&__a.__a_, [&]() -> bool {
return try_wait();
- };
- __cxx_atomic_wait(&__a.__a_, __test_fn);
+ });
}
inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_wait(ptrdiff_t __update = 1)
lib/libcxx/include/limits
@@ -101,6 +101,8 @@ template<> class numeric_limits<cv long double>;
} // std
*/
+
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <type_traits>
@@ -108,12 +110,8 @@ template<> class numeric_limits<cv long double>;
#include "__support/win32/limits_msvc_win32.h"
#endif // _LIBCPP_MSVCRT
-#if defined(__IBMCPP__)
-#include "__support/ibm/limits.h"
-#endif // __IBMCPP__
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -339,7 +337,11 @@ protected:
static _LIBCPP_CONSTEXPR const bool is_modulo = false;
static _LIBCPP_CONSTEXPR const bool traps = false;
+#if (defined(__arm__) || defined(__aarch64__))
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
+#else
static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+#endif
static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
};
@@ -385,7 +387,11 @@ protected:
static _LIBCPP_CONSTEXPR const bool is_modulo = false;
static _LIBCPP_CONSTEXPR const bool traps = false;
+#if (defined(__arm__) || defined(__aarch64__))
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
+#else
static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+#endif
static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
};
@@ -435,7 +441,11 @@ protected:
static _LIBCPP_CONSTEXPR const bool is_modulo = false;
static _LIBCPP_CONSTEXPR const bool traps = false;
+#if (defined(__arm__) || defined(__aarch64__))
+ static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
+#else
static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+#endif
static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
};
lib/libcxx/include/limits.h
@@ -40,7 +40,7 @@ Macros:
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifndef __GNUC__
lib/libcxx/include/list
@@ -180,19 +180,50 @@ template <class T, class Allocator, class Predicate>
*/
+#include <__algorithm/comp.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__debug>
+#include <__format/enable_insertable.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/move_iterator.h>
+#include <__iterator/next.h>
+#include <__iterator/prev.h>
+#include <__iterator/reverse_iterator.h>
+#include <__memory/swap_allocator.h>
#include <__utility/forward.h>
-#include <algorithm>
-#include <initializer_list>
-#include <iterator>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <limits>
#include <memory>
#include <type_traits>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <functional>
+# include <iterator>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [list.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -292,19 +323,15 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator
__link_pointer __ptr_;
-#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
: __ptr_(__p)
{
+ (void)__c;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
- }
-#else
- _LIBCPP_INLINE_VISIBILITY
- explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
#endif
-
-
+ }
template<class, class> friend class list;
template<class, class> friend class __list_imp;
@@ -322,7 +349,7 @@ public:
_VSTD::__debug_db_insert_i(this);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__list_iterator(const __list_iterator& __p)
@@ -348,7 +375,7 @@ public:
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const
@@ -405,17 +432,15 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator
__link_pointer __ptr_;
-#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
: __ptr_(__p)
{
+ (void)__c;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
- }
-#else
- _LIBCPP_INLINE_VISIBILITY
- explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
#endif
+ }
template<class, class> friend class list;
template<class, class> friend class __list_imp;
@@ -435,12 +460,12 @@ public:
__list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
: __ptr_(__p.__ptr_)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__iterator_copy(this, _VSTD::addressof(__p));
#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__list_const_iterator(const __list_const_iterator& __p)
@@ -466,7 +491,7 @@ public:
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const
{
@@ -593,38 +618,22 @@ protected:
_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__end_.__next_, this);
-#else
- return iterator(__end_.__next_);
-#endif
}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(__end_.__next_, this);
-#else
- return const_iterator(__end_.__next_);
-#endif
}
_LIBCPP_INLINE_VISIBILITY
iterator end() _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__end_as_link(), this);
-#else
- return iterator(__end_as_link());
-#endif
}
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT
{
-#if _LIBCPP_DEBUG_LEVEL == 2
return const_iterator(__end_as_link(), this);
-#else
- return const_iterator(__end_as_link());
-#endif
}
void swap(__list_imp& __c)
@@ -672,13 +681,6 @@ private:
void __move_assign_alloc(__list_imp&, false_type)
_NOEXCEPT
{}
-
- _LIBCPP_INLINE_VISIBILITY
- void __invalidate_all_iterators() {
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__invalidate_all(this);
-#endif
- }
};
// Unlink nodes [__f, __l]
@@ -720,9 +722,7 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
template <class _Tp, class _Alloc>
__list_imp<_Tp, _Alloc>::~__list_imp() {
clear();
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__erase_c(this);
-#endif
+ std::__debug_db_erase_c(this);
}
template <class _Tp, class _Alloc>
@@ -743,7 +743,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
__node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
__node_alloc_traits::deallocate(__na, __np, 1);
}
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
}
}
@@ -774,7 +774,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
else
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
@@ -871,13 +871,13 @@ public:
template <class _InpIter>
list(_InpIter __f, _InpIter __l,
- typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
+ __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0);
template <class _InpIter>
list(_InpIter __f, _InpIter __l, const allocator_type& __a,
- typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
+ __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0);
list(const list& __c);
- list(const list& __c, const __identity_t<allocator_type>& __a);
+ list(const list& __c, const __type_identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
list& operator=(const list& __c);
#ifndef _LIBCPP_CXX03_LANG
@@ -888,7 +888,7 @@ public:
list(list&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
_LIBCPP_INLINE_VISIBILITY
- list(list&& __c, const __identity_t<allocator_type>& __a);
+ list(list&& __c, const __type_identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
list& operator=(list&& __c)
_NOEXCEPT_(
@@ -906,7 +906,7 @@ public:
template <class _InpIter>
void assign(_InpIter __f, _InpIter __l,
- typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
+ __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0);
void assign(size_type __n, const value_type& __x);
_LIBCPP_INLINE_VISIBILITY
@@ -1023,7 +1023,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_cpp17_input_iterator<_InpIter>::value>::type* = 0);
+ __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0);
_LIBCPP_INLINE_VISIBILITY
void swap(list& __c)
@@ -1099,14 +1099,14 @@ public:
return __hold_pointer(__p, __node_destructor(__na, 1));
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
_LIBCPP_INLINE_VISIBILITY
@@ -1221,7 +1221,7 @@ list<_Tp, _Alloc>::list(size_type __n, const value_type& __x)
template <class _Tp, class _Alloc>
template <class _InpIter>
list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
- typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
+ __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*)
{
_VSTD::__debug_db_insert_c(this);
for (; __f != __l; ++__f)
@@ -1231,7 +1231,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_cpp17_input_iterator<_InpIter>::value>::type*)
+ __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*)
: base(__a)
{
_VSTD::__debug_db_insert_c(this);
@@ -1249,7 +1249,7 @@ list<_Tp, _Alloc>::list(const list& __c)
}
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(const list& __c, const __identity_t<allocator_type>& __a)
+list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a)
: base(__a)
{
_VSTD::__debug_db_insert_c(this);
@@ -1288,7 +1288,7 @@ inline list<_Tp, _Alloc>::list(list&& __c)
template <class _Tp, class _Alloc>
inline
-list<_Tp, _Alloc>::list(list&& __c, const __identity_t<allocator_type>& __a)
+list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a)
: base(__a)
{
_VSTD::__debug_db_insert_c(this);
@@ -1356,7 +1356,7 @@ template <class _Tp, class _Alloc>
template <class _InpIter>
void
list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
- typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*)
+ __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*)
{
iterator __i = begin();
iterator __e = end();
@@ -1366,9 +1366,7 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
insert(__e, __f, __l);
else
erase(__i, __e);
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__invalidate_all(this);
-#endif
+ std::__debug_db_invalidate_all(this);
}
template <class _Tp, class _Alloc>
@@ -1383,9 +1381,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
insert(__e, __n, __x);
else
erase(__i, __e);
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__invalidate_all(this);
-#endif
+ std::__debug_db_invalidate_all(this);
}
template <class _Tp, class _Alloc>
@@ -1407,11 +1403,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
__link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
++base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__hold.release()->__as_link(), this);
-#else
- return iterator(__hold.release()->__as_link());
-#endif
}
template <class _Tp, class _Alloc>
@@ -1420,11 +1412,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
"list::insert(iterator, n, x) called with an iterator not referring to this list");
-#if _LIBCPP_DEBUG_LEVEL == 2
iterator __r(__p.__ptr_, this);
-#else
- iterator __r(__p.__ptr_);
-#endif
if (__n > 0)
{
size_type __ds = 0;
@@ -1432,11 +1420,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
__hold_pointer __hold = __allocate_node(__na);
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
++__ds;
-#if _LIBCPP_DEBUG_LEVEL == 2
__r = iterator(__hold->__as_link(), this);
-#else
- __r = iterator(__hold->__as_link());
-#endif
__hold.release();
iterator __e = __r;
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1462,11 +1446,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
if (__prev == 0)
break;
-#if _LIBCPP_DEBUG_LEVEL == 2
__e = iterator(__prev, this);
-#else
- __e = iterator(__prev);
-#endif
}
throw;
}
@@ -1481,15 +1461,11 @@ 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_cpp17_input_iterator<_InpIter>::value>::type*)
+ __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*)
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
"list::insert(iterator, range) called with an iterator not referring to this list");
-#if _LIBCPP_DEBUG_LEVEL == 2
iterator __r(__p.__ptr_, this);
-#else
- iterator __r(__p.__ptr_);
-#endif
if (__f != __l)
{
size_type __ds = 0;
@@ -1497,11 +1473,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
__hold_pointer __hold = __allocate_node(__na);
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
++__ds;
-#if _LIBCPP_DEBUG_LEVEL == 2
__r = iterator(__hold.get()->__as_link(), this);
-#else
- __r = iterator(__hold.get()->__as_link());
-#endif
__hold.release();
iterator __e = __r;
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1527,11 +1499,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
if (__prev == 0)
break;
-#if _LIBCPP_DEBUG_LEVEL == 2
__e = iterator(__prev, this);
-#else
- __e = iterator(__prev);
-#endif
}
throw;
}
@@ -1650,11 +1618,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
__link_nodes(__p.__ptr_, __nl, __nl);
++base::__sz();
__hold.release();
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__nl, this);
-#else
- return iterator(__nl);
-#endif
}
template <class _Tp, class _Alloc>
@@ -1670,11 +1634,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
__link_nodes(__p.__ptr_, __nl, __nl);
++base::__sz();
__hold.release();
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__nl, this);
-#else
- return iterator(__nl);
-#endif
}
#endif // _LIBCPP_CXX03_LANG
@@ -1688,7 +1648,7 @@ list<_Tp, _Alloc>::pop_front()
__link_pointer __n = base::__end_.__next_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1717,7 +1677,7 @@ list<_Tp, _Alloc>::pop_back()
__link_pointer __n = base::__end_.__prev_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1750,7 +1710,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
__link_pointer __r = __n->__next_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __ip = __c->end_; __ip != __c->beg_; )
{
@@ -1768,11 +1728,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
__node_pointer __np = __n->__as_node();
__node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
__node_alloc_traits::deallocate(__na, __np, 1);
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__r, this);
-#else
- return iterator(__r);
-#endif
}
template <class _Tp, class _Alloc>
@@ -1792,7 +1748,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
__link_pointer __n = __f.__ptr_;
++__f;
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1812,11 +1768,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
__node_alloc_traits::deallocate(__na, __np, 1);
}
}
-#if _LIBCPP_DEBUG_LEVEL == 2
return iterator(__l.__ptr_, this);
-#else
- return iterator(__l.__ptr_);
-#endif
}
template <class _Tp, class _Alloc>
@@ -1833,11 +1785,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
__hold_pointer __hold = __allocate_node(__na);
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
++__ds;
-#if _LIBCPP_DEBUG_LEVEL == 2
iterator __r = iterator(__hold.release()->__as_link(), this);
-#else
- iterator __r = iterator(__hold.release()->__as_link());
-#endif
iterator __e = __r;
#ifndef _LIBCPP_NO_EXCEPTIONS
try
@@ -1862,11 +1810,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
if (__prev == 0)
break;
-#if _LIBCPP_DEBUG_LEVEL == 2
__e = iterator(__prev, this);
-#else
- __e = iterator(__prev);
-#endif
}
throw;
}
@@ -1891,11 +1835,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
++__ds;
__link_pointer __nl = __hold.release()->__as_link();
-#if _LIBCPP_DEBUG_LEVEL == 2
iterator __r = iterator(__nl, this);
-#else
- iterator __r = iterator(__nl);
-#endif
iterator __e = __r;
#ifndef _LIBCPP_NO_EXCEPTIONS
try
@@ -1920,11 +1860,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
if (__prev == 0)
break;
-#if _LIBCPP_DEBUG_LEVEL == 2
__e = iterator(__prev, this);
-#else
- __e = iterator(__prev);
-#endif
}
throw;
}
@@ -1950,7 +1886,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
__link_nodes(__p.__ptr_, __f, __l);
base::__sz() += __c.__sz();
__c.__sz() = 0;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (_VSTD::addressof(__c) != this) {
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
@@ -1991,7 +1927,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
__link_nodes(__p.__ptr_, __f, __f);
--__c.__sz();
++base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (_VSTD::addressof(__c) != this) {
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
@@ -2014,6 +1950,17 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
}
}
+template <class _Iterator>
+_LIBCPP_HIDE_FROM_ABI
+bool __iterator_in_range(_Iterator __first, _Iterator __last, _Iterator __it) {
+ for (_Iterator __p = __first; __p != __last; ++__p) {
+ if (__p == __it) {
+ return true;
+ }
+ }
+ return false;
+}
+
template <class _Tp, class _Alloc>
void
list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)
@@ -2024,16 +1971,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
"list::splice(iterator, list, iterator, iterator) called with second iterator not referring to the list argument");
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == _VSTD::addressof(__c),
"list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument");
+ _LIBCPP_DEBUG_ASSERT(this != std::addressof(__c) || !std::__iterator_in_range(__f, __l, __p),
+ "list::splice(iterator, list, iterator, iterator)"
+ " called with the first iterator within the range of the second and third iterators");
-#if _LIBCPP_DEBUG_LEVEL == 2
- if (this == _VSTD::addressof(__c))
- {
- for (const_iterator __i = __f; __i != __l; ++__i)
- _LIBCPP_DEBUG_ASSERT(__i != __p,
- "list::splice(iterator, list, iterator, iterator)"
- " called with the first iterator within the range of the second and third iterators");
- }
-#endif
if (__f != __l)
{
__link_pointer __first = __f.__ptr_;
@@ -2047,7 +1988,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
}
base::__unlink_nodes(__first, __last);
__link_nodes(__p.__ptr_, __first, __last);
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (_VSTD::addressof(__c) != this) {
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
@@ -2184,7 +2125,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
++__f1;
}
splice(__e1, __c);
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
@@ -2308,7 +2249,7 @@ list<_Tp, _Alloc>::__invariants() const
return size() == _VSTD::distance(begin(), end());
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Alloc>
bool
@@ -2338,7 +2279,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
return false;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
@@ -2409,8 +2350,16 @@ inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type
erase(list<_Tp, _Allocator>& __c, const _Up& __v) {
return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; });
}
+
+template <>
+inline constexpr bool __format::__enable_insertable<std::list<char>> = true;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;
#endif
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
lib/libcxx/include/locale
@@ -187,26 +187,37 @@ template <class charT> class messages_byname;
*/
+#include <__algorithm/copy.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/find.h>
+#include <__algorithm/max.h>
+#include <__algorithm/reverse.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__debug>
+#include <__iterator/access.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/istreambuf_iterator.h>
+#include <__iterator/ostreambuf_iterator.h>
#include <__locale>
-#include <algorithm>
-#ifndef __APPLE__
-# include <cstdarg>
-#endif
+#include <cstdarg> // TODO: Remove this include
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <ios>
-#include <iterator>
#include <limits>
#include <memory>
#include <streambuf>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iterator>
+#endif
+
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
// Most unix variants have catopen. These are the specific ones that don't.
-# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
+# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
# define _LIBCPP_HAS_CATOPEN 1
# include <nl_types.h>
# endif
@@ -219,7 +230,7 @@ template <class charT> class messages_byname;
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -572,9 +583,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
return 0;
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)
+extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)
+extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>;
#endif
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
@@ -1112,9 +1123,9 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>;
#endif
struct _LIBCPP_TYPE_VIS __num_put_base
@@ -1264,9 +1275,9 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
__op = __ob + (__np - __nb);
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)
+extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)
+extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>;
#endif
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
@@ -1456,7 +1467,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
return do_put(__s, __iob, __fl, (unsigned long)__v);
const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());
typedef typename numpunct<char_type>::string_type string_type;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
string_type __tmp(__v ? __np.truename() : __np.falsename());
string_type __nm = _VSTD::move(__tmp);
#else
@@ -1486,10 +1497,11 @@ num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __i
+ ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up
+ 2; // base prefix + terminating null character
char __nar[__nbuf];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
-#pragma clang diagnostic pop
+ _LIBCPP_DIAGNOSTIC_POP
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
// Stage 2 - Widen __nar while adding thousands separators
@@ -1549,8 +1561,9 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas
char __nar[__nbuf];
char* __nb = __nar;
int __nc;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
if (__specify_precision)
__nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
(int)__iob.precision(), __v);
@@ -1567,7 +1580,7 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas
__throw_bad_alloc();
__nbh.reset(__nb);
}
-#pragma clang diagnostic pop
+ _LIBCPP_DIAGNOSTIC_POP
char* __ne = __nb + __nc;
char* __np = this->__identify_padding(__nb, __ne, __iob);
// Stage 2 - Widen __nar while adding thousands separators
@@ -1633,9 +1646,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
#endif
template <class _CharT, class _InputIterator>
@@ -1918,7 +1931,7 @@ time_get<_CharT, _InputIterator>::__get_month(int& __m,
const ctype<char_type>& __ct) const
{
int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
- if (!(__err & ios_base::failbit) && __t <= 11)
+ if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11)
__m = __t;
else
__err |= ios_base::failbit;
@@ -2323,9 +2336,9 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>;
#endif
class _LIBCPP_TYPE_VIS __time_get
@@ -2425,9 +2438,9 @@ private:
virtual const string_type& __X() const {return this->__X_;}
};
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>;
#endif
class _LIBCPP_TYPE_VIS __time_put
@@ -2540,9 +2553,9 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,
return _VSTD::copy(__nb, __ne, __s);
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>;
#endif
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
@@ -2563,9 +2576,9 @@ protected:
~time_put_byname() {}
};
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>;
#endif
// money_base
@@ -2632,11 +2645,11 @@ template <class _CharT, bool _International>
const bool
moneypunct<_CharT, _International>::intl;
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>;
#endif
// moneypunct_byname
@@ -2688,14 +2701,14 @@ private:
template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, false>::init(const char*);
template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*);
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*);
template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*);
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>;
#endif
// money_get
@@ -2752,9 +2765,9 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
}
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>;
#endif
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
@@ -3121,9 +3134,9 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>;
#endif
// money_put
@@ -3214,9 +3227,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
int __fd)
{
__me = __mb;
- for (unsigned __p = 0; __p < 4; ++__p)
+ for (char __p : __pat.field)
{
- switch (__pat.field[__p])
+ switch (__p)
{
case money_base::none:
__mi = __me;
@@ -3298,9 +3311,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
__mi = __mb;
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>;
#endif
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
@@ -3453,9 +3466,9 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>;
#endif
// messages
@@ -3571,9 +3584,9 @@ messages<_CharT>::do_close(catalog __c) const
#endif // _LIBCPP_HAS_CATOPEN
}
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>;
#endif
template <class _CharT>
@@ -3597,15 +3610,15 @@ protected:
~messages_byname() {}
};
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>;
#endif
template<class _Codecvt, class _Elem = wchar_t,
class _Wide_alloc = allocator<_Elem>,
class _Byte_alloc = allocator<char> >
-class _LIBCPP_TEMPLATE_VIS wstring_convert
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert
{
public:
typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string;
@@ -3672,6 +3685,7 @@ public:
state_type state() const {return __cvtstate_;}
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
inline
wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
@@ -3679,6 +3693,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
: __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0)
{
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
inline
@@ -3713,6 +3728,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
#endif // _LIBCPP_CXX03_LANG
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert()
{
@@ -3724,6 +3740,7 @@ typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string
wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
from_bytes(const char* __frm, const char* __frm_end)
{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
__cvtcount_ = 0;
if (__cvtptr_ != nullptr)
{
@@ -3870,7 +3887,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
}
template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
-class _LIBCPP_TEMPLATE_VIS wbuffer_convert
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert
: public basic_streambuf<_Elem, _Tr>
{
public:
@@ -3947,6 +3964,7 @@ private:
wbuffer_convert* __close();
};
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Codecvt, class _Elem, class _Tr>
wbuffer_convert<_Codecvt, _Elem, _Tr>::
wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)
@@ -3982,6 +4000,7 @@ template <class _Codecvt, class _Elem, class _Tr>
typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
if (__cv_ == 0 || __bufptr_ == 0)
return traits_type::eof();
bool __initial = __read_mode();
@@ -4046,10 +4065,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
return __c;
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Codecvt, class _Elem, class _Tr>
typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c)
{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
if (__cv_ != 0 && __bufptr_ != 0 && this->eback() < this->gptr())
{
if (traits_type::eq_int_type(__c, traits_type::eof()))
@@ -4067,10 +4088,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c)
return traits_type::eof();
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Codecvt, class _Elem, class _Tr>
typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
if (__cv_ == 0 || __bufptr_ == 0)
return traits_type::eof();
__write_mode();
@@ -4129,10 +4152,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
return traits_type::not_eof(__c);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Codecvt, class _Elem, class _Tr>
basic_streambuf<_Elem, _Tr>*
wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n)
{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
this->setg(0, 0, 0);
this->setp(0, 0);
if (__owns_eb_)
@@ -4182,6 +4207,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n)
return this;
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Codecvt, class _Elem, class _Tr>
typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way,
@@ -4213,6 +4239,7 @@ template <class _Codecvt, class _Elem, class _Tr>
int
wbuffer_convert<_Codecvt, _Elem, _Tr>::sync()
{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
if (__cv_ == 0 || __bufptr_ == 0)
return 0;
if (__cm_ & ios_base::out)
@@ -4281,6 +4308,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::sync()
return 0;
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Codecvt, class _Elem, class _Tr>
bool
wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode()
@@ -4335,6 +4363,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::__close()
return __rt;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
lib/libcxx/include/locale.h
@@ -36,11 +36,11 @@ Functions:
#include <__config>
#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# error "The Localization library is not supported since libc++ has been configured with LIBCXX_ENABLE_LOCALIZATION disabled"
+# error "<locale.h> is not supported since libc++ has been configured without support for localization."
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <locale.h>
lib/libcxx/include/map
@@ -528,24 +528,45 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
*/
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__debug>
+#include <__functional/binary_function.h>
#include <__functional/is_transparent.h>
+#include <__functional/operations.h>
+#include <__iterator/erase_if_container.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
#include <__node_handle>
#include <__tree>
#include <__utility/forward.h>
-#include <compare>
-#include <functional>
-#include <initializer_list>
-#include <iterator> // __libcpp_erase_if_container
+#include <__utility/swap.h>
#include <memory>
#include <type_traits>
-#include <utility>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <functional>
+# include <iterator>
+# include <utility>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [associative.map.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -561,9 +582,9 @@ public:
_NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
: _Compare() {}
_LIBCPP_INLINE_VISIBILITY
- __map_value_compare(_Compare c)
+ __map_value_compare(_Compare __c)
_NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
- : _Compare(c) {}
+ : _Compare(__c) {}
_LIBCPP_INLINE_VISIBILITY
const _Compare& key_comp() const _NOEXCEPT {return *this;}
_LIBCPP_INLINE_VISIBILITY
@@ -606,9 +627,9 @@ public:
_NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
: comp() {}
_LIBCPP_INLINE_VISIBILITY
- __map_value_compare(_Compare c)
+ __map_value_compare(_Compare __c)
_NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
- : comp(c) {}
+ : comp(__c) {}
_LIBCPP_INLINE_VISIBILITY
const _Compare& key_comp() const _NOEXCEPT {return comp;}
@@ -771,9 +792,7 @@ public:
}
template <class _ValueTp,
- class = typename enable_if<
- __is_same_uncvref<_ValueTp, value_type>::value
- >::type
+ class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value>
>
_LIBCPP_INLINE_VISIBILITY
__value_type& operator=(_ValueTp&& __v)
@@ -956,32 +975,23 @@ public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef pair<const key_type, mapped_type> value_type;
- typedef __identity_t<_Compare> key_compare;
- typedef __identity_t<_Allocator> allocator_type;
+ typedef __type_identity_t<_Compare> key_compare;
+ typedef __type_identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
class _LIBCPP_TEMPLATE_VIS value_compare
-#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- : public binary_function<value_type, value_type, bool>
-#endif
+ : public __binary_function<value_type, value_type, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
friend class map;
protected:
key_compare comp;
- _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {}
+ _LIBCPP_INLINE_VISIBILITY value_compare(key_compare __c) : comp(__c) {}
public:
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
bool operator()(const value_type& __x, const value_type& __y) const
{return comp(__x.first, __y.first);}
@@ -1218,13 +1228,13 @@ public:
}
template <class _Pp,
- class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert(_Pp&& __p)
{return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}
template <class _Pp,
- class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __pos, _Pp&& __p)
{return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
@@ -1444,11 +1454,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
find(const _K2& __k) {return __tree_.find(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
find(const _K2& __k) const {return __tree_.find(__k);}
#endif
@@ -1458,7 +1468,7 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type>
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
#endif
@@ -1467,7 +1477,7 @@ public:
bool contains(const key_type& __k) const {return find(__k) != end();}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, bool>
contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER > 17
@@ -1480,12 +1490,12 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
#endif
@@ -1498,11 +1508,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
#endif
@@ -1515,11 +1525,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>>
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>>
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
#endif
@@ -1741,33 +1751,24 @@ public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef pair<const key_type, mapped_type> value_type;
- typedef __identity_t<_Compare> key_compare;
- typedef __identity_t<_Allocator> allocator_type;
+ typedef __type_identity_t<_Compare> key_compare;
+ typedef __type_identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
class _LIBCPP_TEMPLATE_VIS value_compare
-#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- : public binary_function<value_type, value_type, bool>
-#endif
+ : public __binary_function<value_type, value_type, bool>
{
-_LIBCPP_SUPPRESS_DEPRECATED_POP
friend class multimap;
protected:
key_compare comp;
_LIBCPP_INLINE_VISIBILITY
- value_compare(key_compare c) : comp(c) {}
+ value_compare(key_compare __c) : comp(__c) {}
public:
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
-#endif
_LIBCPP_INLINE_VISIBILITY
bool operator()(const value_type& __x, const value_type& __y) const
{return comp(__x.first, __y.first);}
@@ -1997,13 +1998,13 @@ public:
}
template <class _Pp,
- class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ class = __enable_if_t<is_constructible<value_type, _Pp>::value>>
_LIBCPP_INLINE_VISIBILITY
iterator insert(_Pp&& __p)
{return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));}
template <class _Pp,
- class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ class = __enable_if_t<is_constructible<value_type, _Pp>::value>>
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __pos, _Pp&& __p)
{return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}
@@ -2125,11 +2126,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
find(const _K2& __k) {return __tree_.find(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
find(const _K2& __k) const {return __tree_.find(__k);}
#endif
@@ -2139,7 +2140,7 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type>
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
#endif
@@ -2148,7 +2149,7 @@ public:
bool contains(const key_type& __k) const {return find(__k) != end();}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, bool>
contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER > 17
@@ -2161,12 +2162,12 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
#endif
@@ -2179,11 +2180,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator>
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator>
upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
#endif
@@ -2196,11 +2197,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>>
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
+ __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>>
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
#endif
lib/libcxx/include/math.h
@@ -294,7 +294,7 @@ long double truncl(long double x);
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <math.h>
@@ -305,6 +305,7 @@ long double truncl(long double x);
// back to C++ linkage before including these C++ headers.
extern "C++" {
+#include <__type_traits/promote.h>
#include <limits>
#include <stdlib.h>
#include <type_traits>
@@ -788,10 +789,10 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
// acos
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -800,10 +801,10 @@ acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
// asin
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -812,10 +813,10 @@ asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
// atan
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -824,10 +825,10 @@ atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
// atan2
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
-#endif
+# endif
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
@@ -847,10 +848,10 @@ atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
// ceil
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -859,10 +860,10 @@ ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
// cos
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -871,10 +872,10 @@ cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
// cosh
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -883,10 +884,10 @@ cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
// exp
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -895,10 +896,10 @@ exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
// fabs
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -907,10 +908,10 @@ fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
// floor
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -919,10 +920,10 @@ floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
// fmod
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
-#endif
+# endif
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
@@ -942,10 +943,10 @@ fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
// frexp
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -954,10 +955,10 @@ frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, _
// ldexp
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -966,10 +967,10 @@ ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __
// log
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -978,10 +979,10 @@ log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
// log10
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -990,17 +991,17 @@ log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
// modf
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
-#endif
+# endif
// pow
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
-#endif
+# endif
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1020,7 +1021,7 @@ pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
// sin
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
#endif
@@ -1032,10 +1033,10 @@ sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
// sinh
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1044,10 +1045,10 @@ sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
// sqrt
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1056,10 +1057,10 @@ sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
// tan
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1068,10 +1069,10 @@ tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
// tanh
-#if !(defined(_AIX) || defined(__sun__))
+# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
-#endif
+# endif
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/memory
@@ -98,6 +98,16 @@ struct allocator_traits
static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
};
+template<class Pointer>
+struct allocation_result {
+ Pointer ptr;
+ size_t count;
+}; // since C++23
+
+template<class Allocator>
+[[nodiscard]] constexpr allocation_result<typename allocator_traits<Allocator>::pointer>
+ allocate_at_least(Allocator& a, size_t n); // since C++23
+
template <>
class allocator<void> // removed in C++20
{
@@ -661,9 +671,29 @@ template<class E, class T, class Y>
template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
template<class T, class... Args>
- shared_ptr<T> make_shared(Args&&... args);
+ shared_ptr<T> make_shared(Args&&... args); // T is not an array
template<class T, class A, class... Args>
- shared_ptr<T> allocate_shared(const A& a, Args&&... args);
+ shared_ptr<T> allocate_shared(const A& a, Args&&... args); // T is not an array
+
+template<class T>
+ shared_ptr<T> make_shared(size_t N); // T is U[] (since C++20)
+template<class T, class A>
+ shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[] (since C++20)
+
+template<class T>
+ shared_ptr<T> make_shared(); // T is U[N] (since C++20)
+template<class T, class A>
+ shared_ptr<T> allocate_shared(const A& a); // T is U[N] (since C++20)
+
+template<class T>
+ shared_ptr<T> make_shared(size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20)
+template<class T, class A>
+ shared_ptr<T> allocate_shared(const A& a, size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20)
+
+template<class T> shared_ptr<T>
+ make_shared(const remove_extent_t<T>& u); // T is U[N] (since C++20)
+template<class T, class A>
+ shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N] (since C++20)
template<class T>
class weak_ptr
@@ -798,19 +828,28 @@ template <class T> struct hash<shared_ptr<T> >;
template <class T, class Alloc>
inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
+// [ptr.align]
void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+template<size_t N, class T>
+[[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20
+
} // std
*/
+#include <__algorithm/copy.h>
+#include <__algorithm/move.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__functional_base>
#include <__memory/addressof.h>
+#include <__memory/allocate_at_least.h>
#include <__memory/allocation_guard.h>
#include <__memory/allocator.h>
#include <__memory/allocator_arg_t.h>
#include <__memory/allocator_traits.h>
+#include <__memory/assume_aligned.h>
+#include <__memory/auto_ptr.h>
#include <__memory/compressed_pair.h>
#include <__memory/concepts.h>
#include <__memory/construct_at.h>
@@ -823,117 +862,31 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
#include <__memory/uninitialized_algorithms.h>
#include <__memory/unique_ptr.h>
#include <__memory/uses_allocator.h>
-#include <compare>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <iosfwd>
-#include <iterator>
#include <new>
#include <stdexcept>
#include <tuple>
#include <type_traits>
#include <typeinfo>
-#include <utility>
#include <version>
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-# include <__memory/auto_ptr.h>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iterator>
+# include <utility>
#endif
+// standard-mandated includes
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Alloc, class _Ptr>
-_LIBCPP_INLINE_VISIBILITY
-void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) {
- static_assert(__is_cpp17_move_insertable<_Alloc>::value,
- "The specified type does not meet the requirements of Cpp17MoveInsertable");
- typedef allocator_traits<_Alloc> _Traits;
- for (; __begin1 != __end1; ++__begin1, (void)++__begin2) {
- _Traits::construct(__a, _VSTD::__to_address(__begin2),
-#ifdef _LIBCPP_NO_EXCEPTIONS
- _VSTD::move(*__begin1)
-#else
- _VSTD::move_if_noexcept(*__begin1)
-#endif
- );
- }
-}
-
-template <class _Alloc, class _Tp, typename enable_if<
- (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
- is_trivially_move_constructible<_Tp>::value
->::type>
-_LIBCPP_INLINE_VISIBILITY
-void __construct_forward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) {
- ptrdiff_t _Np = __end1 - __begin1;
- if (_Np > 0) {
- _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
- __begin2 += _Np;
- }
-}
-
-template <class _Alloc, class _Iter, class _Ptr>
-_LIBCPP_INLINE_VISIBILITY
-void __construct_range_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) {
- typedef allocator_traits<_Alloc> _Traits;
- for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) {
- _Traits::construct(__a, _VSTD::__to_address(__begin2), *__begin1);
- }
-}
-
-template <class _Alloc, class _Source, class _Dest,
- class _RawSource = typename remove_const<_Source>::type,
- class _RawDest = typename remove_const<_Dest>::type,
- class =
- typename enable_if<
- is_trivially_copy_constructible<_Dest>::value &&
- is_same<_RawSource, _RawDest>::value &&
- (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Dest*, _Source&>::value)
- >::type>
-_LIBCPP_INLINE_VISIBILITY
-void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) {
- ptrdiff_t _Np = __end1 - __begin1;
- if (_Np > 0) {
- _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest));
- __begin2 += _Np;
- }
-}
-
-template <class _Alloc, class _Ptr>
-_LIBCPP_INLINE_VISIBILITY
-void __construct_backward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) {
- static_assert(__is_cpp17_move_insertable<_Alloc>::value,
- "The specified type does not meet the requirements of Cpp17MoveInsertable");
- typedef allocator_traits<_Alloc> _Traits;
- while (__end1 != __begin1) {
- _Traits::construct(__a, _VSTD::__to_address(__end2 - 1),
-#ifdef _LIBCPP_NO_EXCEPTIONS
- _VSTD::move(*--__end1)
-#else
- _VSTD::move_if_noexcept(*--__end1)
-#endif
- );
- --__end2;
- }
-}
-
-template <class _Alloc, class _Tp, class = typename enable_if<
- (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) &&
- is_trivially_move_constructible<_Tp>::value
->::type>
-_LIBCPP_INLINE_VISIBILITY
-void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) {
- ptrdiff_t _Np = __end1 - __begin1;
- __end2 -= _Np;
- if (_Np > 0)
- _VSTD::memcpy(static_cast<void*>(__end2), static_cast<void const*>(__begin1), _Np * sizeof(_Tp));
-}
-
struct __destruct_n
{
private:
@@ -975,37 +928,6 @@ public:
_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
-// --- Helper for container swap --
-template <typename _Alloc>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
-#if _LIBCPP_STD_VER > 11
- _NOEXCEPT
-#else
- _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
-#endif
-{
- using _VSTD::swap;
- swap(__a1, __a2);
-}
-
-template <typename _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
-
-template <typename _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
-#if _LIBCPP_STD_VER > 11
- _NOEXCEPT
-#else
- _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
-#endif
-{
- _VSTD::__swap_allocator(__a1, __a2,
- integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
-}
-
template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
struct __noexcept_move_assign_container : public integral_constant<bool,
_Traits::propagate_on_container_move_assignment::value
@@ -1021,21 +943,31 @@ template <class _Tp, class _Alloc>
struct __temp_value {
typedef allocator_traits<_Alloc> _Traits;
+#ifdef _LIBCPP_CXX03_LANG
typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
+#else
+ union { _Tp __v; };
+#endif
_Alloc &__a;
- _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
- _Tp & get() { return *__addr(); }
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp *__addr() {
+#ifdef _LIBCPP_CXX03_LANG
+ return reinterpret_cast<_Tp*>(std::addressof(__v));
+#else
+ return std::addressof(__v);
+#endif
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp & get() { return *__addr(); }
template<class... _Args>
_LIBCPP_NO_CFI
- __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
- _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
- _VSTD::forward<_Args>(__args)...);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
+ _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
}
- ~__temp_value() { _Traits::destroy(__a, __addr()); }
- };
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__temp_value() { _Traits::destroy(__a, __addr()); }
+};
template<typename _Alloc, typename = void, typename = void>
struct __is_allocator : false_type {};
@@ -1058,8 +990,8 @@ struct __builtin_new_allocator {
_LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align)
: __size_(__size), __align_(__align) {}
- void operator()(void* p) const _NOEXCEPT {
- _VSTD::__libcpp_deallocate(p, __size_, __align_);
+ void operator()(void* __p) const _NOEXCEPT {
+ _VSTD::__libcpp_deallocate(__p, __size_, __align_);
}
private:
@@ -1092,7 +1024,6 @@ struct __builtin_new_allocator {
}
};
-
_LIBCPP_END_NAMESPACE_STD
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
lib/libcxx/include/module.modulemap
@@ -1,1092 +0,0 @@
-// define the module for __config outside of the top level 'std' module
-// since __config may be included from C headers which may create an
-// include cycle.
-module std_config [system] [extern_c] {
- textual header "__config"
- textual header "__config_site"
-}
-
-module std [system] {
- export std_config
- // FIXME: The standard does not require that each of these submodules
- // re-exports its imported modules. We should provide an alternative form of
- // export that issues a warning if a name from the submodule is used, and
- // use that to provide a 'strict mode' for libc++.
-
- // Deprecated C-compatibility headers. These can all be included from within
- // an 'extern "C"' context.
- module depr [extern_c] {
- // <assert.h> provided by C library.
- module ctype_h {
- header "ctype.h"
- export *
- }
- module errno_h {
- header "errno.h"
- export *
- }
- module fenv_h {
- header "fenv.h"
- export *
- }
- // <float.h> provided by compiler or C library.
- module inttypes_h {
- header "inttypes.h"
- export stdint_h
- export *
- }
- // <iso646.h> provided by compiler.
- // <limits.h> provided by compiler or C library.
- module locale_h {
- header "locale.h"
- export *
- }
- module math_h {
- header "math.h"
- export *
- }
- module setjmp_h {
- header "setjmp.h"
- export *
- }
- // FIXME: <stdalign.h> is missing.
- // <signal.h> provided by C library.
- // <stdarg.h> provided by compiler.
- // <stdbool.h> provided by compiler.
- module stddef_h {
- // <stddef.h>'s __need_* macros require textual inclusion.
- textual header "stddef.h"
- }
- module stdint_h {
- header "stdint.h"
- export *
- // FIXME: This module only exists on OS X and for some reason the
- // wildcard above doesn't export it.
- export Darwin.C.stdint
- }
- module stdio_h {
- // <stdio.h>'s __need_* macros require textual inclusion.
- textual header "stdio.h"
- export *
- export Darwin.C.stdio
- }
- module stdlib_h {
- // <stdlib.h>'s __need_* macros require textual inclusion.
- textual header "stdlib.h"
- export *
- }
- module string_h {
- header "string.h"
- export *
- }
- // FIXME: <uchar.h> is missing.
- // <time.h> provided by C library.
- module wchar_h {
- // <wchar.h>'s __need_* macros require textual inclusion.
- textual header "wchar.h"
- export *
- }
- module wctype_h {
- header "wctype.h"
- export *
- }
- }
-
- // <complex.h> and <tgmath.h> are not C headers in any real sense, do not
- // allow their use in extern "C" contexts.
- module complex_h {
- header "complex.h"
- export ccomplex
- export *
- }
- module tgmath_h {
- header "tgmath.h"
- export ccomplex
- export cmath
- export *
- }
-
- // C compatibility headers.
- module compat {
- module cassert {
- // <cassert>'s use of NDEBUG requires textual inclusion.
- textual header "cassert"
- }
- module ccomplex {
- header "ccomplex"
- export complex
- export *
- }
- module cctype {
- header "cctype"
- export *
- }
- module cerrno {
- header "cerrno"
- export *
- }
- module cfenv {
- header "cfenv"
- export *
- }
- module cfloat {
- header "cfloat"
- export *
- }
- module cinttypes {
- header "cinttypes"
- export cstdint
- export *
- }
- module ciso646 {
- header "ciso646"
- export *
- }
- module climits {
- header "climits"
- export *
- }
- module clocale {
- header "clocale"
- export *
- }
- module cmath {
- header "cmath"
- export *
- }
- module csetjmp {
- header "csetjmp"
- export *
- }
- module csignal {
- header "csignal"
- export *
- }
- // FIXME: <cstdalign> is missing.
- module cstdarg {
- header "cstdarg"
- export *
- }
- module cstdbool {
- header "cstdbool"
- export *
- }
- module cstddef {
- header "cstddef"
- export *
- }
- module cstdint {
- header "cstdint"
- export depr.stdint_h
- export *
- }
- module cstdio {
- header "cstdio"
- export *
- }
- module cstdlib {
- header "cstdlib"
- export *
- }
- module cstring {
- header "cstring"
- export *
- }
- module ctgmath {
- header "ctgmath"
- export ccomplex
- export cmath
- export *
- }
- module ctime {
- header "ctime"
- export *
- }
- // FIXME: <cuchar> is missing.
- module cwchar {
- header "cwchar"
- export depr.stdio_h
- export *
- }
- module cwctype {
- header "cwctype"
- export *
- }
- }
-
- module algorithm {
- header "algorithm"
- export initializer_list
- export *
-
- module __algorithm {
- module adjacent_find { private header "__algorithm/adjacent_find.h" }
- module all_of { private header "__algorithm/all_of.h" }
- module any_of { private header "__algorithm/any_of.h" }
- module binary_search { private header "__algorithm/binary_search.h" }
- module clamp { private header "__algorithm/clamp.h" }
- module comp { private header "__algorithm/comp.h" }
- module comp_ref_type { private header "__algorithm/comp_ref_type.h" }
- module copy { private header "__algorithm/copy.h" }
- module copy_backward { private header "__algorithm/copy_backward.h" }
- module copy_if { private header "__algorithm/copy_if.h" }
- module copy_n { private header "__algorithm/copy_n.h" }
- module count { private header "__algorithm/count.h" }
- module count_if { private header "__algorithm/count_if.h" }
- module equal { private header "__algorithm/equal.h" }
- module equal_range { private header "__algorithm/equal_range.h" }
- module fill { private header "__algorithm/fill.h" }
- module fill_n { private header "__algorithm/fill_n.h" }
- module find { private header "__algorithm/find.h" }
- module find_end { private header "__algorithm/find_end.h" }
- module find_first_of { private header "__algorithm/find_first_of.h" }
- module find_if { private header "__algorithm/find_if.h" }
- module find_if_not { private header "__algorithm/find_if_not.h" }
- module for_each { private header "__algorithm/for_each.h" }
- module for_each_n { private header "__algorithm/for_each_n.h" }
- module generate { private header "__algorithm/generate.h" }
- module generate_n { private header "__algorithm/generate_n.h" }
- module half_positive { private header "__algorithm/half_positive.h" }
- module in_in_out_result { private header "__algorithm/in_in_out_result.h" }
- module in_in_result { private header "__algorithm/in_in_result.h" }
- module in_out_result { private header "__algorithm/in_out_result.h" }
- module includes { private header "__algorithm/includes.h" }
- module inplace_merge { private header "__algorithm/inplace_merge.h" }
- module is_heap { private header "__algorithm/is_heap.h" }
- module is_heap_until { private header "__algorithm/is_heap_until.h" }
- module is_partitioned { private header "__algorithm/is_partitioned.h" }
- module is_permutation { private header "__algorithm/is_permutation.h" }
- module is_sorted { private header "__algorithm/is_sorted.h" }
- module is_sorted_until { private header "__algorithm/is_sorted_until.h" }
- module iter_swap { private header "__algorithm/iter_swap.h" }
- module lexicographical_compare { private header "__algorithm/lexicographical_compare.h" }
- module lower_bound { private header "__algorithm/lower_bound.h" }
- module make_heap { private header "__algorithm/make_heap.h" }
- module max { private header "__algorithm/max.h" }
- module max_element { private header "__algorithm/max_element.h" }
- module merge { private header "__algorithm/merge.h" }
- module min { private header "__algorithm/min.h" }
- module min_element { private header "__algorithm/min_element.h" }
- module minmax { private header "__algorithm/minmax.h" }
- module minmax_element { private header "__algorithm/minmax_element.h" }
- module mismatch { private header "__algorithm/mismatch.h" }
- module move { private header "__algorithm/move.h" }
- module move_backward { private header "__algorithm/move_backward.h" }
- module next_permutation { private header "__algorithm/next_permutation.h" }
- module none_of { private header "__algorithm/none_of.h" }
- module nth_element { private header "__algorithm/nth_element.h" }
- module partial_sort { private header "__algorithm/partial_sort.h" }
- module partial_sort_copy { private header "__algorithm/partial_sort_copy.h" }
- module partition { private header "__algorithm/partition.h" }
- module partition_copy { private header "__algorithm/partition_copy.h" }
- module partition_point { private header "__algorithm/partition_point.h" }
- module pop_heap { private header "__algorithm/pop_heap.h" }
- module prev_permutation { private header "__algorithm/prev_permutation.h" }
- module push_heap { private header "__algorithm/push_heap.h" }
- module remove { private header "__algorithm/remove.h" }
- module remove_copy { private header "__algorithm/remove_copy.h" }
- module remove_copy_if { private header "__algorithm/remove_copy_if.h" }
- module remove_if { private header "__algorithm/remove_if.h" }
- module replace { private header "__algorithm/replace.h" }
- module replace_copy { private header "__algorithm/replace_copy.h" }
- module replace_copy_if { private header "__algorithm/replace_copy_if.h" }
- module replace_if { private header "__algorithm/replace_if.h" }
- module reverse { private header "__algorithm/reverse.h" }
- module reverse_copy { private header "__algorithm/reverse_copy.h" }
- module rotate { private header "__algorithm/rotate.h" }
- module rotate_copy { private header "__algorithm/rotate_copy.h" }
- module sample { private header "__algorithm/sample.h" }
- module search { private header "__algorithm/search.h" }
- module search_n { private header "__algorithm/search_n.h" }
- module set_difference { private header "__algorithm/set_difference.h" }
- module set_intersection { private header "__algorithm/set_intersection.h" }
- module set_symmetric_difference { private header "__algorithm/set_symmetric_difference.h" }
- module set_union { private header "__algorithm/set_union.h" }
- module shift_left { private header "__algorithm/shift_left.h" }
- module shift_right { private header "__algorithm/shift_right.h" }
- module shuffle { private header "__algorithm/shuffle.h" }
- module sift_down { private header "__algorithm/sift_down.h" }
- module sort { private header "__algorithm/sort.h" }
- module sort_heap { private header "__algorithm/sort_heap.h" }
- module stable_partition { private header "__algorithm/stable_partition.h" }
- module stable_sort { private header "__algorithm/stable_sort.h" }
- module swap_ranges { private header "__algorithm/swap_ranges.h" }
- module transform { private header "__algorithm/transform.h" }
- module unique { private header "__algorithm/unique.h" }
- module unique_copy { private header "__algorithm/unique_copy.h" }
- module unwrap_iter { private header "__algorithm/unwrap_iter.h" }
- module upper_bound { private header "__algorithm/upper_bound.h" }
- }
- }
- module any {
- header "any"
- export *
- }
- module array {
- header "array"
- export initializer_list
- export *
- }
- module atomic {
- header "atomic"
- export *
- }
- module barrier {
- requires cplusplus14
- header "barrier"
- export *
- }
- module bit {
- header "bit"
- export *
-
- module __bit {
- module bit_cast { private header "__bit/bit_cast.h" }
- module byteswap { private header "__bit/byteswap.h" }
- }
- }
- module bitset {
- header "bitset"
- export string
- export iosfwd
- export *
- }
- // No submodule for cassert. It fundamentally needs repeated, textual inclusion.
- module charconv {
- header "charconv"
- export *
-
- module __charconv {
- module chars_format { private header "__charconv/chars_format.h" }
- module from_chars_result { private header "__charconv/from_chars_result.h" }
- module to_chars_result { private header "__charconv/to_chars_result.h" }
- }
-
- }
- module chrono {
- header "chrono"
- export *
-
- module __chrono {
- module calendar { private header "__chrono/calendar.h" }
- module convert_to_timespec { private header "__chrono/convert_to_timespec.h" }
- module duration { private header "__chrono/duration.h" }
- module file_clock { private header "__chrono/file_clock.h" }
- module high_resolution_clock { private header "__chrono/high_resolution_clock.h" }
- module steady_clock { private header "__chrono/steady_clock.h" }
- module system_clock { private header "__chrono/system_clock.h" }
- module time_point { private header "__chrono/time_point.h" }
- }
- }
- module codecvt {
- header "codecvt"
- export *
- }
- module compare {
- header "compare"
- export *
-
- module __compare {
- module common_comparison_category { private header "__compare/common_comparison_category.h" }
- module compare_partial_order_fallback { private header "__compare/compare_partial_order_fallback.h" }
- module compare_strong_order_fallback { private header "__compare/compare_strong_order_fallback.h" }
- module compare_three_way { private header "__compare/compare_three_way.h" }
- module compare_three_way_result { private header "__compare/compare_three_way_result.h" }
- module compare_weak_order_fallback { private header "__compare/compare_weak_order_fallback.h" }
- module is_eq { private header "__compare/is_eq.h" }
- module ordering { private header "__compare/ordering.h" }
- module partial_order { private header "__compare/partial_order.h" }
- module strong_order { private header "__compare/strong_order.h" }
- module synth_three_way { private header "__compare/synth_three_way.h" }
- module three_way_comparable { private header "__compare/three_way_comparable.h" }
- module weak_order { private header "__compare/weak_order.h" }
- }
- }
- module complex {
- header "complex"
- export *
- }
- module concepts {
- header "concepts"
- export *
-
- module __concepts {
- module arithmetic { private header "__concepts/arithmetic.h" }
- module assignable { private header "__concepts/assignable.h" }
- module boolean_testable { private header "__concepts/boolean_testable.h" }
- module class_or_enum { private header "__concepts/class_or_enum.h" }
- module common_reference_with { private header "__concepts/common_reference_with.h" }
- module common_with { private header "__concepts/common_with.h" }
- module constructible { private header "__concepts/constructible.h" }
- module convertible_to { private header "__concepts/convertible_to.h" }
- module copyable { private header "__concepts/copyable.h" }
- module derived_from { private header "__concepts/derived_from.h" }
- module destructible { private header "__concepts/destructible.h" }
- module different_from { private header "__concepts/different_from.h" }
- module equality_comparable { private header "__concepts/equality_comparable.h" }
- module invocable { private header "__concepts/invocable.h" }
- module movable { private header "__concepts/movable.h" }
- module predicate { private header "__concepts/predicate.h" }
- module regular { private header "__concepts/regular.h" }
- module relation { private header "__concepts/relation.h" }
- module same_as { private header "__concepts/same_as.h" }
- module semiregular { private header "__concepts/semiregular.h" }
- module swappable { private header "__concepts/swappable.h" }
- module totally_ordered { private header "__concepts/totally_ordered.h" }
- }
- }
- module condition_variable {
- header "condition_variable"
- export *
- }
- module coroutine {
- requires coroutines
- header "coroutine"
- export compare
- export *
-
- module __coroutine {
- module coroutine_handle { private header "__coroutine/coroutine_handle.h" }
- module coroutine_traits { private header "__coroutine/coroutine_traits.h" }
- module noop_coroutine_handle { private header "__coroutine/noop_coroutine_handle.h" }
- module trivial_awaitables { private header "__coroutine/trivial_awaitables.h" }
- }
- }
- module deque {
- header "deque"
- export initializer_list
- export *
- }
- module exception {
- header "exception"
- export *
- }
- module execution {
- header "execution"
- export *
- }
- module filesystem {
- header "filesystem"
- export *
-
- module __filesystem {
- module copy_options { private header "__filesystem/copy_options.h" }
- module directory_entry { private header "__filesystem/directory_entry.h" }
- module directory_iterator { private header "__filesystem/directory_iterator.h" }
- module directory_options { private header "__filesystem/directory_options.h" }
- module file_status { private header "__filesystem/file_status.h" }
- module file_time_type { private header "__filesystem/file_time_type.h" }
- module file_type { private header "__filesystem/file_type.h" }
- module filesystem_error { private header "__filesystem/filesystem_error.h" }
- module operations { private header "__filesystem/operations.h" }
- module path { private header "__filesystem/path.h" }
- module path_iterator { private header "__filesystem/path_iterator.h" }
- module perm_options { private header "__filesystem/perm_options.h" }
- module perms { private header "__filesystem/perms.h" }
- module recursive_directory_iterator { private header "__filesystem/recursive_directory_iterator.h" }
- module space_info { private header "__filesystem/space_info.h" }
- module u8path { private header "__filesystem/u8path.h" }
- }
- }
- module format {
- header "format"
- export *
-
- module __format {
- module format_arg { private header "__format/format_arg.h" }
- module format_args { private header "__format/format_args.h" }
- module format_context {
- private header "__format/format_context.h"
- export optional
- export locale
- }
- module format_error { private header "__format/format_error.h" }
- module format_fwd { private header "__format/format_fwd.h" }
- module format_parse_context { private header "__format/format_parse_context.h" }
- module format_string { private header "__format/format_string.h" }
- module format_to_n_result { private header "__format/format_to_n_result.h" }
- module formatter { private header "__format/formatter.h" }
- module formatter_bool { private header "__format/formatter_bool.h" }
- module formatter_char { private header "__format/formatter_char.h" }
- module formatter_floating_point { private header "__format/formatter_floating_point.h" }
- module formatter_integer { private header "__format/formatter_integer.h" }
- module formatter_integral { private header "__format/formatter_integral.h" }
- module formatter_pointer { private header "__format/formatter_pointer.h" }
- module formatter_string { private header "__format/formatter_string.h" }
- module parser_std_format_spec { private header "__format/parser_std_format_spec.h" }
- }
- }
- module forward_list {
- header "forward_list"
- export initializer_list
- export *
- }
- module fstream {
- header "fstream"
- export *
- }
- module functional {
- header "functional"
- export *
-
- module __functional {
- module binary_function { private header "__functional/binary_function.h" }
- module binary_negate { private header "__functional/binary_negate.h" }
- module bind { private header "__functional/bind.h" }
- module bind_back { private header "__functional/bind_back.h" }
- module bind_front { private header "__functional/bind_front.h" }
- module binder1st { private header "__functional/binder1st.h" }
- module binder2nd { private header "__functional/binder2nd.h" }
- module compose { private header "__functional/compose.h" }
- module default_searcher { private header "__functional/default_searcher.h" }
- module function { private header "__functional/function.h" }
- module hash { private header "__functional/hash.h" }
- module identity { private header "__functional/identity.h" }
- module invoke { private header "__functional/invoke.h" }
- module is_transparent { private header "__functional/is_transparent.h" }
- module mem_fn { private header "__functional/mem_fn.h" }
- module mem_fun_ref { private header "__functional/mem_fun_ref.h" }
- module not_fn { private header "__functional/not_fn.h" }
- module operations { private header "__functional/operations.h" }
- module perfect_forward { private header "__functional/perfect_forward.h" }
- module pointer_to_binary_function { private header "__functional/pointer_to_binary_function.h" }
- module pointer_to_unary_function { private header "__functional/pointer_to_unary_function.h" }
- module ranges_operations { private header "__functional/ranges_operations.h" }
- module reference_wrapper { private header "__functional/reference_wrapper.h" }
- module unary_function { private header "__functional/unary_function.h" }
- module unary_negate { private header "__functional/unary_negate.h" }
- module unwrap_ref { private header "__functional/unwrap_ref.h" }
- module weak_result_type { private header "__functional/weak_result_type.h" }
- }
- }
- module future {
- header "future"
- export *
- }
- module initializer_list {
- header "initializer_list"
- export *
- }
- module iomanip {
- header "iomanip"
- export *
- }
- module ios {
- header "ios"
- export iosfwd
- export *
- }
- module iosfwd {
- header "iosfwd"
- export *
- }
- module iostream {
- header "iostream"
- export ios
- export streambuf
- export istream
- export ostream
- export *
- }
- module istream {
- header "istream"
- // FIXME: should re-export ios, streambuf?
- export *
- }
- module iterator {
- header "iterator"
- export *
-
- module __iterator {
- module access { private header "__iterator/access.h" }
- module advance { private header "__iterator/advance.h" }
- module back_insert_iterator { private header "__iterator/back_insert_iterator.h" }
- module common_iterator { private header "__iterator/common_iterator.h" }
- module concepts { private header "__iterator/concepts.h" }
- module counted_iterator { private header "__iterator/counted_iterator.h" }
- module data { private header "__iterator/data.h" }
- module default_sentinel { private header "__iterator/default_sentinel.h" }
- module distance { private header "__iterator/distance.h" }
- module empty { private header "__iterator/empty.h" }
- module erase_if_container { private header "__iterator/erase_if_container.h" }
- module front_insert_iterator { private header "__iterator/front_insert_iterator.h" }
- module incrementable_traits { private header "__iterator/incrementable_traits.h" }
- module indirectly_comparable { private header "__iterator/indirectly_comparable.h" }
- module insert_iterator { private header "__iterator/insert_iterator.h" }
- module istream_iterator { private header "__iterator/istream_iterator.h" }
- module istreambuf_iterator { private header "__iterator/istreambuf_iterator.h" }
- module iter_move { private header "__iterator/iter_move.h" }
- module iter_swap { private header "__iterator/iter_swap.h" }
- module iterator { private header "__iterator/iterator.h" }
- module iterator_traits { private header "__iterator/iterator_traits.h" }
- module move_iterator { private header "__iterator/move_iterator.h" }
- module next { private header "__iterator/next.h" }
- module ostream_iterator { private header "__iterator/ostream_iterator.h" }
- module ostreambuf_iterator { private header "__iterator/ostreambuf_iterator.h" }
- module prev { private header "__iterator/prev.h" }
- module projected { private header "__iterator/projected.h" }
- module readable_traits { private header "__iterator/readable_traits.h" }
- module reverse_access { private header "__iterator/reverse_access.h" }
- module reverse_iterator { private header "__iterator/reverse_iterator.h" }
- module size { private header "__iterator/size.h" }
- module unreachable_sentinel { private header "__iterator/unreachable_sentinel.h" }
- module wrap_iter { private header "__iterator/wrap_iter.h" }
- }
- }
- module latch {
- requires cplusplus14
- header "latch"
- export *
- }
- module limits {
- header "limits"
- export *
- }
- module list {
- header "list"
- export initializer_list
- export *
- }
- module locale {
- header "locale"
- export *
- }
- module map {
- header "map"
- export initializer_list
- export *
- }
- module memory {
- header "memory"
- export *
-
- module __memory {
- module addressof { private header "__memory/addressof.h" }
- module allocation_guard { private header "__memory/allocation_guard.h" }
- module allocator { private header "__memory/allocator.h" }
- module allocator_arg_t { private header "__memory/allocator_arg_t.h" }
- module allocator_traits { private header "__memory/allocator_traits.h" }
- module auto_ptr { private header "__memory/auto_ptr.h" }
- module compressed_pair { private header "__memory/compressed_pair.h" }
- module concepts { private header "__memory/concepts.h" }
- module construct_at { private header "__memory/construct_at.h" }
- module pointer_traits { private header "__memory/pointer_traits.h" }
- module ranges_construct_at { private header "__memory/ranges_construct_at.h" }
- module ranges_uninitialized_algorithms { private header "__memory/ranges_uninitialized_algorithms.h" }
- module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" }
- module shared_ptr { private header "__memory/shared_ptr.h" }
- module temporary_buffer { private header "__memory/temporary_buffer.h" }
- module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" }
- module unique_ptr { private header "__memory/unique_ptr.h" }
- module uses_allocator { private header "__memory/uses_allocator.h" }
- module voidify { private header "__memory/voidify.h" }
- }
- }
- module mutex {
- header "mutex"
- export *
- }
- module new {
- header "new"
- export *
- }
- module numbers {
- header "numbers"
- export *
- }
- module numeric {
- header "numeric"
- export *
-
- module __numeric {
- module accumulate { private header "__numeric/accumulate.h" }
- module adjacent_difference { private header "__numeric/adjacent_difference.h" }
- module exclusive_scan { private header "__numeric/exclusive_scan.h" }
- module gcd_lcm { private header "__numeric/gcd_lcm.h" }
- module inclusive_scan { private header "__numeric/inclusive_scan.h" }
- module inner_product { private header "__numeric/inner_product.h" }
- module iota { private header "__numeric/iota.h" }
- module midpoint { private header "__numeric/midpoint.h" }
- module partial_sum { private header "__numeric/partial_sum.h" }
- module reduce { private header "__numeric/reduce.h" }
- module transform_exclusive_scan { private header "__numeric/transform_exclusive_scan.h" }
- module transform_inclusive_scan { private header "__numeric/transform_inclusive_scan.h" }
- module transform_reduce { private header "__numeric/transform_reduce.h" }
- }
- }
- module optional {
- header "optional"
- export *
- }
- module ostream {
- header "ostream"
- // FIXME: should re-export ios, streambuf?
- export *
- }
- module queue {
- header "queue"
- export initializer_list
- export *
- }
- module random {
- header "random"
- export initializer_list
- export *
-
- module __random {
- module bernoulli_distribution { private header "__random/bernoulli_distribution.h" }
- module binomial_distribution { private header "__random/binomial_distribution.h" }
- module cauchy_distribution { private header "__random/cauchy_distribution.h" }
- module chi_squared_distribution { private header "__random/chi_squared_distribution.h" }
- module clamp_to_integral { private header "__random/clamp_to_integral.h" }
- module default_random_engine { private header "__random/default_random_engine.h" }
- module discard_block_engine { private header "__random/discard_block_engine.h" }
- module discrete_distribution { private header "__random/discrete_distribution.h" }
- module exponential_distribution { private header "__random/exponential_distribution.h" }
- module extreme_value_distribution { private header "__random/extreme_value_distribution.h" }
- module fisher_f_distribution { private header "__random/fisher_f_distribution.h" }
- module gamma_distribution { private header "__random/gamma_distribution.h" }
- module generate_canonical { private header "__random/generate_canonical.h" }
- module geometric_distribution { private header "__random/geometric_distribution.h" }
- module independent_bits_engine { private header "__random/independent_bits_engine.h" }
- module is_seed_sequence { private header "__random/is_seed_sequence.h" }
- module knuth_b { private header "__random/knuth_b.h" }
- module linear_congruential_engine { private header "__random/linear_congruential_engine.h" }
- module log2 { private header "__random/log2.h" }
- module lognormal_distribution { private header "__random/lognormal_distribution.h" }
- module mersenne_twister_engine { private header "__random/mersenne_twister_engine.h" }
- module negative_binomial_distribution { private header "__random/negative_binomial_distribution.h" }
- module normal_distribution { private header "__random/normal_distribution.h" }
- module piecewise_constant_distribution { private header "__random/piecewise_constant_distribution.h" }
- module piecewise_linear_distribution { private header "__random/piecewise_linear_distribution.h" }
- module poisson_distribution { private header "__random/poisson_distribution.h" }
- module random_device { private header "__random/random_device.h" }
- module ranlux { private header "__random/ranlux.h" }
- module seed_seq { private header "__random/seed_seq.h" }
- module shuffle_order_engine { private header "__random/shuffle_order_engine.h" }
- module student_t_distribution { private header "__random/student_t_distribution.h" }
- module subtract_with_carry_engine { private header "__random/subtract_with_carry_engine.h" }
- module uniform_int_distribution { private header "__random/uniform_int_distribution.h" }
- module uniform_random_bit_generator { private header "__random/uniform_random_bit_generator.h" }
- module uniform_real_distribution { private header "__random/uniform_real_distribution.h" }
- module weibull_distribution { private header "__random/weibull_distribution.h" }
- }
- }
- module ranges {
- header "ranges"
- export compare
- export initializer_list
- export iterator
- export *
-
- module __ranges {
- module access { private header "__ranges/access.h" }
- module all {
- private header "__ranges/all.h"
- export functional.__functional.compose
- export functional.__functional.perfect_forward
- }
- module common_view { private header "__ranges/common_view.h" }
- module concepts { private header "__ranges/concepts.h" }
- module copyable_box { private header "__ranges/copyable_box.h" }
- module counted {
- private header "__ranges/counted.h"
- export span
- }
- module dangling { private header "__ranges/dangling.h" }
- module data { private header "__ranges/data.h" }
- module drop_view { private header "__ranges/drop_view.h" }
- module empty { private header "__ranges/empty.h" }
- module empty_view { private header "__ranges/empty_view.h" }
- module enable_borrowed_range { private header "__ranges/enable_borrowed_range.h" }
- module enable_view { private header "__ranges/enable_view.h" }
- module iota_view { private header "__ranges/iota_view.h" }
- module join_view { private header "__ranges/join_view.h" }
- module non_propagating_cache { private header "__ranges/non_propagating_cache.h" }
- module owning_view { private header "__ranges/owning_view.h" }
- module range_adaptor { private header "__ranges/range_adaptor.h" }
- module ref_view { private header "__ranges/ref_view.h" }
- module reverse_view { private header "__ranges/reverse_view.h" }
- module single_view { private header "__ranges/single_view.h" }
- module size { private header "__ranges/size.h" }
- module subrange { private header "__ranges/subrange.h" }
- module take_view { private header "__ranges/take_view.h" }
- module transform_view {
- private header "__ranges/transform_view.h"
- export functional.__functional.bind_back
- export functional.__functional.perfect_forward
- }
- module view_interface { private header "__ranges/view_interface.h" }
- module views { private header "__ranges/views.h" }
- }
- }
- module ratio {
- header "ratio"
- export *
- }
- module regex {
- header "regex"
- export initializer_list
- export *
- }
- module scoped_allocator {
- header "scoped_allocator"
- export *
- }
- module semaphore {
- requires cplusplus14
- header "semaphore"
- export *
- }
- module set {
- header "set"
- export initializer_list
- export *
- }
- module shared_mutex {
- header "shared_mutex"
- export version
- }
- module span {
- header "span"
- export ranges.__ranges.enable_borrowed_range
- export version
- }
- module sstream {
- header "sstream"
- // FIXME: should re-export istream, ostream, ios, streambuf, string?
- export *
- }
- module stack {
- header "stack"
- export initializer_list
- export *
- }
- module stdexcept {
- header "stdexcept"
- export *
- }
- module streambuf {
- header "streambuf"
- export *
- }
- module string {
- header "string"
- export initializer_list
- export string_view
- export __string
- export *
- }
- module string_view {
- header "string_view"
- export initializer_list
- export __string
- export *
- }
- module strstream {
- header "strstream"
- export *
- }
- module system_error {
- header "system_error"
- export *
- }
- module thread {
- header "thread"
- export *
-
- module __thread {
- module poll_with_backoff { private header "__thread/poll_with_backoff.h" }
- module timed_backoff_policy { private header "__thread/timed_backoff_policy.h" }
- }
- }
- module tuple {
- header "tuple"
- export *
- }
- module type_traits {
- header "type_traits"
- export functional.__functional.unwrap_ref
- export *
- }
- module typeindex {
- header "typeindex"
- export *
- }
- module typeinfo {
- header "typeinfo"
- export *
- }
- module unordered_map {
- header "unordered_map"
- export initializer_list
- export *
- }
- module unordered_set {
- header "unordered_set"
- export initializer_list
- export *
- }
- module utility {
- header "utility"
- export initializer_list
- export *
-
- module __utility {
- module as_const { private header "__utility/as_const.h" }
- module auto_cast { private header "__utility/auto_cast.h" }
- module cmp { private header "__utility/cmp.h" }
- module declval { private header "__utility/declval.h" }
- module exchange { private header "__utility/exchange.h" }
- module forward { private header "__utility/forward.h" }
- module in_place { private header "__utility/in_place.h" }
- module integer_sequence { private header "__utility/integer_sequence.h" }
- module move { private header "__utility/move.h" }
- module pair { private header "__utility/pair.h" }
- module piecewise_construct { private header "__utility/piecewise_construct.h" }
- module priority_tag { private header "__utility/priority_tag.h" }
- module rel_ops { private header "__utility/rel_ops.h" }
- module swap { private header "__utility/swap.h" }
- module to_underlying { private header "__utility/to_underlying.h" }
- module transaction { private header "__utility/transaction.h" }
- }
- }
- module valarray {
- header "valarray"
- export initializer_list
- export *
- }
- module variant {
- header "variant"
- export *
-
- module __variant {
- module monostate { private header "__variant/monostate.h" }
- }
- }
- module vector {
- header "vector"
- export initializer_list
- export *
- }
- module version {
- header "version"
- export *
- }
-
- // __config not modularised due to a bug in Clang
- // FIXME: These should be private.
- module __availability { private header "__availability" export * }
- module __bit_reference { private header "__bit_reference" export * }
- module __bits { private header "__bits" export * }
- module __debug { header "__debug" export * }
- module __errc { private header "__errc" export * }
- module __hash_table { header "__hash_table" export * }
- module __locale { private header "__locale" export * }
- module __mbstate_t { private header "__mbstate_t.h" export * }
- module __mutex_base { private header "__mutex_base" export * }
- module __node_handle { private header "__node_handle" export * }
- module __nullptr { header "__nullptr" export * }
- module __split_buffer { private header "__split_buffer" export * }
- module __std_stream { private header "__std_stream" export * }
- module __string { private header "__string" export * }
- module __threading_support { header "__threading_support" export * }
- module __tree { header "__tree" export * }
- module __tuple { private header "__tuple" export * }
- module __undef_macros { header "__undef_macros" export * }
-
- module experimental {
- requires cplusplus11
-
- module algorithm {
- header "experimental/algorithm"
- export *
- }
- module coroutine {
- requires coroutines
- header "experimental/coroutine"
- export *
- }
- module deque {
- header "experimental/deque"
- export *
- }
- module filesystem {
- header "experimental/filesystem"
- export *
- }
- module forward_list {
- header "experimental/forward_list"
- export *
- }
- module functional {
- header "experimental/functional"
- export *
- }
- module iterator {
- header "experimental/iterator"
- export *
- }
- module list {
- header "experimental/list"
- export *
- }
- module map {
- header "experimental/map"
- export *
- }
- module memory_resource {
- header "experimental/memory_resource"
- export *
- }
- module propagate_const {
- header "experimental/propagate_const"
- export *
- }
- module regex {
- header "experimental/regex"
- export *
- }
- module simd {
- header "experimental/simd"
- export *
- }
- module set {
- header "experimental/set"
- export *
- }
- module span {
- header "span"
- export *
- }
- module string {
- header "experimental/string"
- export *
- }
- module type_traits {
- header "experimental/type_traits"
- export *
- }
- module unordered_map {
- header "experimental/unordered_map"
- export *
- }
- module unordered_set {
- header "experimental/unordered_set"
- export *
- }
- module utility {
- header "experimental/utility"
- export *
- }
- module vector {
- header "experimental/vector"
- export *
- }
- // FIXME these should be private
- module __memory {
- header "experimental/__memory"
- export *
- }
- } // end experimental
-}
lib/libcxx/include/mutex
@@ -186,20 +186,24 @@ template<class Callable, class ...Args>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__mutex_base>
#include <__threading_support>
#include <__utility/forward.h>
#include <cstdint>
-#include <functional>
#include <memory>
#ifndef _LIBCPP_CXX03_LANG
# include <tuple>
#endif
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <functional>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/new
@@ -86,6 +86,7 @@ void operator delete[](void* ptr, void*) noexcept;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <cstddef>
@@ -99,7 +100,7 @@ void operator delete[](void* ptr, void*) noexcept;
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L
@@ -359,6 +360,17 @@ constexpr _Tp* launder(_Tp* __p) noexcept
}
#endif
+#if _LIBCPP_STD_VER > 14
+
+#if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
+
+inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE;
+inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE;
+
+#endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
+
+#endif // _LIBCPP_STD_VER > 14
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_NEW
lib/libcxx/include/numbers
@@ -58,15 +58,16 @@ namespace std::numbers {
}
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <concepts>
#include <type_traits>
#include <version>
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -128,6 +129,6 @@ inline constexpr double phi = phi_v<double>;
_LIBCPP_END_NAMESPACE_STD
-#endif //!defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP_NUMBERS
lib/libcxx/include/numeric
@@ -144,10 +144,9 @@ template<class T>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cmath> // for isnormal
-#include <functional>
-#include <iterator>
#include <version>
#include <__numeric/accumulate.h>
@@ -164,8 +163,13 @@ template<class T>
#include <__numeric/transform_inclusive_scan.h>
#include <__numeric/transform_reduce.h>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <functional>
+# include <iterator>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
lib/libcxx/include/optional
@@ -93,11 +93,11 @@ namespace std {
template <class U, class... Args>
constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);
template <class U = T>
- constexpr EXPLICIT optional(U &&);
+ constexpr explicit(see-below) optional(U &&);
template <class U>
- EXPLICIT optional(const optional<U> &); // constexpr in C++20
+ explicit(see-below) optional(const optional<U> &); // constexpr in C++20
template <class U>
- EXPLICIT optional(optional<U> &&); // constexpr in C++20
+ explicit(see-below) optional(optional<U> &&); // constexpr in C++20
// 23.6.3.2, destructor
~optional(); // constexpr in C++20
@@ -158,22 +158,45 @@ template<class T>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__concepts/invocable.h>
#include <__config>
-#include <__debug>
-#include <__functional_base>
-#include <compare>
-#include <functional>
+#include <__functional/hash.h>
+#include <__functional/invoke.h>
+#include <__functional/unary_function.h>
+#include <__memory/construct_at.h>
+#include <__tuple>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <initializer_list>
#include <new>
#include <stdexcept>
#include <type_traits>
-#include <utility>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <atomic>
+# include <chrono>
+# include <climits>
+# include <concepts>
+# include <ctime>
+# include <iterator>
+# include <memory>
+# include <ratio>
+# include <tuple>
+# include <typeinfo>
+# include <utility>
+# include <variant>
+#endif
+
+// standard-mandated includes
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
namespace std // purposefully not using versioning namespace
@@ -382,9 +405,9 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
}
};
-// optional<T&> is currently required ill-formed, however it may to be in the
-// future. For this reason it has already been implemented to ensure we can
-// make the change in an ABI compatible manner.
+// optional<T&> is currently required to be ill-formed. However, it may
+// be allowed in the future. For this reason, it has already been implemented
+// to ensure we can make the change in an ABI-compatible manner.
template <class _Tp>
struct __optional_storage_base<_Tp, true>
{
@@ -1039,7 +1062,7 @@ public:
#if _LIBCPP_STD_VER > 20
template<class _Func>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr auto and_then(_Func&& __f) & {
using _Up = invoke_result_t<_Func, value_type&>;
static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
@@ -1050,7 +1073,7 @@ public:
}
template<class _Func>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr auto and_then(_Func&& __f) const& {
using _Up = invoke_result_t<_Func, const value_type&>;
static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
@@ -1061,7 +1084,7 @@ public:
}
template<class _Func>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr auto and_then(_Func&& __f) && {
using _Up = invoke_result_t<_Func, value_type&&>;
static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
@@ -1083,7 +1106,7 @@ public:
}
template<class _Func>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr auto transform(_Func&& __f) & {
using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>;
static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
@@ -1098,7 +1121,7 @@ public:
}
template<class _Func>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr auto transform(_Func&& __f) const& {
using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>;
static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
@@ -1113,7 +1136,7 @@ public:
}
template<class _Func>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr auto transform(_Func&& __f) && {
using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>;
static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
@@ -1128,7 +1151,7 @@ public:
}
template<class _Func>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr auto transform(_Func&& __f) const&& {
using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>;
static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
lib/libcxx/include/ostream
@@ -130,20 +130,53 @@ template <class charT, class traits>
template <class Stream, class T>
Stream&& operator<<(Stream&& os, const T& x);
+template<class traits>
+basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete; // since C++20
+template<class traits>
+basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete; // since C++20
+template<class traits>
+basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete; // since C++20
+template<class traits>
+basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete; // since C++20
+template<class traits>
+basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete; // since C++20
+template<class traits>
+basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete; // since C++20
+template<class traits>
+basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete; // since C++20
+template<class traits>
+basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete; // since C++20
+template<class traits>
+basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char8_t*) = delete; // since C++20
+template<class traits>
+basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char16_t*) = delete; // since C++20
+template<class traits>
+basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char32_t*) = delete; // since C++20
+template<class traits>
+basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete; // since C++20
+template<class traits>
+basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; // since C++20
+template<class traits>
+basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete; // since C++20
+
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <bitset>
#include <ios>
-#include <iterator>
#include <locale>
#include <streambuf>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iterator>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -221,9 +254,13 @@ public:
basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
+#if _LIBCPP_STD_VER > 14
+// LWG 2221 - nullptr. This is not backported to older standards modes.
+// See https://reviews.llvm.org/D127033 for more info on the rationale.
_LIBCPP_INLINE_VISIBILITY
basic_ostream& operator<<(nullptr_t)
{ return *this << "nullptr"; }
+#endif
// 27.7.2.7 Unformatted output:
basic_ostream& put(char_type __c);
@@ -1094,9 +1131,60 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
}
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)
+#if _LIBCPP_STD_VER > 17
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
+
+template <class _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete;
+
+template <class _Traits>
+basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete;
+
+template <class _Traits>
+basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete;
+
+template <class _Traits>
+basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete;
+
+template <class _Traits>
+basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
+
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template <class _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
+
+template <class _Traits>
+basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete;
+
+template <class _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete;
+
+template <class _Traits>
+basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
+#endif
+
+template <class _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
+
+template <class _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete;
+
+template <class _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete;
+
+template <class _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
+
+#endif // _LIBCPP_STD_VER > 17
+
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
#endif
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/queue
@@ -217,20 +217,30 @@ template <class T, class Container, class Compare>
*/
+#include <__algorithm/make_heap.h>
+#include <__algorithm/pop_heap.h>
+#include <__algorithm/push_heap.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__functional/operations.h>
#include <__iterator/iterator_traits.h>
#include <__memory/uses_allocator.h>
#include <__utility/forward.h>
-#include <algorithm>
-#include <compare>
#include <deque>
-#include <functional>
#include <type_traits>
#include <vector>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <functional>
+#endif
+
+// standard-mandated includes
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/random
@@ -1677,6 +1677,7 @@ class piecewise_linear_distribution
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__random/bernoulli_distribution.h>
#include <__random/binomial_distribution.h>
@@ -1694,6 +1695,7 @@ class piecewise_linear_distribution
#include <__random/geometric_distribution.h>
#include <__random/independent_bits_engine.h>
#include <__random/is_seed_sequence.h>
+#include <__random/is_valid.h>
#include <__random/knuth_b.h>
#include <__random/linear_congruential_engine.h>
#include <__random/log2.h>
@@ -1714,10 +1716,15 @@ class piecewise_linear_distribution
#include <__random/uniform_random_bit_generator.h>
#include <__random/uniform_real_distribution.h>
#include <__random/weibull_distribution.h>
-#include <initializer_list>
#include <version>
-#include <algorithm> // for backward compatibility; TODO remove it
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+#endif
+
+// standard-mandated includes
+#include <initializer_list>
+
#include <cmath> // for backward compatibility; TODO remove it
#include <cstddef> // for backward compatibility; TODO remove it
#include <cstdint> // for backward compatibility; TODO remove it
@@ -1729,7 +1736,7 @@ class piecewise_linear_distribution
#include <vector> // for backward compatibility; TODO remove it
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_RANDOM
lib/libcxx/include/ranges
@@ -120,6 +120,14 @@ namespace std::ranges {
requires is_object_v<T>
class empty_view;
+ template<class T>
+ inline constexpr bool enable_borrowed_range<empty_view<T>> = true;
+
+ namespace views {
+ template<class T>
+ inline constexpr empty_view<T> empty{};
+ }
+
// [range.all], all view
namespace views {
inline constexpr unspecified all = unspecified;
@@ -142,6 +150,15 @@ namespace std::ranges {
template<class T>
inline constexpr bool enable_borrowed_range<owning_view<T>> = enable_borrowed_range<T>;
+ // [range.filter], filter view
+ template<input_range V, indirect_unary_predicate<iterator_t<V>> Pred>
+ requires view<V> && is_object_v<Pred>
+ class filter_view;
+
+ namespace views {
+ inline constexpr unspecified filter = unspecified;
+ }
+
// [range.drop], drop view
template<view V>
class drop_view;
@@ -196,10 +213,66 @@ namespace std::ranges {
template<input_range V>
requires view<V> && input_range<range_reference_t<V>>
class join_view;
+
+ // [range.lazy.split], lazy split view
+ template<class R>
+ concept tiny-range = see below; // exposition only
+
+ template<input_range V, forward_range Pattern>
+ requires view<V> && view<Pattern> &&
+ indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> &&
+ (forward_range<V> || tiny-range<Pattern>)
+ class lazy_split_view;
+
+ namespace views {
+ inline constexpr unspecified lazy_split = unspecified;
+ }
+
+ // [range.zip], zip view
+ template<input_range... Views>
+ requires (view<Views> && ...) && (sizeof...(Views) > 0)
+ class zip_view; // C++2b
+
+ template<class... Views>
+ inline constexpr bool enable_borrowed_range<zip_view<Views...>> = // C++2b
+ (enable_borrowed_range<Views> && ...);
+
+ namespace views { inline constexpr unspecified zip = unspecified; } // C++2b
}
+namespace std {
+ namespace views = ranges::views;
+
+ template<class T> struct tuple_size;
+ template<size_t I, class T> struct tuple_element;
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_size<ranges::subrange<I, S, K>>
+ : integral_constant<size_t, 2> {};
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_element<0, ranges::subrange<I, S, K>> {
+ using type = I;
+ };
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_element<1, ranges::subrange<I, S, K>> {
+ using type = S;
+ };
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_element<0, const ranges::subrange<I, S, K>> {
+ using type = I;
+ };
+
+ template<class I, class S, ranges::subrange_kind K>
+ struct tuple_element<1, const ranges::subrange<I, S, K>> {
+ using type = S;
+ };
+}
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__ranges/access.h>
#include <__ranges/all.h>
@@ -213,9 +286,13 @@ namespace std::ranges {
#include <__ranges/empty_view.h>
#include <__ranges/enable_borrowed_range.h>
#include <__ranges/enable_view.h>
+#include <__ranges/filter_view.h>
#include <__ranges/iota_view.h>
#include <__ranges/join_view.h>
+#include <__ranges/lazy_split_view.h>
+#include <__ranges/rbegin.h>
#include <__ranges/ref_view.h>
+#include <__ranges/rend.h>
#include <__ranges/reverse_view.h>
#include <__ranges/single_view.h>
#include <__ranges/size.h>
@@ -224,6 +301,8 @@ namespace std::ranges {
#include <__ranges/transform_view.h>
#include <__ranges/view_interface.h>
#include <__ranges/views.h>
+#include <__ranges/zip_view.h>
+#include <__tuple> // TODO: <ranges> has to export std::tuple_size. Replace this, once <tuple> is granularized.
#include <compare> // Required by the standard.
#include <initializer_list> // Required by the standard.
#include <iterator> // Required by the standard.
@@ -231,7 +310,7 @@ namespace std::ranges {
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_RANGES
lib/libcxx/include/ratio
@@ -77,6 +77,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported
}
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <climits>
#include <cstdint>
@@ -84,7 +85,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -416,11 +417,11 @@ struct _LIBCPP_TEMPLATE_VIS ratio_subtract
template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_equal
- : public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {};
+ : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {};
template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_not_equal
- : public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {};
+ : _BoolConstant<!ratio_equal<_R1, _R2>::value> {};
// ratio_less
@@ -479,19 +480,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL>
template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_less
- : public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {};
+ : _BoolConstant<__ratio_less<_R1, _R2>::value> {};
template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_less_equal
- : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {};
+ : _BoolConstant<!ratio_less<_R2, _R1>::value> {};
template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_greater
- : public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {};
+ : _BoolConstant<ratio_less<_R2, _R1>::value> {};
template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal
- : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {};
+ : _BoolConstant<!ratio_less<_R1, _R2>::value> {};
template <class _R1, class _R2>
struct __ratio_gcd
lib/libcxx/include/regex
@@ -762,23 +762,42 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
} // std
*/
+#include <__algorithm/find.h>
+#include <__algorithm/search.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__debug>
+#include <__iterator/back_insert_iterator.h>
#include <__iterator/wrap_iter.h>
#include <__locale>
-#include <compare>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <deque>
-#include <initializer_list>
-#include <iterator>
#include <memory>
#include <stdexcept>
#include <string>
-#include <utility>
#include <vector>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iterator>
+# include <utility>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [re.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -1311,9 +1330,9 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
}
inline _LIBCPP_INLINE_VISIBILITY
-bool __is_07(unsigned char c)
+bool __is_07(unsigned char __c)
{
- return (c & 0xF8u) ==
+ return (__c & 0xF8u) ==
#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
0xF0;
#else
@@ -1322,9 +1341,9 @@ bool __is_07(unsigned char c)
}
inline _LIBCPP_INLINE_VISIBILITY
-bool __is_89(unsigned char c)
+bool __is_89(unsigned char __c)
{
- return (c & 0xFEu) ==
+ return (__c & 0xFEu) ==
#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
0xF8;
#else
@@ -1333,12 +1352,12 @@ bool __is_89(unsigned char c)
}
inline _LIBCPP_INLINE_VISIBILITY
-unsigned char __to_lower(unsigned char c)
+unsigned char __to_lower(unsigned char __c)
{
#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
return c & 0xBF;
#else
- return c | 0x20;
+ return __c | 0x20;
#endif
}
@@ -2038,9 +2057,9 @@ __word_boundary<_CharT, _Traits>::__exec(__state& __s) const
template <class _CharT>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-bool __is_eol(_CharT c)
+bool __is_eol(_CharT __c)
{
- return c == '\r' || c == '\n';
+ return __c == '\r' || __c == '\n';
}
template <class _CharT>
@@ -2093,14 +2112,14 @@ class __r_anchor_multiline
{
typedef __owns_one_state<_CharT> base;
- bool __multiline;
+ bool __multiline_;
public:
typedef _VSTD::__state<_CharT> __state;
_LIBCPP_INLINE_VISIBILITY
__r_anchor_multiline(bool __multiline, __node<_CharT>* __s)
- : base(__s), __multiline(__multiline) {}
+ : base(__s), __multiline_(__multiline) {}
virtual void __exec(__state&) const;
};
@@ -2115,7 +2134,7 @@ __r_anchor_multiline<_CharT>::__exec(__state& __s) const
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
}
- else if (__multiline && __is_eol(*__s.__current_))
+ else if (__multiline_ && __is_eol(*__s.__current_))
{
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
@@ -2729,12 +2748,7 @@ public:
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- __is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value,
- basic_regex&
- >::type
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value, basic_regex&>::type
assign(_InputIterator __first, _InputIterator __last,
flag_type __f = regex_constants::ECMAScript)
{
@@ -2949,7 +2963,7 @@ private:
__parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
basic_string<_CharT>* __str = nullptr);
- bool __test_back_ref(_CharT c);
+ bool __test_back_ref(_CharT);
_LIBCPP_INLINE_VISIBILITY
void __push_l_anchor();
@@ -4768,9 +4782,9 @@ basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
template <class _CharT, class _Traits>
bool
-basic_regex<_CharT, _Traits>::__test_back_ref(_CharT c)
+basic_regex<_CharT, _Traits>::__test_back_ref(_CharT __c)
{
- unsigned __val = __traits_.value(c, 10);
+ unsigned __val = __traits_.value(__c, 10);
if (__val >= 1 && __val <= 9)
{
if (__val > mark_count())
lib/libcxx/include/scoped_allocator
@@ -109,13 +109,14 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__utility/forward.h>
#include <memory>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -218,10 +219,10 @@ protected:
is_constructible<outer_allocator_type, _OuterA2>::value
>::type>
_LIBCPP_INLINE_VISIBILITY
- __scoped_allocator_storage(_OuterA2&& __outerAlloc,
- const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
- : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)),
- __inner_(__innerAllocs...) {}
+ __scoped_allocator_storage(_OuterA2&& __outer_alloc,
+ const _InnerAllocs& ...__inner_allocs) _NOEXCEPT
+ : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)),
+ __inner_(__inner_allocs...) {}
template <class _OuterA2,
class = typename enable_if<
@@ -299,8 +300,8 @@ protected:
is_constructible<outer_allocator_type, _OuterA2>::value
>::type>
_LIBCPP_INLINE_VISIBILITY
- __scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT
- : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {}
+ __scoped_allocator_storage(_OuterA2&& __outer_alloc) _NOEXCEPT
+ : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)) {}
template <class _OuterA2,
class = typename enable_if<
@@ -443,9 +444,9 @@ public:
is_constructible<outer_allocator_type, _OuterA2>::value
>::type>
_LIBCPP_INLINE_VISIBILITY
- scoped_allocator_adaptor(_OuterA2&& __outerAlloc,
- const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
- : base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {}
+ scoped_allocator_adaptor(_OuterA2&& __outer_alloc,
+ const _InnerAllocs& ...__inner_allocs) _NOEXCEPT
+ : base(_VSTD::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
// scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
template <class _OuterA2,
class = typename enable_if<
lib/libcxx/include/semaphore
@@ -45,19 +45,22 @@ using binary_semaphore = counting_semaphore<1>;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
+#include <__chrono/time_point.h>
#include <__config>
#include <__thread/timed_backoff_policy.h>
#include <__threading_support>
#include <atomic>
+#include <limits>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef _LIBCPP_HAS_NO_THREADS
-# error <semaphore> is not supported on this single threaded system
+# error "<semaphore> is not supported since libc++ has been configured without support for threads."
#endif
_LIBCPP_PUSH_MACROS
lib/libcxx/include/set
@@ -471,21 +471,40 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
*/
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__debug>
#include <__functional/is_transparent.h>
+#include <__functional/operations.h>
+#include <__iterator/erase_if_container.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
#include <__node_handle>
#include <__tree>
#include <__utility/forward.h>
+#include <version>
+
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <functional>
+# include <iterator>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [associative.set.syn]
#include <compare>
-#include <functional>
#include <initializer_list>
-#include <iterator> // __libcpp_erase_if_container
-#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -501,9 +520,9 @@ public:
// types:
typedef _Key key_type;
typedef key_type value_type;
- typedef __identity_t<_Compare> key_compare;
+ typedef __type_identity_t<_Compare> key_compare;
typedef key_compare value_compare;
- typedef __identity_t<_Allocator> allocator_type;
+ typedef __type_identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -1034,9 +1053,9 @@ public:
// types:
typedef _Key key_type;
typedef key_type value_type;
- typedef __identity_t<_Compare> key_compare;
+ typedef __type_identity_t<_Compare> key_compare;
typedef key_compare value_compare;
- typedef __identity_t<_Allocator> allocator_type;
+ typedef __type_identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
lib/libcxx/include/setjmp.h
@@ -28,7 +28,7 @@ void longjmp(jmp_buf env, int val);
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <setjmp.h>
lib/libcxx/include/span
@@ -127,24 +127,43 @@ template<class R>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__debug>
+#include <__fwd/span.h>
+#include <__iterator/bounded_iter.h>
#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
#include <__iterator/wrap_iter.h>
+#include <__memory/pointer_traits.h>
#include <__ranges/concepts.h>
#include <__ranges/data.h>
#include <__ranges/enable_borrowed_range.h>
#include <__ranges/enable_view.h>
#include <__ranges/size.h>
+#include <__utility/forward.h>
#include <array> // for array
#include <cstddef> // for byte
-#include <iterator> // for iterators
#include <limits>
#include <type_traits> // for remove_cv, etc
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <functional>
+# include <iterator>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -154,10 +173,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
-template <typename _Tp, size_t _Extent = dynamic_extent> class span;
-
-
template <class _Tp>
struct __is_std_array : false_type {};
@@ -170,24 +185,22 @@ struct __is_std_span : false_type {};
template <class _Tp, size_t _Sz>
struct __is_std_span<span<_Tp, _Sz>> : true_type {};
-#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// This is a temporary workaround until we ship <ranges> -- we've unfortunately been
// shipping <span> before its API was finalized, and we used to provide a constructor
// from container types that had the requirements below. To avoid breaking code that
// has started relying on the range-based constructor until we ship all of <ranges>,
// we emulate the constructor requirements like this.
-template <class _Range, class _ElementType, class = void>
-struct __span_compatible_range : false_type { };
-
template <class _Range, class _ElementType>
-struct __span_compatible_range<_Range, _ElementType, void_t<
- enable_if_t<!__is_std_span<remove_cvref_t<_Range>>::value>,
- enable_if_t<!__is_std_array<remove_cvref_t<_Range>>::value>,
- enable_if_t<!is_array_v<remove_cvref_t<_Range>>>,
- decltype(data(declval<_Range>())),
- decltype(size(declval<_Range>())),
- enable_if_t<is_convertible_v<remove_pointer_t<decltype(data(declval<_Range&>()))>(*)[], _ElementType(*)[]>>
->> : true_type { };
+concept __span_compatible_range =
+ !__is_std_span<remove_cvref_t<_Range>>::value &&
+ !__is_std_array<remove_cvref_t<_Range>>::value &&
+ !is_array_v<remove_cvref_t<_Range>> &&
+ requires (_Range&& __r) {
+ data(std::forward<_Range>(__r));
+ size(std::forward<_Range>(__r));
+ } &&
+ is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
#else
template <class _Range, class _ElementType>
concept __span_compatible_range =
@@ -198,7 +211,16 @@ concept __span_compatible_range =
!__is_std_array<remove_cvref_t<_Range>>::value &&
!is_array_v<remove_cvref_t<_Range>> &&
is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
-#endif
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+template <class _From, class _To>
+concept __span_array_convertible = is_convertible_v<_From(*)[], _To(*)[]>;
+
+template <class _It, class _Tp>
+concept __span_compatible_iterator = contiguous_iterator<_It> && __span_array_convertible<remove_reference_t<iter_reference_t<_It>>, _Tp>;
+
+template <class _Sentinel, class _It>
+concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>;
template <typename _Tp, size_t _Extent>
class _LIBCPP_TEMPLATE_VIS span {
@@ -212,8 +234,8 @@ public:
using const_pointer = const _Tp *;
using reference = _Tp &;
using const_reference = const _Tp &;
-#if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)
- using iterator = pointer;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ using iterator = __bounded_iter<pointer>;
#else
using iterator = __wrap_iter<pointer>;
#endif
@@ -222,17 +244,13 @@ public:
static constexpr size_type extent = _Extent;
// [span.cons], span constructors, copy, assignment, and destructor
- template <size_t _Sz = _Extent, enable_if_t<_Sz == 0, nullptr_t> = nullptr>
+ template <size_t _Sz = _Extent> requires(_Sz == 0)
_LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}
constexpr span (const span&) noexcept = default;
constexpr span& operator=(const span&) noexcept = default;
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
- template <class _It,
- enable_if_t<contiguous_iterator<_It> &&
- is_convertible_v<remove_reference_t<iter_reference_t<_It>>(*)[], element_type (*)[]>,
- nullptr_t> = nullptr>
+ template <__span_compatible_iterator<element_type> _It>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit span(_It __first, size_type __count)
: __data{_VSTD::to_address(__first)} {
@@ -240,11 +258,7 @@ public:
_LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
}
- template <
- class _It, class _End,
- enable_if_t<is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]> &&
- contiguous_iterator<_It> && sized_sentinel_for<_End, _It> && !is_convertible_v<_End, size_t>,
- nullptr_t> = nullptr>
+ template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} {
(void)__last;
@@ -252,31 +266,27 @@ public:
_LIBCPP_ASSERT(__last - __first == _Extent,
"invalid range in span's constructor (iterator, sentinel): last - first != extent");
}
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
_LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}
- template <class _OtherElementType,
- enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
- template <class _OtherElementType,
- enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ template <class _OtherElementType>
+ requires __span_array_convertible<const _OtherElementType, element_type>
_LIBCPP_INLINE_VISIBILITY
constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
-#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
- template <class _Container, class = enable_if_t<
- __span_compatible_range<_Container, element_type>::value
- >>
+#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+ template <class _Container>
+ requires __span_compatible_range<_Container, element_type>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit span(_Container& __c) : __data{std::data(__c)} {
_LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
}
- template <class _Container, class = enable_if_t<
- __span_compatible_range<const _Container, element_type>::value
- >>
+ template <class _Container>
+ requires __span_compatible_range<const _Container, element_type>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit span(const _Container& __c) : __data{std::data(__c)} {
_LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
@@ -287,22 +297,16 @@ public:
constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {
_LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");
}
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif
- template <class _OtherElementType>
+ template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(const span<_OtherElementType, _Extent>& __other,
- enable_if_t<
- is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
- nullptr_t> = nullptr)
+ constexpr span(const span<_OtherElementType, _Extent>& __other)
: __data{__other.data()} {}
- template <class _OtherElementType>
+ template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other,
- enable_if_t<
- is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
- nullptr_t> = nullptr) noexcept
+ constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept
: __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
@@ -312,7 +316,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, _Count> first() const noexcept
{
- static_assert(_Count <= _Extent, "Count out of range in span::first()");
+ static_assert(_Count <= _Extent, "span<T, N>::first<Count>(): Count out of range");
return span<element_type, _Count>{data(), _Count};
}
@@ -320,21 +324,21 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, _Count> last() const noexcept
{
- static_assert(_Count <= _Extent, "Count out of range in span::last()");
+ static_assert(_Count <= _Extent, "span<T, N>::last<Count>(): Count out of range");
return span<element_type, _Count>{data() + size() - _Count, _Count};
}
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
{
- _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");
+ _LIBCPP_ASSERT(__count <= size(), "span<T, N>::first(count): count out of range");
return {data(), __count};
}
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept
{
- _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");
+ _LIBCPP_ASSERT(__count <= size(), "span<T, N>::last(count): count out of range");
return {data() + size() - __count, __count};
}
@@ -343,8 +347,8 @@ public:
constexpr auto subspan() const noexcept
-> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>
{
- static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()");
- static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "Offset + count out of range in span::subspan()");
+ static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range");
+ static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range");
using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>;
return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};
@@ -355,11 +359,11 @@ public:
constexpr span<element_type, dynamic_extent>
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)");
+ _LIBCPP_ASSERT(__offset <= size(), "span<T, N>::subspan(offset, count): offset out of range");
+ _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T, N>::subspan(offset, count): count out of range");
if (__count == dynamic_extent)
return {data() + __offset, size() - __offset};
- _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)");
+ _LIBCPP_ASSERT(__count <= size() - __offset, "span<T, N>::subspan(offset, count): offset + count out of range");
return {data() + __offset, __count};
}
@@ -369,7 +373,7 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
- _LIBCPP_ASSERT(__idx < size(), "span<T,N>[] index out of bounds");
+ _LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range");
return __data[__idx];
}
@@ -388,8 +392,20 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
// [span.iter], span iterator support
- _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); }
- _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }
+ _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ return std::__make_bounded_iter(data(), data(), data() + size());
+#else
+ return iterator(this, data());
+#endif
+ }
+ _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ return std::__make_bounded_iter(data() + size(), data(), data() + size());
+#else
+ return iterator(this, data() + size());
+#endif
+ }
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
@@ -401,14 +417,11 @@ public:
private:
pointer __data;
-
};
template <typename _Tp>
class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {
-private:
-
public:
// constants and types
using element_type = _Tp;
@@ -419,8 +432,8 @@ public:
using const_pointer = const _Tp *;
using reference = _Tp &;
using const_reference = const _Tp &;
-#if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)
- using iterator = pointer;
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ using iterator = __bounded_iter<pointer>;
#else
using iterator = __wrap_iter<pointer>;
#endif
@@ -434,62 +447,47 @@ public:
constexpr span (const span&) noexcept = default;
constexpr span& operator=(const span&) noexcept = default;
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
- template <class _It,
- enable_if_t<contiguous_iterator<_It> &&
- is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]>,
- nullptr_t> = nullptr>
+ template <__span_compatible_iterator<element_type> _It>
_LIBCPP_INLINE_VISIBILITY
constexpr span(_It __first, size_type __count)
: __data{_VSTD::to_address(__first)}, __size{__count} {}
- template <
- class _It, class _End,
- enable_if_t<is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]> &&
- contiguous_iterator<_It> && sized_sentinel_for<_End, _It> && !is_convertible_v<_End, size_t>,
- nullptr_t> = nullptr>
+ template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
_LIBCPP_INLINE_VISIBILITY
constexpr span(_It __first, _End __last)
: __data(_VSTD::to_address(__first)), __size(__last - __first) {}
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
template <size_t _Sz>
_LIBCPP_INLINE_VISIBILITY
constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
- template <class _OtherElementType, size_t _Sz,
- enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ template <__span_array_convertible<element_type> _OtherElementType, size_t _Sz>
_LIBCPP_INLINE_VISIBILITY
constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
- template <class _OtherElementType, size_t _Sz,
- enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ template <class _OtherElementType, size_t _Sz>
+ requires __span_array_convertible<const _OtherElementType, element_type>
_LIBCPP_INLINE_VISIBILITY
constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
-#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
- template <class _Container, class = enable_if_t<
- __span_compatible_range<_Container, element_type>::value
- >>
+#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+ template <class _Container>
+ requires __span_compatible_range<_Container, element_type>
_LIBCPP_INLINE_VISIBILITY
constexpr span(_Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
- template <class _Container, class = enable_if_t<
- __span_compatible_range<const _Container, element_type>::value
- >>
+ template <class _Container>
+ requires __span_compatible_range<const _Container, element_type>
_LIBCPP_INLINE_VISIBILITY
constexpr span(const _Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
#else
template <__span_compatible_range<element_type> _Range>
_LIBCPP_INLINE_VISIBILITY
constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif
- template <class _OtherElementType, size_t _OtherExtent>
+ template <__span_array_convertible<element_type> _OtherElementType, size_t _OtherExtent>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
- enable_if_t<
- is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
- nullptr_t> = nullptr) noexcept
+ constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept
: __data{__other.data()}, __size{__other.size()} {}
// ~span() noexcept = default;
@@ -498,7 +496,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, _Count> first() const noexcept
{
- _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()");
+ _LIBCPP_ASSERT(_Count <= size(), "span<T>::first<Count>(): Count out of range");
return span<element_type, _Count>{data(), _Count};
}
@@ -506,21 +504,21 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, _Count> last() const noexcept
{
- _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()");
+ _LIBCPP_ASSERT(_Count <= size(), "span<T>::last<Count>(): Count out of range");
return span<element_type, _Count>{data() + size() - _Count, _Count};
}
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
{
- _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");
+ _LIBCPP_ASSERT(__count <= size(), "span<T>::first(count): count out of range");
return {data(), __count};
}
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept
{
- _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");
+ _LIBCPP_ASSERT(__count <= size(), "span<T>::last(count): count out of range");
return {data() + size() - __count, __count};
}
@@ -528,8 +526,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr span<element_type, _Count> subspan() const noexcept
{
- _LIBCPP_ASSERT(_Offset <= size(), "Offset out of range in span::subspan()");
- _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "Offset + count out of range in span::subspan()");
+ _LIBCPP_ASSERT(_Offset <= size(), "span<T>::subspan<Offset, Count>(): Offset out of range");
+ _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "span<T>::subspan<Offset, Count>(): Offset + Count out of range");
return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};
}
@@ -537,11 +535,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
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)");
+ _LIBCPP_ASSERT(__offset <= size(), "span<T>::subspan(offset, count): offset out of range");
+ _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T>::subspan(offset, count): count out of range");
if (__count == dynamic_extent)
return {data() + __offset, size() - __offset};
- _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)");
+ _LIBCPP_ASSERT(__count <= size() - __offset, "span<T>::subspan(offset, count): offset + count out of range");
return {data() + __offset, __count};
}
@@ -551,19 +549,19 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
- _LIBCPP_ASSERT(__idx < size(), "span<T>[] index out of bounds");
+ _LIBCPP_ASSERT(__idx < size(), "span<T>::operator[](index): index out of range");
return __data[__idx];
}
_LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
{
- _LIBCPP_ASSERT(!empty(), "span<T>[].front() on empty span");
+ _LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span");
return __data[0];
}
_LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
{
- _LIBCPP_ASSERT(!empty(), "span<T>[].back() on empty span");
+ _LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span");
return __data[size()-1];
}
@@ -571,8 +569,20 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
// [span.iter], span iterator support
- _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); }
- _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }
+ _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ return std::__make_bounded_iter(data(), data(), data() + size());
+#else
+ return iterator(this, data());
+#endif
+ }
+ _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+ return std::__make_bounded_iter(data() + size(), data(), data() + size());
+#else
+ return iterator(this, data() + size());
+#endif
+ }
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
@@ -587,31 +597,27 @@ private:
size_type __size;
};
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
template <class _Tp, size_t _Extent>
inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true;
template <class _ElementType, size_t _Extent>
inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
// as_bytes & as_writable_bytes
template <class _Tp, size_t _Extent>
_LIBCPP_INLINE_VISIBILITY
auto as_bytes(span<_Tp, _Extent> __s) noexcept
--> decltype(__s.__as_bytes())
-{ return __s.__as_bytes(); }
+{ return __s.__as_bytes(); }
-template <class _Tp, size_t _Extent>
+template <class _Tp, size_t _Extent> requires(!is_const_v<_Tp>)
_LIBCPP_INLINE_VISIBILITY
auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept
--> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())>
{ return __s.__as_writable_bytes(); }
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template<contiguous_iterator _It, class _EndOrSize>
span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
template<class _Tp, size_t _Sz>
span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
@@ -622,7 +628,7 @@ template<class _Tp, size_t _Sz>
template<class _Tp, size_t _Sz>
span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
-#if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
template<class _Container>
span(_Container&) -> span<typename _Container::value_type>;
lib/libcxx/include/sstream
@@ -180,14 +180,16 @@ typedef basic_stringstream<wchar_t> wstringstream;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__utility/swap.h>
#include <istream>
#include <ostream>
#include <string>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -859,10 +861,10 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
}
#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>;
#endif
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/stack
@@ -98,6 +98,7 @@ template <class T, class Container>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__memory/uses_allocator.h>
@@ -106,8 +107,16 @@ template <class T, class Container>
#include <type_traits>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <functional>
+#endif
+
+// standard-mandated includes
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/stdatomic.h
@@ -0,0 +1,235 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_STDATOMIC_H
+#define _LIBCPP_STDATOMIC_H
+
+/*
+ stdatomic.h synopsis
+
+template<class T>
+ using std-atomic = std::atomic<T>; // exposition only
+
+#define _Atomic(T) std-atomic<T>
+
+#define ATOMIC_BOOL_LOCK_FREE see below
+#define ATOMIC_CHAR_LOCK_FREE see below
+#define ATOMIC_CHAR16_T_LOCK_FREE see below
+#define ATOMIC_CHAR32_T_LOCK_FREE see below
+#define ATOMIC_WCHAR_T_LOCK_FREE see below
+#define ATOMIC_SHORT_LOCK_FREE see below
+#define ATOMIC_INT_LOCK_FREE see below
+#define ATOMIC_LONG_LOCK_FREE see below
+#define ATOMIC_LLONG_LOCK_FREE see below
+#define ATOMIC_POINTER_LOCK_FREE see below
+
+using std::memory_order // see below
+using std::memory_order_relaxed // see below
+using std::memory_order_consume // see below
+using std::memory_order_acquire // see below
+using std::memory_order_release // see below
+using std::memory_order_acq_rel // see below
+using std::memory_order_seq_cst // see below
+
+using std::atomic_flag // see below
+
+using std::atomic_bool // see below
+using std::atomic_char // see below
+using std::atomic_schar // see below
+using std::atomic_uchar // see below
+using std::atomic_short // see below
+using std::atomic_ushort // see below
+using std::atomic_int // see below
+using std::atomic_uint // see below
+using std::atomic_long // see below
+using std::atomic_ulong // see below
+using std::atomic_llong // see below
+using std::atomic_ullong // see below
+using std::atomic_char8_t // see below
+using std::atomic_char16_t // see below
+using std::atomic_char32_t // see below
+using std::atomic_wchar_t // see below
+using std::atomic_int8_t // see below
+using std::atomic_uint8_t // see below
+using std::atomic_int16_t // see below
+using std::atomic_uint16_t // see below
+using std::atomic_int32_t // see below
+using std::atomic_uint32_t // see below
+using std::atomic_int64_t // see below
+using std::atomic_uint64_t // see below
+using std::atomic_int_least8_t // see below
+using std::atomic_uint_least8_t // see below
+using std::atomic_int_least16_t // see below
+using std::atomic_uint_least16_t // see below
+using std::atomic_int_least32_t // see below
+using std::atomic_uint_least32_t // see below
+using std::atomic_int_least64_t // see below
+using std::atomic_uint_least64_t // see below
+using std::atomic_int_fast8_t // see below
+using std::atomic_uint_fast8_t // see below
+using std::atomic_int_fast16_t // see below
+using std::atomic_uint_fast16_t // see below
+using std::atomic_int_fast32_t // see below
+using std::atomic_uint_fast32_t // see below
+using std::atomic_int_fast64_t // see below
+using std::atomic_uint_fast64_t // see below
+using std::atomic_intptr_t // see below
+using std::atomic_uintptr_t // see below
+using std::atomic_size_t // see below
+using std::atomic_ptrdiff_t // see below
+using std::atomic_intmax_t // see below
+using std::atomic_uintmax_t // see below
+
+using std::atomic_is_lock_free // see below
+using std::atomic_load // see below
+using std::atomic_load_explicit // see below
+using std::atomic_store // see below
+using std::atomic_store_explicit // see below
+using std::atomic_exchange // see below
+using std::atomic_exchange_explicit // see below
+using std::atomic_compare_exchange_strong // see below
+using std::atomic_compare_exchange_strong_explicit // see below
+using std::atomic_compare_exchange_weak // see below
+using std::atomic_compare_exchange_weak_explicit // see below
+using std::atomic_fetch_add // see below
+using std::atomic_fetch_add_explicit // see below
+using std::atomic_fetch_sub // see below
+using std::atomic_fetch_sub_explicit // see below
+using std::atomic_fetch_or // see below
+using std::atomic_fetch_or_explicit // see below
+using std::atomic_fetch_and // see below
+using std::atomic_fetch_and_explicit // see below
+using std::atomic_flag_test_and_set // see below
+using std::atomic_flag_test_and_set_explicit // see below
+using std::atomic_flag_clear // see below
+using std::atomic_flag_clear_explicit // see below
+
+using std::atomic_thread_fence // see below
+using std::atomic_signal_fence // see below
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 20
+
+#include <atomic>
+#include <version>
+
+#ifdef _Atomic
+# undef _Atomic
+#endif
+
+#define _Atomic(_Tp) ::std::atomic<_Tp>
+
+using std::memory_order _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_consume _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_acquire _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_release _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_acq_rel _LIBCPP_USING_IF_EXISTS;
+using std::memory_order_seq_cst _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_flag _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_bool _LIBCPP_USING_IF_EXISTS;
+using std::atomic_char _LIBCPP_USING_IF_EXISTS;
+using std::atomic_schar _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uchar _LIBCPP_USING_IF_EXISTS;
+using std::atomic_short _LIBCPP_USING_IF_EXISTS;
+using std::atomic_ushort _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint _LIBCPP_USING_IF_EXISTS;
+using std::atomic_long _LIBCPP_USING_IF_EXISTS;
+using std::atomic_ulong _LIBCPP_USING_IF_EXISTS;
+using std::atomic_llong _LIBCPP_USING_IF_EXISTS;
+using std::atomic_ullong _LIBCPP_USING_IF_EXISTS;
+using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int64_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint64_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_int_least8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_least8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_least16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_least16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_least32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_least32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_least64_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_least64_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_int_fast8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_fast8_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_fast16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_fast16_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_fast32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_fast32_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_int_fast64_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uint_fast64_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_intptr_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uintptr_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_size_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_ptrdiff_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_intmax_t _LIBCPP_USING_IF_EXISTS;
+using std::atomic_uintmax_t _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_compare_exchange_strong _LIBCPP_USING_IF_EXISTS;
+using std::atomic_compare_exchange_strong_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_compare_exchange_weak _LIBCPP_USING_IF_EXISTS;
+using std::atomic_compare_exchange_weak_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_exchange _LIBCPP_USING_IF_EXISTS;
+using std::atomic_exchange_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_add _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS;
+using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_flag_clear _LIBCPP_USING_IF_EXISTS;
+using std::atomic_flag_clear_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_flag_test_and_set _LIBCPP_USING_IF_EXISTS;
+using std::atomic_flag_test_and_set_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_is_lock_free _LIBCPP_USING_IF_EXISTS;
+using std::atomic_load _LIBCPP_USING_IF_EXISTS;
+using std::atomic_load_explicit _LIBCPP_USING_IF_EXISTS;
+using std::atomic_store _LIBCPP_USING_IF_EXISTS;
+using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;
+
+using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;
+using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
+
+#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
+
+// Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking
+// the header. We do this because Clang has historically shipped a <stdatomic.h>
+// header that would be available in all Standard modes, and we don't want to
+// break that use case.
+# if __has_include_next(<stdatomic.h>)
+# include_next <stdatomic.h>
+# endif
+
+#endif // _LIBCPP_STD_VER > 20
+
+#endif // _LIBCPP_STDATOMIC_H
lib/libcxx/include/stdbool.h
@@ -9,7 +9,6 @@
#ifndef _LIBCPP_STDBOOL_H
#define _LIBCPP_STDBOOL_H
-
/*
stdbool.h synopsis
@@ -22,7 +21,7 @@ Macros:
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <stdbool.h>
lib/libcxx/include/stddef.h
@@ -11,7 +11,7 @@
defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <stddef.h>
@@ -39,18 +39,13 @@ Types:
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <stddef.h>
#ifdef __cplusplus
-
-extern "C++" {
-#include <__nullptr>
-using std::nullptr_t;
-}
-
+ typedef decltype(nullptr) nullptr_t;
#endif
#endif // _LIBCPP_STDDEF_H
lib/libcxx/include/stdexcept
@@ -41,13 +41,14 @@ public:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cstdlib>
#include <exception>
#include <iosfwd> // for string forward decl
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/stdint.h
@@ -106,7 +106,7 @@ Macros:
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
lib/libcxx/include/stdio.h
@@ -10,7 +10,7 @@
#if defined(__need_FILE) || defined(__need___FILE)
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <stdio.h>
@@ -101,7 +101,7 @@ void perror(const char* s);
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <stdio.h>
lib/libcxx/include/stdlib.h
@@ -10,7 +10,7 @@
#if defined(__need_malloc_and_calloc)
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <stdlib.h>
@@ -87,7 +87,7 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <stdlib.h>
lib/libcxx/include/streambuf
@@ -107,6 +107,7 @@ protected:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cstdint>
#include <ios>
@@ -114,7 +115,7 @@ protected:
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -487,11 +488,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
return traits_type::eof();
}
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>)
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/string
@@ -95,248 +95,246 @@ public:
static const size_type npos = -1;
basic_string()
- noexcept(is_nothrow_default_constructible<allocator_type>::value);
- explicit basic_string(const allocator_type& a);
- basic_string(const basic_string& str);
+ noexcept(is_nothrow_default_constructible<allocator_type>::value); // constexpr since C++20
+ explicit basic_string(const allocator_type& a); // constexpr since C++20
+ basic_string(const basic_string& str); // constexpr since C++20
basic_string(basic_string&& str)
- noexcept(is_nothrow_move_constructible<allocator_type>::value);
+ noexcept(is_nothrow_move_constructible<allocator_type>::value); // constexpr since C++20
basic_string(const basic_string& str, size_type pos,
- const allocator_type& a = allocator_type());
+ const allocator_type& a = allocator_type()); // constexpr since C++20
basic_string(const basic_string& str, size_type pos, size_type n,
- const Allocator& a = Allocator());
+ const Allocator& a = Allocator()); // constexpr since C++20
template<class T>
- basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17
+ basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17, constexpr since C++20
template <class T>
- explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17
- basic_string(const value_type* s, const allocator_type& a = allocator_type());
- basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type());
+ explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17, constexpr since C++20
+ basic_string(const value_type* s, const allocator_type& a = allocator_type()); // constexpr since C++20
+ basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); // constexpr since C++20
basic_string(nullptr_t) = delete; // C++2b
- basic_string(size_type n, value_type c, const allocator_type& a = allocator_type());
+ basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); // constexpr since C++20
template<class InputIterator>
basic_string(InputIterator begin, InputIterator end,
- const allocator_type& a = allocator_type());
- basic_string(initializer_list<value_type>, const Allocator& = Allocator());
- basic_string(const basic_string&, const Allocator&);
- basic_string(basic_string&&, const Allocator&);
+ const allocator_type& a = allocator_type()); // constexpr since C++20
+ basic_string(initializer_list<value_type>, const Allocator& = Allocator()); // constexpr since C++20
+ basic_string(const basic_string&, const Allocator&); // constexpr since C++20
+ basic_string(basic_string&&, const Allocator&); // constexpr since C++20
- ~basic_string();
+ ~basic_string(); // constexpr since C++20
- operator basic_string_view<charT, traits>() const noexcept;
+ operator basic_string_view<charT, traits>() const noexcept; // constexpr since C++20
- basic_string& operator=(const basic_string& str);
+ basic_string& operator=(const basic_string& str); // constexpr since C++20
template <class T>
- basic_string& operator=(const T& t); // C++17
+ basic_string& operator=(const T& t); // C++17, constexpr since C++20
basic_string& operator=(basic_string&& str)
noexcept(
allocator_type::propagate_on_container_move_assignment::value ||
- allocator_type::is_always_equal::value ); // C++17
- basic_string& operator=(const value_type* s);
+ allocator_type::is_always_equal::value ); // C++17, constexpr since C++20
+ basic_string& operator=(const value_type* s); // constexpr since C++20
basic_string& operator=(nullptr_t) = delete; // C++2b
- basic_string& operator=(value_type c);
- basic_string& operator=(initializer_list<value_type>);
+ basic_string& operator=(value_type c); // constexpr since C++20
+ basic_string& operator=(initializer_list<value_type>); // constexpr since C++20
- iterator begin() noexcept;
- const_iterator begin() const noexcept;
- iterator end() noexcept;
- const_iterator end() const noexcept;
+ iterator begin() noexcept; // constexpr since C++20
+ const_iterator begin() const noexcept; // constexpr since C++20
+ iterator end() noexcept; // constexpr since C++20
+ const_iterator end() const noexcept; // constexpr since C++20
- reverse_iterator rbegin() noexcept;
- const_reverse_iterator rbegin() const noexcept;
- reverse_iterator rend() noexcept;
- const_reverse_iterator rend() const noexcept;
+ reverse_iterator rbegin() noexcept; // constexpr since C++20
+ const_reverse_iterator rbegin() const noexcept; // constexpr since C++20
+ reverse_iterator rend() noexcept; // constexpr since C++20
+ const_reverse_iterator rend() const noexcept; // constexpr since C++20
- const_iterator cbegin() const noexcept;
- const_iterator cend() const noexcept;
- const_reverse_iterator crbegin() const noexcept;
- const_reverse_iterator crend() const noexcept;
+ const_iterator cbegin() const noexcept; // constexpr since C++20
+ const_iterator cend() const noexcept; // constexpr since C++20
+ const_reverse_iterator crbegin() const noexcept; // constexpr since C++20
+ const_reverse_iterator crend() const noexcept; // constexpr since C++20
- size_type size() const noexcept;
- size_type length() const noexcept;
- size_type max_size() const noexcept;
- size_type capacity() const noexcept;
+ size_type size() const noexcept; // constexpr since C++20
+ size_type length() const noexcept; // constexpr since C++20
+ size_type max_size() const noexcept; // constexpr since C++20
+ size_type capacity() const noexcept; // constexpr since C++20
- void resize(size_type n, value_type c);
- void resize(size_type n);
+ void resize(size_type n, value_type c); // constexpr since C++20
+ void resize(size_type n); // constexpr since C++20
template<class Operation>
constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23
- void reserve(size_type res_arg);
+ void reserve(size_type res_arg); // constexpr since C++20
void reserve(); // deprecated in C++20
- void shrink_to_fit();
- void clear() noexcept;
- bool empty() const noexcept;
+ void shrink_to_fit(); // constexpr since C++20
+ void clear() noexcept; // constexpr since C++20
+ bool empty() const noexcept; // constexpr since C++20
- const_reference operator[](size_type pos) const;
- reference operator[](size_type pos);
+ const_reference operator[](size_type pos) const; // constexpr since C++20
+ reference operator[](size_type pos); // constexpr since C++20
- const_reference at(size_type n) const;
- reference at(size_type n);
+ const_reference at(size_type n) const; // constexpr since C++20
+ reference at(size_type n); // constexpr since C++20
- basic_string& operator+=(const basic_string& str);
+ basic_string& operator+=(const basic_string& str); // constexpr since C++20
template <class T>
- basic_string& operator+=(const T& t); // C++17
- basic_string& operator+=(const value_type* s);
- basic_string& operator+=(value_type c);
- basic_string& operator+=(initializer_list<value_type>);
+ basic_string& operator+=(const T& t); // C++17, constexpr since C++20
+ basic_string& operator+=(const value_type* s); // constexpr since C++20
+ basic_string& operator+=(value_type c); // constexpr since C++20
+ basic_string& operator+=(initializer_list<value_type>); // constexpr since C++20
- basic_string& append(const basic_string& str);
+ basic_string& append(const basic_string& str); // constexpr since C++20
template <class T>
- basic_string& append(const T& t); // C++17
- basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14
+ basic_string& append(const T& t); // C++17, constexpr since C++20
+ basic_string& append(const basic_string& str, size_type pos, size_type n=npos); // C++14, constexpr since C++20
template <class T>
- basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17
- basic_string& append(const value_type* s, size_type n);
- basic_string& append(const value_type* s);
- basic_string& append(size_type n, value_type c);
+ basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20
+ basic_string& append(const value_type* s, size_type n); // constexpr since C++20
+ basic_string& append(const value_type* s); // constexpr since C++20
+ basic_string& append(size_type n, value_type c); // constexpr since C++20
template<class InputIterator>
- basic_string& append(InputIterator first, InputIterator last);
- basic_string& append(initializer_list<value_type>);
+ basic_string& append(InputIterator first, InputIterator last); // constexpr since C++20
+ basic_string& append(initializer_list<value_type>); // constexpr since C++20
- void push_back(value_type c);
- void pop_back();
- reference front();
- const_reference front() const;
- reference back();
- const_reference back() const;
+ void push_back(value_type c); // constexpr since C++20
+ void pop_back(); // constexpr since C++20
+ reference front(); // constexpr since C++20
+ const_reference front() const; // constexpr since C++20
+ reference back(); // constexpr since C++20
+ const_reference back() const; // constexpr since C++20
- basic_string& assign(const basic_string& str);
+ basic_string& assign(const basic_string& str); // constexpr since C++20
template <class T>
- basic_string& assign(const T& t); // C++17
- basic_string& assign(basic_string&& str);
- basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14
+ basic_string& assign(const T& t); // C++17, constexpr since C++20
+ basic_string& assign(basic_string&& str); // constexpr since C++20
+ basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14, constexpr since C++20
template <class T>
- basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17
- basic_string& assign(const value_type* s, size_type n);
- basic_string& assign(const value_type* s);
- basic_string& assign(size_type n, value_type c);
+ basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20
+ basic_string& assign(const value_type* s, size_type n); // constexpr since C++20
+ basic_string& assign(const value_type* s); // constexpr since C++20
+ basic_string& assign(size_type n, value_type c); // constexpr since C++20
template<class InputIterator>
- basic_string& assign(InputIterator first, InputIterator last);
- basic_string& assign(initializer_list<value_type>);
+ basic_string& assign(InputIterator first, InputIterator last); // constexpr since C++20
+ basic_string& assign(initializer_list<value_type>); // constexpr since C++20
- basic_string& insert(size_type pos1, const basic_string& str);
+ basic_string& insert(size_type pos1, const basic_string& str); // constexpr since C++20
template <class T>
- basic_string& insert(size_type pos1, const T& t);
+ basic_string& insert(size_type pos1, const T& t); // constexpr since C++20
basic_string& insert(size_type pos1, const basic_string& str,
- size_type pos2, size_type n);
+ size_type pos2, size_type n); // constexpr since C++20
template <class T>
- basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17
- basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14
- basic_string& insert(size_type pos, const value_type* s);
- basic_string& insert(size_type pos, size_type n, value_type c);
- iterator insert(const_iterator p, value_type c);
- iterator insert(const_iterator p, size_type n, value_type c);
+ basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17, constexpr since C++20
+ basic_string& insert(size_type pos, const value_type* s, size_type n=npos); // C++14, constexpr since C++20
+ basic_string& insert(size_type pos, const value_type* s); // constexpr since C++20
+ basic_string& insert(size_type pos, size_type n, value_type c); // constexpr since C++20
+ iterator insert(const_iterator p, value_type c); // constexpr since C++20
+ iterator insert(const_iterator p, size_type n, value_type c); // constexpr since C++20
template<class InputIterator>
- iterator insert(const_iterator p, InputIterator first, InputIterator last);
- iterator insert(const_iterator p, initializer_list<value_type>);
+ iterator insert(const_iterator p, InputIterator first, InputIterator last); // constexpr since C++20
+ iterator insert(const_iterator p, initializer_list<value_type>); // constexpr since C++20
- basic_string& erase(size_type pos = 0, size_type n = npos);
- iterator erase(const_iterator position);
- iterator erase(const_iterator first, const_iterator last);
+ basic_string& erase(size_type pos = 0, size_type n = npos); // constexpr since C++20
+ iterator erase(const_iterator position); // constexpr since C++20
+ iterator erase(const_iterator first, const_iterator last); // constexpr since C++20
- basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
+ basic_string& replace(size_type pos1, size_type n1, const basic_string& str); // constexpr since C++20
template <class T>
- basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17
+ basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17, constexpr since C++20
basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
- size_type pos2, size_type n2=npos); // C++14
+ size_type pos2, size_type n2=npos); // C++14, constexpr since C++20
template <class T>
basic_string& replace(size_type pos1, size_type n1, const T& t,
- size_type pos2, size_type n); // C++17
- basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2);
- basic_string& replace(size_type pos, size_type n1, const value_type* s);
- basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);
- basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
+ size_type pos2, size_type n); // C++17, constexpr since C++20
+ basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); // constexpr since C++20
+ basic_string& replace(size_type pos, size_type n1, const value_type* s); // constexpr since C++20
+ basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); // constexpr since C++20
+ basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); // constexpr since C++20
template <class T>
- basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17
- basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n);
- basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s);
- basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c);
+ basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17, constexpr since C++20
+ basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); // constexpr since C++20
+ basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); // constexpr since C++20
+ basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); // constexpr since C++20
template<class InputIterator>
- basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
- basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>);
+ basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); // constexpr since C++20
+ basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); // constexpr since C++20
- size_type copy(value_type* s, size_type n, size_type pos = 0) const;
- basic_string substr(size_type pos = 0, size_type n = npos) const;
+ size_type copy(value_type* s, size_type n, size_type pos = 0) const; // constexpr since C++20
+ basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr since C++20
void swap(basic_string& str)
noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
- allocator_traits<allocator_type>::is_always_equal::value); // C++17
+ allocator_traits<allocator_type>::is_always_equal::value); // C++17, constexpr since C++20
- const value_type* c_str() const noexcept;
- const value_type* data() const noexcept;
- value_type* data() noexcept; // C++17
+ const value_type* c_str() const noexcept; // constexpr since C++20
+ const value_type* data() const noexcept; // constexpr since C++20
+ value_type* data() noexcept; // C++17, constexpr since C++20
- allocator_type get_allocator() const noexcept;
+ allocator_type get_allocator() const noexcept; // constexpr since C++20
- size_type find(const basic_string& str, size_type pos = 0) const noexcept;
+ size_type find(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20
template <class T>
- size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension
- size_type find(const value_type* s, size_type pos, size_type n) const noexcept;
- size_type find(const value_type* s, size_type pos = 0) const noexcept;
- size_type find(value_type c, size_type pos = 0) const noexcept;
+ size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
+ size_type find(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
+ size_type find(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20
+ size_type find(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20
- size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
+ size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20
template <class T>
- size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension
- size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;
- size_type rfind(const value_type* s, size_type pos = npos) const noexcept;
- size_type rfind(value_type c, size_type pos = npos) const noexcept;
+ size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
+ size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
+ size_type rfind(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20
+ size_type rfind(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20
- size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
+ size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20
template <class T>
- size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension
- size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept;
- size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept;
- size_type find_first_of(value_type c, size_type pos = 0) const noexcept;
+ size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
+ size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
+ size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20
+ size_type find_first_of(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20
- size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
+ size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20
template <class T>
- size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension
- size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;
- size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;
- size_type find_last_of(value_type c, size_type pos = npos) const noexcept;
+ size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension, constexpr since C++20
+ size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
+ size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20
+ size_type find_last_of(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20
- size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
+ size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20
template <class T>
- size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension
- size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
- size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept;
- size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;
+ size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
+ size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
+ size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20
+ size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20
- size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
+ size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20
template <class T>
- size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension
- size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
- size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;
- size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;
+ size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
+ size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20
+ size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20
+ size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20
- int compare(const basic_string& str) const noexcept;
+ int compare(const basic_string& str) const noexcept; // constexpr since C++20
template <class T>
- int compare(const T& t) const noexcept; // C++17, noexcept as an extension
- int compare(size_type pos1, size_type n1, const basic_string& str) const;
+ int compare(const T& t) const noexcept; // C++17, noexcept as an extension, constexpr since C++20
+ int compare(size_type pos1, size_type n1, const basic_string& str) const; // constexpr since C++20
template <class T>
- int compare(size_type pos1, size_type n1, const T& t) const; // C++17
+ int compare(size_type pos1, size_type n1, const T& t) const; // C++17, constexpr since C++20
int compare(size_type pos1, size_type n1, const basic_string& str,
- size_type pos2, size_type n2=npos) const; // C++14
+ size_type pos2, size_type n2=npos) const; // C++14, constexpr since C++20
template <class T>
int compare(size_type pos1, size_type n1, const T& t,
- size_type pos2, size_type n2=npos) const; // C++17
- int compare(const value_type* s) const noexcept;
- int compare(size_type pos1, size_type n1, const value_type* s) const;
- int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;
-
- bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
- bool starts_with(charT c) const noexcept; // C++20
- bool starts_with(const charT* s) const; // C++20
- bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
- bool ends_with(charT c) const noexcept; // C++20
- bool ends_with(const charT* s) const; // C++20
-
- constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++2b
- constexpr bool contains(charT c) const noexcept; // C++2b
- constexpr bool contains(const charT* s) const; // C++2b
-
- bool __invariants() const;
+ size_type pos2, size_type n2=npos) const; // C++17, constexpr since C++20
+ int compare(const value_type* s) const noexcept; // constexpr since C++20
+ int compare(size_type pos1, size_type n1, const value_type* s) const; // constexpr since C++20
+ int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; // constexpr since C++20
+
+ constexpr bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
+ constexpr bool starts_with(charT c) const noexcept; // C++20
+ constexpr bool starts_with(const charT* s) const; // C++20
+ constexpr bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20
+ constexpr bool ends_with(charT c) const noexcept; // C++20
+ constexpr bool ends_with(const charT* s) const; // C++20
+
+ constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++2b
+ constexpr bool contains(charT c) const noexcept; // C++2b
+ constexpr bool contains(const charT* s) const; // C++2b
};
template<class InputIterator,
@@ -349,88 +347,88 @@ basic_string(InputIterator, InputIterator, Allocator = Allocator())
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
operator+(const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs);
+ const basic_string<charT, traits, Allocator>& rhs); // constexpr since C++20
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
-operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs);
+operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); // constexpr since C++20
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
-operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
+operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
-operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
+operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); // constexpr since C++20
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
-operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);
+operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); // constexpr since C++20
template<class charT, class traits, class Allocator>
bool operator==(const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept;
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept;
+bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept;
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
bool operator< (const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept;
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
bool operator> (const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept;
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept;
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept;
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
void swap(basic_string<charT, traits, Allocator>& lhs,
basic_string<charT, traits, Allocator>& rhs)
- noexcept(noexcept(lhs.swap(rhs)));
+ noexcept(noexcept(lhs.swap(rhs))); // constexpr since C++20
template<class charT, class traits, class Allocator>
basic_istream<charT, traits>&
@@ -508,45 +506,81 @@ template <> struct hash<u16string>;
template <> struct hash<u32string>;
template <> struct hash<wstring>;
-basic_string<char> operator "" s( const char *str, size_t len ); // C++14
-basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14
-basic_string<char8_t> operator "" s( const char8_t *str, size_t len ); // C++20
-basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14
-basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14
+basic_string<char> operator "" s( const char *str, size_t len ); // C++14, constexpr since C++20
+basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14, constexpr since C++20
+constexpr basic_string<char8_t> operator "" s( const char8_t *str, size_t len ); // C++20
+basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14, constexpr since C++20
+basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14, constexpr since C++20
} // std
*/
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__debug>
-#include <__functional_base>
+#include <__format/enable_insertable.h>
+#include <__functional/hash.h>
+#include <__functional/unary_function.h>
+#include <__ios/fpos.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
#include <__iterator/wrap_iter.h>
-#include <algorithm>
-#include <compare>
+#include <__memory/allocate_at_least.h>
+#include <__memory/swap_allocator.h>
+#include <__string/char_traits.h>
+#include <__string/extern_template_lists.h>
+#include <__utility/auto_cast.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
+#include <__utility/unreachable.h>
+#include <climits>
+#include <cstdint>
#include <cstdio> // EOF
#include <cstdlib>
#include <cstring>
-#include <initializer_list>
#include <iosfwd>
-#include <iterator>
+#include <limits>
#include <memory>
#include <stdexcept>
#include <string_view>
#include <type_traits>
-#include <utility>
#include <version>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-# include <cwchar>
+# include <cwchar>
#endif
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-# include <cstdint>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <functional>
+# include <iterator>
+# include <new>
+# include <typeinfo>
+# include <utility>
+# include <vector>
#endif
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [string.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -555,68 +589,35 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-// fpos
-
-template <class _StateT>
-class _LIBCPP_TEMPLATE_VIS fpos
-{
-private:
- _StateT __st_;
- streamoff __off_;
-public:
- _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
-
- _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;}
-
- _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;}
- _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;}
-
- _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;}
- _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;}
- _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;}
- _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;}
-};
-
-template <class _StateT>
-inline _LIBCPP_INLINE_VISIBILITY
-streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
- {return streamoff(__x) - streamoff(__y);}
-
-template <class _StateT>
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
- {return streamoff(__x) == streamoff(__y);}
-
-template <class _StateT>
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
- {return streamoff(__x) != streamoff(__y);}
-
// basic_string
template<class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,
const basic_string<_CharT, _Traits, _Allocator>& __y);
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))
+extern template _LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&);
template <class _Iter>
struct __string_is_trivial_iterator : public false_type {};
@@ -635,29 +636,13 @@ struct __can_be_converted_to_string_view : public _BoolConstant<
!is_convertible<const _Tp&, const _CharT*>::value
> {};
-#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
-
-template <class _CharT, size_t = sizeof(_CharT)>
-struct __padding
-{
- unsigned char __xx[sizeof(_CharT)-1];
-};
-
-template <class _CharT>
-struct __padding<_CharT, 1>
-{
-};
-
-#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
-
#ifndef _LIBCPP_HAS_NO_CHAR8_T
typedef basic_string<char8_t> u8string;
#endif
-
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef basic_string<char16_t> u16string;
typedef basic_string<char32_t> u32string;
-#endif
+
+struct __uninitialized_size_tag {};
template<class _CharT, class _Traits, class _Allocator>
class
@@ -665,10 +650,8 @@ class
#ifndef _LIBCPP_HAS_NO_CHAR8_T
_LIBCPP_PREFERRED_NAME(u8string)
#endif
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
_LIBCPP_PREFERRED_NAME(u16string)
_LIBCPP_PREFERRED_NAME(u32string)
-#endif
basic_string
{
public:
@@ -695,10 +678,11 @@ public:
typedef __wrap_iter<pointer> iterator;
typedef __wrap_iter<const_pointer> const_iterator;
- typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
- typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
private:
+ static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits");
#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
@@ -706,62 +690,79 @@ private:
{
pointer __data_;
size_type __size_;
- size_type __cap_;
+ size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1;
+ size_type __is_long_ : 1;
};
-#ifdef _LIBCPP_BIG_ENDIAN
- static const size_type __short_mask = 0x01;
- static const size_type __long_mask = 0x1ul;
-#else // _LIBCPP_BIG_ENDIAN
- static const size_type __short_mask = 0x80;
- static const size_type __long_mask = ~(size_type(~0) >> 1);
-#endif // _LIBCPP_BIG_ENDIAN
-
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
(sizeof(__long) - 1)/sizeof(value_type) : 2};
struct __short
{
value_type __data_[__min_cap];
- struct
- : __padding<value_type>
- {
- unsigned char __size_;
- };
+ unsigned char __padding_[sizeof(value_type) - 1];
+ unsigned char __size_ : 7;
+ unsigned char __is_long_ : 1;
};
+// The __endian_factor is required because the field we use to store the size
+// has one fewer bit than it would if it were not a bitfield.
+//
+// If the LSB is used to store the short-flag in the short string representation,
+// we have to multiply the size by two when it is stored and divide it by two when
+// it is loaded to make sure that we always store an even number. In the long string
+// representation, we can ignore this because we can assume that we always allocate
+// an even amount of value_types.
+//
+// If the MSB is used for the short-flag, the max_size() is numeric_limits<size_type>::max() / 2.
+// This does not impact the short string representation, since we never need the MSB
+// for representing the size of a short string anyway.
+
+#ifdef _LIBCPP_BIG_ENDIAN
+ static const size_type __endian_factor = 2;
#else
+ static const size_type __endian_factor = 1;
+#endif
+#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+
+#ifdef _LIBCPP_BIG_ENDIAN
+ static const size_type __endian_factor = 1;
+#else
+ static const size_type __endian_factor = 2;
+#endif
+
+ // Attribute 'packed' is used to keep the layout compatible with the
+ // previous definition that did not use bit fields. This is because on
+ // some platforms bit fields have a default size rather than the actual
+ // size used, e.g., it is 4 bytes on AIX. See D128285 for details.
struct __long
{
- size_type __cap_;
+ struct _LIBCPP_PACKED {
+ size_type __is_long_ : 1;
+ size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1;
+ };
size_type __size_;
pointer __data_;
};
-#ifdef _LIBCPP_BIG_ENDIAN
- static const size_type __short_mask = 0x80;
- static const size_type __long_mask = ~(size_type(~0) >> 1);
-#else // _LIBCPP_BIG_ENDIAN
- static const size_type __short_mask = 0x01;
- static const size_type __long_mask = 0x1ul;
-#endif // _LIBCPP_BIG_ENDIAN
-
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
(sizeof(__long) - 1)/sizeof(value_type) : 2};
struct __short
{
- union
- {
- unsigned char __size_;
- value_type __lx;
+ struct _LIBCPP_PACKED {
+ unsigned char __is_long_ : 1;
+ unsigned char __size_ : 7;
};
+ char __padding_[sizeof(value_type) - 1];
value_type __data_[__min_cap];
};
#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+ static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");
+
union __ulx{__long __lx; __short __lxx;};
enum {__n_words = sizeof(__ulx) / sizeof(size_type)};
@@ -783,25 +784,47 @@ private:
__compressed_pair<__rep, allocator_type> __r_;
+ // Construct a string with the given allocator and enough storage to hold `__size` characters, but
+ // don't initialize the characters. The contents of the string, including the null terminator, must be
+ // initialized separately.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a)
+ : __r_(__default_init_tag(), __a) {
+ if (__size > max_size())
+ __throw_length_error();
+ if (__fits_in_sso(__size)) {
+ __zero();
+ __set_short_size(__size);
+ } else {
+ auto __capacity = __recommend(__size) + 1;
+ auto __allocation = __alloc_traits::allocate(__alloc(), __capacity);
+ __begin_lifetime(__allocation, __capacity);
+ __set_long_cap(__capacity);
+ __set_long_pointer(__allocation);
+ __set_long_size(__size);
+ }
+ std::__debug_db_insert_c(this);
+ }
+
public:
_LIBCPP_TEMPLATE_DATA_VIS
static const size_type npos = -1;
- _LIBCPP_INLINE_VISIBILITY basic_string()
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
#else
_NOEXCEPT;
#endif
- basic_string(const basic_string& __str);
- basic_string(const basic_string& __str, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str, const allocator_type& __a);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(basic_string&& __str)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
@@ -809,218 +832,221 @@ public:
_NOEXCEPT;
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(basic_string&& __str, const allocator_type& __a);
#endif // _LIBCPP_CXX03_LANG
template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
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));
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(const _CharT* __s, const _Allocator& __a);
#if _LIBCPP_STD_VER > 20
basic_string(nullptr_t) = delete;
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(const _CharT* __s, size_type __n);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(size_type __n, _CharT __c);
template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(size_type __n, _CharT __c, const _Allocator& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(const basic_string& __str, size_type __pos, size_type __n,
const _Allocator& __a = _Allocator());
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(const basic_string& __str, size_type __pos,
const _Allocator& __a = _Allocator());
template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(const _Tp& __t, size_type __pos, size_type __n,
const allocator_type& __a = allocator_type());
template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
!__is_same_uncvref<_Tp, basic_string>::value> >
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit basic_string(const _Tp& __t);
template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit basic_string(const _Tp& __t, const allocator_type& __a);
template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(_InputIterator __first, _InputIterator __last);
template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(initializer_list<_CharT> __il);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
#endif // _LIBCPP_CXX03_LANG
- inline ~basic_string();
+ inline _LIBCPP_CONSTEXPR_AFTER_CXX17 ~basic_string();
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }
- basic_string& operator=(const basic_string& __str);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const basic_string& __str);
- template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
- basic_string& operator=(const _Tp& __t)
- {__self_view __sv = __t; return assign(__sv);}
+ template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
+ !__is_same_uncvref<_Tp, basic_string>::value> >
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const _Tp& __t) {
+ __self_view __sv = __t;
+ return assign(__sv);
+ }
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& operator=(basic_string&& __str)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
#endif
- _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ basic_string& operator=(const value_type* __s) {return assign(__s);}
#if _LIBCPP_STD_VER > 20
basic_string& operator=(nullptr_t) = delete;
#endif
- basic_string& operator=(value_type __c);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(value_type __c);
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator begin() _NOEXCEPT
{return iterator(this, __get_pointer());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator begin() const _NOEXCEPT
{return const_iterator(this, __get_pointer());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator end() _NOEXCEPT
{return iterator(this, __get_pointer() + size());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator end() const _NOEXCEPT
{return const_iterator(this, __get_pointer() + size());}
-#else
- _LIBCPP_INLINE_VISIBILITY
- iterator begin() _NOEXCEPT
- {return iterator(__get_pointer());}
- _LIBCPP_INLINE_VISIBILITY
- const_iterator begin() const _NOEXCEPT
- {return const_iterator(__get_pointer());}
- _LIBCPP_INLINE_VISIBILITY
- iterator end() _NOEXCEPT
- {return iterator(__get_pointer() + size());}
- _LIBCPP_INLINE_VISIBILITY
- const_iterator end() const _NOEXCEPT
- {return const_iterator(__get_pointer() + size());}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_INLINE_VISIBILITY
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator cbegin() const _NOEXCEPT
{return begin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator cend() const _NOEXCEPT
{return end();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
- _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT
{return __is_long() ? __get_long_size() : __get_short_size();}
- _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();}
- _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT
- {return (__is_long() ? __get_long_cap()
- : static_cast<size_type>(__min_cap)) - 1;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type length() const _NOEXCEPT {return size();}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT {
+ return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1;
+ }
- void resize(size_type __n, value_type __c);
- _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n, value_type __c);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n) { resize(__n, value_type()); }
- void reserve(size_type __requested_capacity);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __requested_capacity);
#if _LIBCPP_STD_VER > 20
template <class _Op>
_LIBCPP_HIDE_FROM_ABI constexpr
void resize_and_overwrite(size_type __n, _Op __op) {
__resize_default_init(__n);
- __erase_to_end(_VSTD::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
+ __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
}
#endif
- _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __resize_default_init(size_type __n);
- _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
- void reserve() _NOEXCEPT {shrink_to_fit();}
- _LIBCPP_INLINE_VISIBILITY
- void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- void clear() _NOEXCEPT;
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _NOEXCEPT;
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
bool empty() const _NOEXCEPT {return size() == 0;}
- _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ const_reference operator[](size_type __pos) const _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __pos) _NOEXCEPT;
- const_reference at(size_type __n) const;
- reference at(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);
- _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const basic_string& __str) {
+ return append(__str);
+ }
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
&& !__is_same_uncvref<_Tp, basic_string >::value,
basic_string&
>
- operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);}
- _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);}
- _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;}
+ operator+=(const _Tp& __t) {
+ __self_view __sv = __t; return append(__sv);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const value_type* __s) {
+ return append(__s);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(value_type __c) {
+ push_back(__c);
+ return *this;
+ }
+
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ basic_string& operator+=(initializer_list<value_type> __il) { return append(__il); }
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& append(const basic_string& __str);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
&& !__is_same_uncvref<_Tp, basic_string>::value,
basic_string&
>
append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }
- basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -1028,11 +1054,11 @@ public:
basic_string&
>
append(const _Tp& __t, size_type __pos, size_type __n=npos);
- basic_string& append(const value_type* __s, size_type __n);
- basic_string& append(const value_type* __s);
- basic_string& append(size_type __n, value_type __c);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(size_type __n, value_type __c);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __append_default_init(size_type __n);
template<class _InputIterator>
@@ -1042,7 +1068,7 @@ public:
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
basic_string&
>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
append(_InputIterator __first, _InputIterator __last) {
const basic_string __temp(__first, __last, __alloc());
append(__temp.data(), __temp.size());
@@ -1055,41 +1081,40 @@ public:
__is_cpp17_forward_iterator<_ForwardIterator>::value,
basic_string&
>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
append(_ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
#endif // _LIBCPP_CXX03_LANG
- void push_back(value_type __c);
- _LIBCPP_INLINE_VISIBILITY
- void pop_back();
- _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type __c);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back();
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
basic_string&
>
assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& assign(const basic_string& __str) { return *this = __str; }
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& assign(basic_string&& __str)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
- {*this = _VSTD::move(__str); return *this;}
+ {*this = std::move(__str); return *this;}
#endif
- basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -1097,11 +1122,11 @@ public:
basic_string&
>
assign(const _Tp & __t, size_type __pos, size_type __n=npos);
- basic_string& assign(const value_type* __s, size_type __n);
- basic_string& assign(const value_type* __s);
- basic_string& assign(size_type __n, value_type __c);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(size_type __n, value_type __c);
template<class _InputIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
@@ -1109,7 +1134,7 @@ public:
>
assign(_InputIterator __first, _InputIterator __last);
template<class _ForwardIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -1117,15 +1142,15 @@ public:
>
assign(_ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& insert(size_type __pos1, const basic_string& __str);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -1135,22 +1160,23 @@ public:
{ __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
basic_string&
>
insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);
- basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
- basic_string& insert(size_type __pos, const value_type* __s);
- basic_string& insert(size_type __pos, size_type __n, value_type __c);
- iterator insert(const_iterator __pos, value_type __c);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, size_type __n, value_type __c);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __pos, value_type __c);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator insert(const_iterator __pos, size_type __n, value_type __c);
template<class _InputIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
@@ -1158,7 +1184,7 @@ public:
>
insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
template<class _ForwardIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -1166,45 +1192,47 @@ public:
>
insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator insert(const_iterator __pos, initializer_list<value_type> __il)
{return insert(__pos, __il.begin(), __il.end());}
#endif // _LIBCPP_CXX03_LANG
- basic_string& erase(size_type __pos = 0, size_type __n = npos);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& erase(size_type __pos = 0, size_type __n = npos);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator erase(const_iterator __pos);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator erase(const_iterator __first, const_iterator __last);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
basic_string&
>
replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); }
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
basic_string&
>
replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
- basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
- basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -1212,14 +1240,14 @@ public:
>
replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
template<class _InputIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_input_iterator<_InputIterator>::value,
@@ -1227,16 +1255,16 @@ public:
>
replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)
{return replace(__i1, __i2, __il.begin(), __il.end());}
#endif // _LIBCPP_CXX03_LANG
- size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string substr(size_type __pos = 0, size_type __n = npos) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void swap(basic_string& __str)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
@@ -1245,123 +1273,129 @@ public:
__is_nothrow_swappable<allocator_type>::value);
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const value_type* c_str() const _NOEXCEPT {return data();}
- _LIBCPP_INLINE_VISIBILITY
- const value_type* data() const _NOEXCEPT {return _VSTD::__to_address(__get_pointer());}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());}
#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
- _LIBCPP_INLINE_VISIBILITY
- value_type* data() _NOEXCEPT {return _VSTD::__to_address(__get_pointer());}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
- size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
- size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
int compare(const basic_string& __str) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -1370,7 +1404,7 @@ public:
compare(const _Tp &__t) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -1378,199 +1412,243 @@ public:
>
compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
- int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2,
+ size_type __n2 = npos) const;
template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
int
>
compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const;
- int compare(const value_type* __s) const _NOEXCEPT;
- int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(const value_type* __s) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
#if _LIBCPP_STD_VER > 17
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool starts_with(__self_view __sv) const noexcept
{ return __self_view(data(), size()).starts_with(__sv); }
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool starts_with(value_type __c) const noexcept
{ return !empty() && _Traits::eq(front(), __c); }
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool starts_with(const value_type* __s) const noexcept
{ return starts_with(__self_view(__s)); }
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool ends_with(__self_view __sv) const noexcept
{ return __self_view(data(), size()).ends_with( __sv); }
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool ends_with(value_type __c) const noexcept
{ return !empty() && _Traits::eq(back(), __c); }
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool ends_with(const value_type* __s) const noexcept
{ return ends_with(__self_view(__s)); }
#endif
#if _LIBCPP_STD_VER > 20
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool contains(__self_view __sv) const noexcept
{ return __self_view(data(), size()).contains(__sv); }
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool contains(value_type __c) const noexcept
{ return __self_view(data(), size()).contains(__c); }
- constexpr _LIBCPP_INLINE_VISIBILITY
+ constexpr _LIBCPP_HIDE_FROM_ABI
bool contains(const value_type* __s) const
{ return __self_view(data(), size()).contains(__s); }
#endif
- _LIBCPP_INLINE_VISIBILITY bool __invariants() const;
-
- _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT;
-
- _LIBCPP_INLINE_VISIBILITY void __shrink_or_extend(size_type __target_capacity);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
- _LIBCPP_INLINE_VISIBILITY
- bool __is_long() const _NOEXCEPT
- {return bool(__r_.first().__s.__size_ & __short_mask);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __clear_and_shrink() _NOEXCEPT;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
- _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) {
- // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly
- return !__libcpp_is_constant_evaluated() && (__sz < __min_cap);
+ template<class _Alloc>
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ bool friend operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs,
+ const basic_string<char, char_traits<char>, _Alloc>& __rhs) _NOEXCEPT;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __shrink_or_extend(size_type __target_capacity);
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ bool __is_long() const _NOEXCEPT {
+ if (__libcpp_is_constant_evaluated())
+ return true;
+ return __r_.first().__s.__is_long_;
}
- _LIBCPP_INLINE_VISIBILITY
- allocator_type& __alloc() _NOEXCEPT
- {return __r_.second();}
- _LIBCPP_INLINE_VISIBILITY
- const allocator_type& __alloc() const _NOEXCEPT
- {return __r_.second();}
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __begin_lifetime(pointer __begin, size_type __n) {
+#if _LIBCPP_STD_VER > 17
+ if (__libcpp_is_constant_evaluated()) {
+ for (size_type __i = 0; __i != __n; ++__i)
+ std::construct_at(std::addressof(__begin[__i]));
+ }
+#else
+ (void)__begin;
+ (void)__n;
+#endif // _LIBCPP_STD_VER > 17
+ }
-#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __default_init() {
+ __zero();
+ if (__libcpp_is_constant_evaluated()) {
+ size_type __sz = __recommend(0) + 1;
+ pointer __ptr = __alloc_traits::allocate(__alloc(), __sz);
+ __begin_lifetime(__ptr, __sz);
+ __set_long_pointer(__ptr);
+ __set_long_cap(__sz);
+ __set_long_size(0);
+ }
+ }
- _LIBCPP_INLINE_VISIBILITY
- void __set_short_size(size_type __s) _NOEXCEPT
-# ifdef _LIBCPP_BIG_ENDIAN
- {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
-# else
- {__r_.first().__s.__size_ = (unsigned char)(__s);}
-# endif
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __deallocate_constexpr() {
+ if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr)
+ __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap());
+ }
- _LIBCPP_INLINE_VISIBILITY
- size_type __get_short_size() const _NOEXCEPT
-# ifdef _LIBCPP_BIG_ENDIAN
- {return __r_.first().__s.__size_ >> 1;}
-# else
- {return __r_.first().__s.__size_;}
-# endif
+ _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) {
+ // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly
+ return !__libcpp_is_constant_evaluated() && (__sz < __min_cap);
+ }
+
+ template <class _ForwardIterator>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) {
+ size_type __sz = size();
+ size_type __cap = capacity();
+ value_type* __p;
+ if (__cap - __sz >= __n)
+ {
+ __p = std::__to_address(__get_pointer());
+ size_type __n_move = __sz - __ip;
+ if (__n_move != 0)
+ traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
+ }
+ else
+ {
+ __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
+ __p = std::__to_address(__get_long_pointer());
+ }
+ __sz += __n;
+ __set_size(__sz);
+ traits_type::assign(__p[__sz], value_type());
+ for (__p += __ip; __first != __last; ++__p, ++__first)
+ traits_type::assign(*__p, *__first);
-#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+ return begin() + __ip;
+ }
- _LIBCPP_INLINE_VISIBILITY
- void __set_short_size(size_type __s) _NOEXCEPT
-# ifdef _LIBCPP_BIG_ENDIAN
- {__r_.first().__s.__size_ = (unsigned char)(__s);}
-# else
- {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
-# endif
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); }
- _LIBCPP_INLINE_VISIBILITY
- size_type __get_short_size() const _NOEXCEPT
-# ifdef _LIBCPP_BIG_ENDIAN
- {return __r_.first().__s.__size_;}
-# else
- {return __r_.first().__s.__size_ >> 1;}
-# endif
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void __set_short_size(size_type __s) _NOEXCEPT {
+ _LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");
+ __r_.first().__s.__size_ = __s;
+ __r_.first().__s.__is_long_ = false;
+ }
-#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ size_type __get_short_size() const _NOEXCEPT {
+ _LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size");
+ return __r_.first().__s.__size_;
+ }
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __set_long_size(size_type __s) _NOEXCEPT
{__r_.first().__l.__size_ = __s;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type __get_long_size() const _NOEXCEPT
{return __r_.first().__l.__size_;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __set_size(size_type __s) _NOEXCEPT
{if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}
- _LIBCPP_INLINE_VISIBILITY
- void __set_long_cap(size_type __s) _NOEXCEPT
- {__r_.first().__l.__cap_ = __long_mask | __s;}
- _LIBCPP_INLINE_VISIBILITY
- size_type __get_long_cap() const _NOEXCEPT
- {return __r_.first().__l.__cap_ & size_type(~__long_mask);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void __set_long_cap(size_type __s) _NOEXCEPT {
+ __r_.first().__l.__cap_ = __s / __endian_factor;
+ __r_.first().__l.__is_long_ = true;
+ }
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ size_type __get_long_cap() const _NOEXCEPT {
+ return __r_.first().__l.__cap_ * __endian_factor;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __set_long_pointer(pointer __p) _NOEXCEPT
{__r_.first().__l.__data_ = __p;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
pointer __get_long_pointer() _NOEXCEPT
{return __r_.first().__l.__data_;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_pointer __get_long_pointer() const _NOEXCEPT
{return __r_.first().__l.__data_;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
pointer __get_short_pointer() _NOEXCEPT
{return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_pointer __get_short_pointer() const _NOEXCEPT
{return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
pointer __get_pointer() _NOEXCEPT
{return __is_long() ? __get_long_pointer() : __get_short_pointer();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
const_pointer __get_pointer() const _NOEXCEPT
{return __is_long() ? __get_long_pointer() : __get_short_pointer();}
- _LIBCPP_INLINE_VISIBILITY
- void __zero() _NOEXCEPT
- {
- size_type (&__a)[__n_words] = __r_.first().__r.__words;
- for (unsigned __i = 0; __i < __n_words; ++__i)
- __a[__i] = 0;
- }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void __zero() _NOEXCEPT {
+ __r_.first() = __rep();
+ }
template <size_type __a> static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type __align_it(size_type __s) _NOEXCEPT
{return (__s + (__a-1)) & ~(__a-1);}
enum {__alignment = 16};
- static _LIBCPP_INLINE_VISIBILITY
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type __recommend(size_type __s) _NOEXCEPT
- {
- if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1;
+ {
+ if (__s < __min_cap) {
+ if (__libcpp_is_constant_evaluated())
+ return static_cast<size_type>(__min_cap);
+ else
+ return static_cast<size_type>(__min_cap) - 1;
+ }
size_type __guess = __align_it<sizeof(value_type) < __alignment ?
__alignment/sizeof(value_type) : 1 > (__s+1) - 1;
if (__guess == __min_cap) ++__guess;
return __guess;
- }
+ }
- inline
+ inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void __init(const value_type* __s, size_type __sz, size_type __reserve);
- inline
+ inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void __init(const value_type* __s, size_type __sz);
- inline
+ inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void __init(size_type __n, value_type __c);
// Slow path for the (inlined) copy constructor for 'long' strings.
@@ -1581,10 +1659,10 @@ private:
// to call the __init() functions as those are marked as inline which may
// result in over-aggressive inlining by the compiler, where our aim is
// to only inline the fast path code directly in the ctor.
- void __init_copy_ctor_external(const value_type* __s, size_type __sz);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init_copy_ctor_external(const value_type* __s, size_type __sz);
template <class _InputIterator>
- inline
+ inline _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value
@@ -1592,15 +1670,17 @@ private:
__init(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
- inline
+ inline _LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value
>
__init(_ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
size_type __n_copy, size_type __n_del, size_type __n_add = 0);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
size_type __n_copy, size_type __n_del,
size_type __n_add, const value_type* __p_new_stuff);
@@ -1609,21 +1689,21 @@ private:
// have proof that the input does not alias the current instance.
// For example, operator=(basic_string) performs a 'self' check.
template <bool __is_short>
- basic_string& __assign_no_alias(const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_no_alias(const value_type* __s, size_type __n);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __erase_to_end(size_type __pos);
// __erase_external_with_move is invoked for erase() invocations where
// `n ~= npos`, likely requiring memory moves on the string data.
- void __erase_external_with_move(size_type __pos, size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __erase_external_with_move(size_type __pos, size_type __n);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const basic_string& __str)
{__copy_assign_alloc(__str, integral_constant<bool,
__alloc_traits::propagate_on_container_copy_assignment::value>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const basic_string& __str, true_type)
{
if (__alloc() == __str.__alloc())
@@ -1638,25 +1718,26 @@ private:
else
{
allocator_type __a = __str.__alloc();
- pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap());
+ auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());
+ __begin_lifetime(__allocation.ptr, __allocation.count);
__clear_and_shrink();
- __alloc() = _VSTD::move(__a);
- __set_long_pointer(__p);
- __set_long_cap(__str.__get_long_cap());
+ __alloc() = std::move(__a);
+ __set_long_pointer(__allocation.ptr);
+ __set_long_cap(__allocation.count);
__set_long_size(__str.size());
}
}
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT
{}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign(basic_string& __str, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign(basic_string& __str, true_type)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT;
@@ -1665,7 +1746,7 @@ private:
#endif
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void
__move_assign_alloc(basic_string& __str)
_NOEXCEPT_(
@@ -1674,78 +1755,83 @@ private:
{__move_assign_alloc(__str, integral_constant<bool,
__alloc_traits::propagate_on_container_move_assignment::value>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign_alloc(basic_string& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
- __alloc() = _VSTD::move(__c.__alloc());
+ __alloc() = std::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign_alloc(basic_string&, false_type)
_NOEXCEPT
{}
- basic_string& __assign_external(const value_type* __s);
- basic_string& __assign_external(const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s, size_type __n);
// Assigns the value in __s, guaranteed to be __n < __min_cap in length.
inline basic_string& __assign_short(const value_type* __s, size_type __n) {
pointer __p = __is_long()
? (__set_long_size(__n), __get_long_pointer())
: (__set_short_size(__n), __get_short_pointer());
- traits_type::move(_VSTD::__to_address(__p), __s, __n);
+ traits_type::move(std::__to_address(__p), __s, __n);
traits_type::assign(__p[__n], value_type());
return *this;
}
- _LIBCPP_HIDE_FROM_ABI basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {
__set_size(__newsz);
__invalidate_iterators_past(__newsz);
traits_type::assign(__p[__newsz], value_type());
return *this;
}
- _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
- _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type);
template<class _Tp>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
bool __addr_in_range(_Tp&& __t) const {
- const volatile void *__p = _VSTD::addressof(__t);
+ // assume that the ranges overlap, because we can't check during constant evaluation
+ if (__libcpp_is_constant_evaluated())
+ return true;
+ const volatile void *__p = std::addressof(__t);
return data() <= __p && __p <= data() + size();
}
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void __throw_length_error() const {
- _VSTD::__throw_length_error("basic_string");
+ std::__throw_length_error("basic_string");
}
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void __throw_out_of_range() const {
- _VSTD::__throw_out_of_range("basic_string");
+ std::__throw_out_of_range("basic_string");
}
- friend basic_string operator+<>(const basic_string&, const basic_string&);
- friend basic_string operator+<>(const value_type*, const basic_string&);
- friend basic_string operator+<>(value_type, const basic_string&);
- friend basic_string operator+<>(const basic_string&, const value_type*);
- friend basic_string operator+<>(const basic_string&, value_type);
+ friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const basic_string&);
+ friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const value_type*, const basic_string&);
+ friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(value_type, const basic_string&);
+ friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const value_type*);
+ friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, value_type);
};
// These declarations must appear before any functions are implicitly used
// so that they have the correct visibility specifier.
+#define _LIBCPP_DECLARE(...) extern template __VA_ARGS__;
#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
- _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
+ _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)
# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
+ _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)
# endif
#else
- _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
+ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)
# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
+ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)
# endif
#endif
+#undef _LIBCPP_DECLARE
#if _LIBCPP_STD_VER >= 17
@@ -1777,22 +1863,11 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _
#endif
template <class _CharT, class _Traits, class _Allocator>
-inline
-void
-basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
-{
-#if _LIBCPP_DEBUG_LEVEL == 2
- if (!__libcpp_is_constant_evaluated())
- __get_db()->__invalidate_all(this);
-#endif
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated()) {
__c_node* __c = __get_db()->__find_c_and_lock(this);
if (__c)
@@ -1806,7 +1881,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
{
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
- _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ std::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -1814,21 +1889,21 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
}
#else
(void)__pos;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __r_(__default_init_tag(), __default_init_tag())
{
- _VSTD::__debug_db_insert_c(this);
- __zero();
+ std::__debug_db_insert_c(this);
+ __default_init();
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
@@ -1837,15 +1912,18 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __
#endif
: __r_(__default_init_tag(), __a)
{
- _VSTD::__debug_db_insert_c(this);
- __zero();
+ std::__debug_db_insert_c(this);
+ __default_init();
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
size_type __sz,
size_type __reserve)
{
+ if (__libcpp_is_constant_evaluated())
+ __zero();
if (__reserve > max_size())
__throw_length_error();
pointer __p;
@@ -1856,20 +1934,24 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
}
else
{
- size_type __cap = __recommend(__reserve);
- __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__reserve) + 1);
+ __p = __allocation.ptr;
+ __begin_lifetime(__p, __allocation.count);
__set_long_pointer(__p);
- __set_long_cap(__cap+1);
+ __set_long_cap(__allocation.count);
__set_long_size(__sz);
}
- traits_type::copy(_VSTD::__to_address(__p), __s, __sz);
+ traits_type::copy(std::__to_address(__p), __s, __sz);
traits_type::assign(__p[__sz], value_type());
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
{
+ if (__libcpp_is_constant_evaluated())
+ __zero();
if (__sz > max_size())
__throw_length_error();
pointer __p;
@@ -1880,59 +1962,63 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
}
else
{
- size_type __cap = __recommend(__sz);
- __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);
+ __p = __allocation.ptr;
+ __begin_lifetime(__p, __allocation.count);
__set_long_pointer(__p);
- __set_long_cap(__cap+1);
+ __set_long_cap(__allocation.count);
__set_long_size(__sz);
}
- traits_type::copy(_VSTD::__to_address(__p), __s, __sz);
+ traits_type::copy(std::__to_address(__p), __s, __sz);
traits_type::assign(__p[__sz], value_type());
}
template <class _CharT, class _Traits, class _Allocator>
template <class>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
: __r_(__default_init_tag(), __a)
{
_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
__init(__s, traits_type::length(__s));
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
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);
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
: __r_(__default_init_tag(), __a)
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
__init(__s, __n);
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
: __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_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),
+ __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
__str.__get_long_size());
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(
const basic_string& __str, const allocator_type& __a)
: __r_(__default_init_tag(), __a)
@@ -1940,14 +2026,17 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
if (!__str.__is_long())
__r_.first().__r = __str.__r_.first().__r;
else
- __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()),
+ __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
__str.__get_long_size());
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
const value_type* __s, size_type __sz) {
+ if (__libcpp_is_constant_evaluated())
+ __zero();
pointer __p;
if (__fits_in_sso(__sz)) {
__p = __get_short_pointer();
@@ -1955,60 +2044,65 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
} else {
if (__sz > max_size())
__throw_length_error();
- size_t __cap = __recommend(__sz);
- __p = __alloc_traits::allocate(__alloc(), __cap + 1);
+ auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);
+ __p = __allocation.ptr;
+ __begin_lifetime(__p, __allocation.count);
__set_long_pointer(__p);
- __set_long_cap(__cap + 1);
+ __set_long_cap(__allocation.count);
__set_long_size(__sz);
}
- traits_type::copy(_VSTD::__to_address(__p), __s, __sz + 1);
+ traits_type::copy(std::__to_address(__p), __s, __sz + 1);
}
#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
#else
_NOEXCEPT
#endif
- : __r_(_VSTD::move(__str.__r_))
+ : __r_(std::move(__str.__r_))
{
- __str.__zero();
- _VSTD::__debug_db_insert_c(this);
-#if _LIBCPP_DEBUG_LEVEL == 2
- if (!__libcpp_is_constant_evaluated() && __is_long())
- __get_db()->swap(this, &__str);
-#endif
+ __str.__default_init();
+ std::__debug_db_insert_c(this);
+ if (__is_long())
+ std::__debug_db_swap(this, &__str);
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
: __r_(__default_init_tag(), __a)
{
if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
- __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
+ __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
else
{
- __r_.first().__r = __str.__r_.first().__r;
- __str.__zero();
+ if (__libcpp_is_constant_evaluated()) {
+ __zero();
+ __r_.first().__l = __str.__r_.first().__l;
+ } else {
+ __r_.first().__r = __str.__r_.first().__r;
+ }
+ __str.__default_init();
}
- _VSTD::__debug_db_insert_c(this);
-#if _LIBCPP_DEBUG_LEVEL == 2
- if (!__libcpp_is_constant_evaluated() && __is_long())
- __get_db()->swap(this, &__str);
-#endif
+ std::__debug_db_insert_c(this);
+ if (__is_long())
+ std::__debug_db_swap(this, &__str);
}
#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
{
+ if (__libcpp_is_constant_evaluated())
+ __zero();
if (__n > max_size())
__throw_length_error();
pointer __p;
@@ -2019,35 +2113,38 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
}
else
{
- size_type __cap = __recommend(__n);
- __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__n) + 1);
+ __p = __allocation.ptr;
+ __begin_lifetime(__p, __allocation.count);
__set_long_pointer(__p);
- __set_long_cap(__cap+1);
+ __set_long_cap(__allocation.count);
__set_long_size(__n);
}
- traits_type::assign(_VSTD::__to_address(__p), __n, __c);
+ traits_type::assign(std::__to_address(__p), __n, __c);
traits_type::assign(__p[__n], value_type());
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c)
: __r_(__default_init_tag(), __default_init_tag())
{
__init(__n, __c);
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
template <class>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
: __r_(__default_init_tag(), __a)
{
__init(__n, __c);
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
size_type __pos, size_type __n,
const _Allocator& __a)
@@ -2056,12 +2153,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
size_type __str_sz = __str.size();
if (__pos > __str_sz)
__throw_out_of_range();
- __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));
- _VSTD::__debug_db_insert_c(this);
+ __init(__str.data() + __pos, std::min(__n, __str_sz - __pos));
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
const _Allocator& __a)
: __r_(__default_init_tag(), __a)
@@ -2070,11 +2167,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
if (__pos > __str_sz)
__throw_out_of_range();
__init(__str.data() + __pos, __str_sz - __pos);
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(
const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
: __r_(__default_init_tag(), __a)
@@ -2082,38 +2180,41 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
__self_view __sv0 = __t;
__self_view __sv = __sv0.substr(__pos, __n);
__init(__sv.data(), __sv.size());
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
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());
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
: __r_(__default_init_tag(), __a)
{
__self_view __sv = __t;
__init(__sv.data(), __sv.size());
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value
>
basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)
{
- __zero();
+ __default_init();
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2133,13 +2234,16 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input
template <class _CharT, class _Traits, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value
>
basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
{
- size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__libcpp_is_constant_evaluated())
+ __zero();
+ size_type __sz = static_cast<size_type>(std::distance(__first, __last));
if (__sz > max_size())
__throw_length_error();
pointer __p;
@@ -2150,10 +2254,11 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
}
else
{
- size_type __cap = __recommend(__sz);
- __p = __alloc_traits::allocate(__alloc(), __cap+1);
+ auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);
+ __p = __allocation.ptr;
+ __begin_lifetime(__p, __allocation.count);
__set_long_pointer(__p);
- __set_long_cap(__cap+1);
+ __set_long_cap(__allocation.count);
__set_long_size(__sz);
}
@@ -2177,62 +2282,60 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator, class>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)
: __r_(__default_init_tag(), __default_init_tag())
{
__init(__first, __last);
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator, class>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: __r_(__default_init_tag(), __a)
{
__init(__first, __last);
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(
initializer_list<_CharT> __il)
: __r_(__default_init_tag(), __default_init_tag())
{
__init(__il.begin(), __il.end());
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
template <class _CharT, class _Traits, class _Allocator>
-inline
-
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::basic_string(
initializer_list<_CharT> __il, const _Allocator& __a)
: __r_(__default_init_tag(), __a)
{
__init(__il.begin(), __il.end());
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::~basic_string()
{
-#if _LIBCPP_DEBUG_LEVEL == 2
- if (!__libcpp_is_constant_evaluated())
- __get_db()->__erase_c(this);
-#endif
+ std::__debug_db_erase_c(this);
if (__is_long())
__alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
@@ -2243,23 +2346,25 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
__throw_length_error();
pointer __old_p = __get_pointer();
size_type __cap = __old_cap < __ms / 2 - __alignment ?
- __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
+ __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) :
__ms - 1;
- pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
- __invalidate_all_iterators();
+ auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1);
+ pointer __p = __allocation.ptr;
+ __begin_lifetime(__p, __allocation.count);
+ std::__debug_db_invalidate_all(this);
if (__n_copy != 0)
- traits_type::copy(_VSTD::__to_address(__p),
- _VSTD::__to_address(__old_p), __n_copy);
+ traits_type::copy(std::__to_address(__p),
+ std::__to_address(__old_p), __n_copy);
if (__n_add != 0)
- traits_type::copy(_VSTD::__to_address(__p) + __n_copy, __p_new_stuff, __n_add);
+ traits_type::copy(std::__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_address(__p) + __n_copy + __n_add,
- _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);
- if (__old_cap+1 != __min_cap)
+ traits_type::copy(std::__to_address(__p) + __n_copy + __n_add,
+ std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);
+ if (__old_cap+1 != __min_cap || __libcpp_is_constant_evaluated())
__alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
__set_long_pointer(__p);
- __set_long_cap(__cap+1);
+ __set_long_cap(__allocation.count);
__old_sz = __n_copy + __n_add + __sec_cp_sz;
__set_long_size(__old_sz);
traits_type::assign(__p[__old_sz], value_type());
@@ -2267,6 +2372,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
template <class _CharT, class _Traits, class _Allocator>
void
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
size_type __n_copy, size_type __n_del, size_type __n_add)
{
@@ -2275,36 +2381,39 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t
__throw_length_error();
pointer __old_p = __get_pointer();
size_type __cap = __old_cap < __ms / 2 - __alignment ?
- __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
+ __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) :
__ms - 1;
- pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
- __invalidate_all_iterators();
+ auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1);
+ pointer __p = __allocation.ptr;
+ __begin_lifetime(__p, __allocation.count);
+ std::__debug_db_invalidate_all(this);
if (__n_copy != 0)
- traits_type::copy(_VSTD::__to_address(__p),
- _VSTD::__to_address(__old_p), __n_copy);
+ traits_type::copy(std::__to_address(__p),
+ std::__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_address(__p) + __n_copy + __n_add,
- _VSTD::__to_address(__old_p) + __n_copy + __n_del,
+ traits_type::copy(std::__to_address(__p) + __n_copy + __n_add,
+ std::__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);
+ if (__libcpp_is_constant_evaluated() || __old_cap + 1 != __min_cap)
+ __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1);
__set_long_pointer(__p);
- __set_long_cap(__cap+1);
+ __set_long_cap(__allocation.count);
}
// assign
template <class _CharT, class _Traits, class _Allocator>
template <bool __is_short>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
const value_type* __s, size_type __n) {
- size_type __cap = __is_short ? __min_cap : __get_long_cap();
+ size_type __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap();
if (__n < __cap) {
pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer();
__is_short ? __set_short_size(__n) : __set_long_size(__n);
- traits_type::copy(_VSTD::__to_address(__p), __s, __n);
+ traits_type::copy(std::__to_address(__p), __s, __n);
traits_type::assign(__p[__n], value_type());
__invalidate_iterators_past(__n);
} else {
@@ -2315,12 +2424,13 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::__assign_external(
const value_type* __s, size_type __n) {
size_type __cap = capacity();
if (__cap >= __n) {
- value_type* __p = _VSTD::__to_address(__get_pointer());
+ value_type* __p = std::__to_address(__get_pointer());
traits_type::move(__p, __s, __n);
return __null_terminate_at(__p, __n);
} else {
@@ -2331,6 +2441,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external(
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
{
@@ -2341,6 +2452,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
{
@@ -2350,12 +2462,13 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
size_type __sz = size();
__grow_by(__cap, __n - __cap, __sz, 0, __sz);
}
- value_type* __p = _VSTD::__to_address(__get_pointer());
+ value_type* __p = std::__to_address(__get_pointer());
traits_type::assign(__p, __n, __c);
return __null_terminate_at(__p, __n);
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
{
@@ -2377,6 +2490,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
{
@@ -2398,7 +2512,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value)
@@ -2410,7 +2524,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
#if _LIBCPP_STD_VER > 14
@@ -2431,12 +2545,16 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
}
__move_assign_alloc(__str);
__r_.first() = __str.__r_.first();
- __str.__set_short_size(0);
- traits_type::assign(__str.__get_short_pointer()[0], value_type());
+ if (__libcpp_is_constant_evaluated()) {
+ __str.__default_init();
+ } else {
+ __str.__set_short_size(0);
+ traits_type::assign(__str.__get_short_pointer()[0], value_type());
+ }
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
@@ -2450,6 +2568,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)
template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
@@ -2464,6 +2583,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input
template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2473,7 +2593,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
{
size_type __cap = capacity();
size_type __n = __string_is_trivial_iterator<_ForwardIterator>::value ?
- static_cast<size_type>(_VSTD::distance(__first, __last)) : 0;
+ static_cast<size_type>(std::distance(__first, __last)) : 0;
if (__string_is_trivial_iterator<_ForwardIterator>::value &&
(__cap >= __n || !__addr_in_range(*__first)))
@@ -2499,17 +2619,19 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
{
size_type __sz = __str.size();
if (__pos > __sz)
__throw_out_of_range();
- return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
+ return assign(__str.data() + __pos, std::min(__n, __sz - __pos));
}
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -2522,17 +2644,19 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p
size_type __sz = __sv.size();
if (__pos > __sz)
__throw_out_of_range();
- return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));
+ return assign(__sv.data() + __pos, std::min(__n, __sz - __pos));
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {
return __assign_external(__s, traits_type::length(__s));
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
{
@@ -2546,6 +2670,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
// append
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
{
@@ -2556,7 +2681,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
{
if (__n)
{
- value_type* __p = _VSTD::__to_address(__get_pointer());
+ value_type* __p = std::__to_address(__get_pointer());
traits_type::copy(__p + __sz, __s, __n);
__sz += __n;
__set_size(__sz);
@@ -2569,6 +2694,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
{
@@ -2579,7 +2705,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_address(__p) + __sz, __n, __c);
+ traits_type::assign(std::__to_address(__p) + __sz, __n, __c);
__sz += __n;
__set_size(__sz);
traits_type::assign(__p[__sz], value_type());
@@ -2588,7 +2714,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
}
template <class _CharT, class _Traits, class _Allocator>
-inline void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void
basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
{
if (__n)
@@ -2605,6 +2731,7 @@ basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
{
@@ -2626,7 +2753,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
__grow_by(__cap, 1, __sz, __sz, 0);
__is_short = false; // the string is always long after __grow_by
}
- pointer __p;
+ pointer __p = __get_pointer();
if (__is_short)
{
__p = __get_short_pointer() + __sz;
@@ -2643,6 +2770,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2653,7 +2781,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(
{
size_type __sz = size();
size_type __cap = capacity();
- size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+ size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n)
{
if (__string_is_trivial_iterator<_ForwardIterator>::value &&
@@ -2677,7 +2805,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)
{
@@ -2685,17 +2813,19 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)
{
size_type __sz = __str.size();
if (__pos > __sz)
__throw_out_of_range();
- return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
+ return append(__str.data() + __pos, std::min(__n, __sz - __pos));
}
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
@@ -2707,10 +2837,11 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p
size_type __sz = __sv.size();
if (__pos > __sz)
__throw_out_of_range();
- return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));
+ return append(__sv.data() + __pos, std::min(__n, __sz - __pos));
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
{
@@ -2721,6 +2852,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
// insert
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
{
@@ -2729,11 +2861,18 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
if (__pos > __sz)
__throw_out_of_range();
size_type __cap = capacity();
+ if (__libcpp_is_constant_evaluated()) {
+ if (__cap - __sz >= __n)
+ __grow_by_and_replace(__cap, 0, __sz, __pos, 0, __n, __s);
+ else
+ __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s);
+ return *this;
+ }
if (__cap - __sz >= __n)
{
if (__n)
{
- value_type* __p = _VSTD::__to_address(__get_pointer());
+ value_type* __p = std::__to_address(__get_pointer());
size_type __n_move = __sz - __pos;
if (__n_move != 0)
{
@@ -2753,6 +2892,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)
{
@@ -2765,7 +2905,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
value_type* __p;
if (__cap - __sz >= __n)
{
- __p = _VSTD::__to_address(__get_pointer());
+ __p = std::__to_address(__get_pointer());
size_type __n_move = __sz - __pos;
if (__n_move != 0)
traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
@@ -2773,7 +2913,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_address(__get_long_pointer());
+ __p = std::__to_address(__get_long_pointer());
}
traits_type::assign(__p + __pos, __n, __c);
__sz += __n;
@@ -2785,6 +2925,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
@@ -2801,6 +2942,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt
template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2808,49 +2950,27 @@ __enable_if_t
>
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
{
- _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
- "string::insert(iterator, range) called with an iterator not"
- " referring to this string");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+ "string::insert(iterator, range) called with an iterator not referring to this string");
size_type __ip = static_cast<size_type>(__pos - begin());
- size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
- if (__n)
+ size_type __n = static_cast<size_type>(std::distance(__first, __last));
+ if (__n == 0)
+ return begin() + __ip;
+
+ if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first))
{
- if (__string_is_trivial_iterator<_ForwardIterator>::value &&
- !__addr_in_range(*__first))
- {
- size_type __sz = size();
- size_type __cap = capacity();
- value_type* __p;
- if (__cap - __sz >= __n)
- {
- __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);
- }
- else
- {
- __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
- __p = _VSTD::__to_address(__get_long_pointer());
- }
- __sz += __n;
- __set_size(__sz);
- traits_type::assign(__p[__sz], value_type());
- for (__p += __ip; __first != __last; ++__p, (void) ++__first)
- traits_type::assign(*__p, *__first);
- }
- else
- {
- const basic_string __temp(__first, __last, __alloc());
- return insert(__pos, __temp.data(), __temp.data() + __temp.size());
- }
+ return __insert_from_safe_copy(__n, __ip, __first, __last);
+ }
+ else
+ {
+ const basic_string __temp(__first, __last, __alloc());
+ return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end());
}
- return begin() + __ip;
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str)
{
@@ -2858,6 +2978,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,
size_type __pos2, size_type __n)
@@ -2865,11 +2986,12 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_
size_type __str_sz = __str.size();
if (__pos2 > __str_sz)
__throw_out_of_range();
- return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
+ return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2));
}
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
@@ -2882,10 +3004,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _
size_type __str_sz = __sv.size();
if (__pos2 > __str_sz)
__throw_out_of_range();
- return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
+ return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2));
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
{
@@ -2894,6 +3017,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
{
@@ -2908,11 +3032,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_address(__get_long_pointer());
+ __p = std::__to_address(__get_long_pointer());
}
else
{
- __p = _VSTD::__to_address(__get_pointer());
+ __p = std::__to_address(__get_pointer());
size_type __n_move = __sz - __ip;
if (__n_move != 0)
traits_type::move(__p + __ip + 1, __p + __ip, __n_move);
@@ -2924,7 +3048,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)
{
@@ -2939,6 +3063,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_typ
// replace
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
@@ -2947,11 +3072,15 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
size_type __sz = size();
if (__pos > __sz)
__throw_out_of_range();
- __n1 = _VSTD::min(__n1, __sz - __pos);
+ __n1 = std::min(__n1, __sz - __pos);
size_type __cap = capacity();
if (__cap - __sz + __n1 >= __n2)
{
- value_type* __p = _VSTD::__to_address(__get_pointer());
+ if (__libcpp_is_constant_evaluated()) {
+ __grow_by_and_replace(__cap, 0, __sz, __pos, __n1, __n2, __s);
+ return *this;
+ }
+ value_type* __p = std::__to_address(__get_pointer());
if (__n1 != __n2)
{
size_type __n_move = __sz - __pos - __n1;
@@ -2988,18 +3117,19 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)
{
size_type __sz = size();
if (__pos > __sz)
__throw_out_of_range();
- __n1 = _VSTD::min(__n1, __sz - __pos);
+ __n1 = std::min(__n1, __sz - __pos);
size_type __cap = capacity();
value_type* __p;
if (__cap - __sz + __n1 >= __n2)
{
- __p = _VSTD::__to_address(__get_pointer());
+ __p = std::__to_address(__get_pointer());
if (__n1 != __n2)
{
size_type __n_move = __sz - __pos - __n1;
@@ -3010,7 +3140,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_address(__get_long_pointer());
+ __p = std::__to_address(__get_long_pointer());
}
traits_type::assign(__p + __pos, __n2, __c);
return __null_terminate_at(__p, __sz - (__n1 - __n2));
@@ -3018,6 +3148,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__is_cpp17_input_iterator<_InputIterator>::value,
@@ -3031,7 +3162,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str)
{
@@ -3039,6 +3170,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,
size_type __pos2, size_type __n2)
@@ -3046,11 +3178,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
size_type __str_sz = __str.size();
if (__pos2 > __str_sz)
__throw_out_of_range();
- return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
+ return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2));
}
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
@@ -3063,10 +3196,11 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
size_type __str_sz = __sv.size();
if (__pos2 > __str_sz)
__throw_out_of_range();
- return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
+ return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2));
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
{
@@ -3075,7 +3209,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str)
{
@@ -3084,7 +3218,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n)
{
@@ -3092,7 +3226,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s)
{
@@ -3100,7 +3234,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c)
{
@@ -3112,6 +3246,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
// 'externally instantiated' erase() implementation, called when __n != npos.
// Does not check __pos against size()
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
size_type __pos, size_type __n)
@@ -3119,8 +3254,8 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
if (__n)
{
size_type __sz = size();
- value_type* __p = _VSTD::__to_address(__get_pointer());
- __n = _VSTD::min(__n, __sz - __pos);
+ value_type* __p = std::__to_address(__get_pointer());
+ __n = std::min(__n, __sz - __pos);
size_type __n_move = __sz - __pos - __n;
if (__n_move != 0)
traits_type::move(__p + __pos, __p + __pos + __n, __n_move);
@@ -3129,6 +3264,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
size_type __n) {
@@ -3143,7 +3279,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
{
@@ -3159,7 +3295,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
@@ -3175,7 +3311,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::pop_back()
{
@@ -3184,11 +3320,11 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back()
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
{
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
if (__is_long())
{
traits_type::assign(*__get_long_pointer(), value_type());
@@ -3202,14 +3338,15 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos)
{
- __null_terminate_at(_VSTD::__to_address(__get_pointer()), __pos);
+ __null_terminate_at(std::__to_address(__get_pointer()), __pos);
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
{
@@ -3221,7 +3358,7 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
}
template <class _CharT, class _Traits, class _Allocator>
-inline void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void
basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
{
size_type __sz = size();
@@ -3232,19 +3369,21 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
{
size_type __m = __alloc_traits::max_size(__alloc());
-#ifdef _LIBCPP_BIG_ENDIAN
- return (__m <= ~__long_mask ? __m : __m/2) - __alignment;
-#else
- return __m - __alignment;
-#endif
+ if (__m <= std::numeric_limits<size_type>::max() / 2) {
+ return __m - __alignment;
+ } else {
+ bool __uses_lsb = __endian_factor == 2;
+ return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;
+ }
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
{
@@ -3257,7 +3396,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit
if (__requested_capacity <= capacity())
return;
- size_type __target_capacity = _VSTD::max(__requested_capacity, size());
+ size_type __target_capacity = std::max(__requested_capacity, size());
__target_capacity = __recommend(__target_capacity);
if (__target_capacity == capacity()) return;
@@ -3265,7 +3404,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@@ -3276,7 +3415,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)
{
@@ -3285,7 +3424,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
pointer __new_data, __p;
bool __was_long, __now_long;
- if (__target_capacity == __min_cap - 1)
+ if (__fits_in_sso(__target_capacity))
{
__was_long = true;
__now_long = false;
@@ -3294,15 +3433,20 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
}
else
{
- if (__target_capacity > __cap)
- __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
+ if (__target_capacity > __cap) {
+ auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1);
+ __new_data = __allocation.ptr;
+ __target_capacity = __allocation.count - 1;
+ }
else
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
- __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
+ auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1);
+ __new_data = __allocation.ptr;
+ __target_capacity = __allocation.count - 1;
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3314,12 +3458,13 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
return;
#endif // _LIBCPP_NO_EXCEPTIONS
}
+ __begin_lifetime(__new_data, __target_capacity + 1);
__now_long = true;
__was_long = __is_long();
__p = __get_pointer();
}
- traits_type::copy(_VSTD::__to_address(__new_data),
- _VSTD::__to_address(__p), size()+1);
+ traits_type::copy(std::__to_address(__new_data),
+ std::__to_address(__p), size()+1);
if (__was_long)
__alloc_traits::deallocate(__alloc(), __p, __cap+1);
if (__now_long)
@@ -3330,11 +3475,11 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
}
else
__set_short_size(__sz);
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::const_reference
basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT
{
@@ -3343,7 +3488,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NO
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::reference
basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT
{
@@ -3352,6 +3497,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::const_reference
basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
{
@@ -3361,6 +3507,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::reference
basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
{
@@ -3370,7 +3517,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::reference
basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT
{
@@ -3379,7 +3526,7 @@ basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::const_reference
basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT
{
@@ -3388,7 +3535,7 @@ basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::reference
basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT
{
@@ -3397,7 +3544,7 @@ basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::const_reference
basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT
{
@@ -3406,19 +3553,20 @@ basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const
{
size_type __sz = size();
if (__pos > __sz)
__throw_out_of_range();
- size_type __rlen = _VSTD::min(__n, __sz - __pos);
+ size_type __rlen = std::min(__n, __sz - __pos);
traits_type::copy(__s, data() + __pos, __rlen);
return __rlen;
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const
{
@@ -3426,7 +3574,7 @@ basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
#if _LIBCPP_STD_VER >= 14
@@ -3436,21 +3584,18 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
__is_nothrow_swappable<allocator_type>::value)
#endif
{
-#if _LIBCPP_DEBUG_LEVEL == 2
- if (!__libcpp_is_constant_evaluated()) {
- if (!__is_long())
- __get_db()->__invalidate_all(this);
- if (!__str.__is_long())
- __get_db()->__invalidate_all(&__str);
- __get_db()->swap(this, &__str);
- }
-#endif
+ if (!__is_long())
+ std::__debug_db_invalidate_all(this);
+ if (!__str.__is_long())
+ std::__debug_db_invalidate_all(&__str);
+ std::__debug_db_swap(this, &__str);
+
_LIBCPP_ASSERT(
__alloc_traits::propagate_on_container_swap::value ||
__alloc_traits::is_always_equal::value ||
__alloc() == __str.__alloc(), "swapping non-equal allocators");
- _VSTD::swap(__r_.first(), __str.__r_.first());
- _VSTD::__swap_allocator(__alloc(), __str.__alloc());
+ std::swap(__r_.first(), __str.__r_.first());
+ std::__swap_allocator(__alloc(), __str.__alloc());
}
// find
@@ -3459,12 +3604,13 @@ template <class _Traits>
struct _LIBCPP_HIDDEN __traits_eq
{
typedef typename _Traits::char_type char_type;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT
{return _Traits::eq(__x, __y);}
};
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
size_type __pos,
@@ -3476,7 +3622,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
size_type __pos) const _NOEXCEPT
@@ -3487,6 +3633,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
template<class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3501,7 +3648,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
size_type __pos) const _NOEXCEPT
@@ -3512,6 +3659,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
}
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
size_type __pos) const _NOEXCEPT
@@ -3523,6 +3671,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
// rfind
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
size_type __pos,
@@ -3534,7 +3683,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
size_type __pos) const _NOEXCEPT
@@ -3545,6 +3694,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
template<class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3559,7 +3709,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
size_type __pos) const _NOEXCEPT
@@ -3570,6 +3720,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
}
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
size_type __pos) const _NOEXCEPT
@@ -3581,6 +3732,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
// find_first_of
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
size_type __pos,
@@ -3592,7 +3744,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,
size_type __pos) const _NOEXCEPT
@@ -3603,6 +3755,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s
template<class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3617,7 +3770,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
size_type __pos) const _NOEXCEPT
@@ -3628,7 +3781,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
size_type __pos) const _NOEXCEPT
@@ -3639,6 +3792,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
// find_last_of
template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
size_type __pos,
@@ -3650,7 +3804,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,
size_type __pos) const _NOEXCEPT
@@ -3661,6 +3815,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st
template<class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3675,7 +3830,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
size_type __pos) const _NOEXCEPT
@@ -3686,7 +3841,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
size_type __pos) const _NOEXCEPT
@@ -3697,6 +3852,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
// find_first_not_of
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
size_type __pos,
@@ -3708,7 +3864,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,
size_type __pos) const _NOEXCEPT
@@ -3719,6 +3875,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string&
template<class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3733,7 +3890,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
size_type __pos) const _NOEXCEPT
@@ -3744,7 +3901,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
size_type __pos) const _NOEXCEPT
@@ -3756,6 +3913,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
// find_last_not_of
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
size_type __pos,
@@ -3767,7 +3925,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,
size_type __pos) const _NOEXCEPT
@@ -3778,6 +3936,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string&
template<class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3792,7 +3951,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
size_type __pos) const _NOEXCEPT
@@ -3803,7 +3962,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
size_type __pos) const _NOEXCEPT
@@ -3816,6 +3975,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3827,7 +3987,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE
size_t __lhs_sz = size();
size_t __rhs_sz = __sv.size();
int __result = traits_type::compare(data(), __sv.data(),
- _VSTD::min(__lhs_sz, __rhs_sz));
+ std::min(__lhs_sz, __rhs_sz));
if (__result != 0)
return __result;
if (__lhs_sz < __rhs_sz)
@@ -3838,7 +3998,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
int
basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT
{
@@ -3846,6 +4006,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co
}
template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
int
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
@@ -3856,8 +4017,8 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __sz = size();
if (__pos1 > __sz || __n2 == npos)
__throw_out_of_range();
- size_type __rlen = _VSTD::min(__n1, __sz - __pos1);
- int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2));
+ size_type __rlen = std::min(__n1, __sz - __pos1);
+ int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2));
if (__r == 0)
{
if (__rlen < __n2)
@@ -3870,6 +4031,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3884,7 +4046,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
}
template <class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
int
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
@@ -3895,6 +4057,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -3912,6 +4075,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
int
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
@@ -3923,6 +4087,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
int
basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
{
@@ -3931,6 +4096,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const
}
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
int
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
@@ -3943,7 +4109,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
// __invariants
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
basic_string<_CharT, _Traits, _Allocator>::__invariants() const
{
@@ -3961,7 +4127,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const
// __clear_and_shrink
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
{
@@ -3978,7 +4144,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
// operator==
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -3990,7 +4156,7 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
@@ -4009,7 +4175,7 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator==(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4022,7 +4188,7 @@ operator==(const _CharT* __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4035,7 +4201,7 @@ operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4044,7 +4210,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator!=(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4053,7 +4219,7 @@ operator!=(const _CharT* __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4064,7 +4230,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
// operator<
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4073,7 +4239,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4082,7 +4248,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator< (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4093,7 +4259,7 @@ operator< (const _CharT* __lhs,
// operator>
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4102,7 +4268,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4111,7 +4277,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator> (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4122,7 +4288,7 @@ operator> (const _CharT* __lhs,
// operator<=
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4131,7 +4297,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4140,7 +4306,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator<=(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4151,7 +4317,7 @@ operator<=(const _CharT* __lhs,
// operator>=
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4160,7 +4326,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4169,7 +4335,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
bool
operator>=(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4180,123 +4346,152 @@ operator>=(const _CharT* __lhs,
// operator +
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
- basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
- typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
- typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
- __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);
- __r.append(__rhs.data(), __rhs_sz);
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ auto __lhs_sz = __lhs.size();
+ auto __rhs_sz = __rhs.size();
+ _String __r(__uninitialized_size_tag(),
+ __lhs_sz + __rhs_sz,
+ _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
+ auto __ptr = std::__to_address(__r.__get_pointer());
+ _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
+ _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
+ _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
return __r;
}
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)
{
- basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator());
- typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs);
- typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
- __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz);
- __r.append(__rhs.data(), __rhs_sz);
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ auto __lhs_sz = _Traits::length(__lhs);
+ auto __rhs_sz = __rhs.size();
+ _String __r(__uninitialized_size_tag(),
+ __lhs_sz + __rhs_sz,
+ _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
+ auto __ptr = std::__to_address(__r.__get_pointer());
+ _Traits::copy(__ptr, __lhs, __lhs_sz);
+ _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
+ _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
return __r;
}
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
{
- basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator());
- typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
- __r.__init(&__lhs, 1, 1 + __rhs_sz);
- __r.append(__rhs.data(), __rhs_sz);
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ typename _String::size_type __rhs_sz = __rhs.size();
+ _String __r(__uninitialized_size_tag(),
+ __rhs_sz + 1,
+ _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
+ auto __ptr = std::__to_address(__r.__get_pointer());
+ _Traits::assign(__ptr, 1, __lhs);
+ _Traits::copy(__ptr + 1, __rhs.data(), __rhs_sz);
+ _Traits::assign(__ptr + 1 + __rhs_sz, 1, _CharT());
return __r;
}
template<class _CharT, class _Traits, class _Allocator>
-inline
+inline _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)
{
- basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
- typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
- typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs);
- __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);
- __r.append(__rhs, __rhs_sz);
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ typename _String::size_type __lhs_sz = __lhs.size();
+ typename _String::size_type __rhs_sz = _Traits::length(__rhs);
+ _String __r(__uninitialized_size_tag(),
+ __lhs_sz + __rhs_sz,
+ _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
+ auto __ptr = std::__to_address(__r.__get_pointer());
+ _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
+ _Traits::copy(__ptr + __lhs_sz, __rhs, __rhs_sz);
+ _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
return __r;
}
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
{
- basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
- typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
- __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1);
- __r.push_back(__rhs);
+ using _String = basic_string<_CharT, _Traits, _Allocator>;
+ typename _String::size_type __lhs_sz = __lhs.size();
+ _String __r(__uninitialized_size_tag(),
+ __lhs_sz + 1,
+ _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
+ auto __ptr = std::__to_address(__r.__get_pointer());
+ _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
+ _Traits::assign(__ptr + __lhs_sz, 1, __rhs);
+ _Traits::assign(__ptr + 1 + __lhs_sz, 1, _CharT());
return __r;
}
#ifndef _LIBCPP_CXX03_LANG
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
- return _VSTD::move(__lhs.append(__rhs));
+ return std::move(__lhs.append(__rhs));
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
{
- return _VSTD::move(__rhs.insert(0, __lhs));
+ return std::move(__rhs.insert(0, __lhs));
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
{
- return _VSTD::move(__lhs.append(__rhs));
+ return std::move(__lhs.append(__rhs));
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
{
- return _VSTD::move(__rhs.insert(0, __lhs));
+ return std::move(__rhs.insert(0, __lhs));
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
{
__rhs.insert(__rhs.begin(), __lhs);
- return _VSTD::move(__rhs);
+ return std::move(__rhs);
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)
{
- return _VSTD::move(__lhs.append(__rhs));
+ return std::move(__lhs.append(__rhs));
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<_CharT, _Traits, _Allocator>
operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
{
__lhs.push_back(__rhs);
- return _VSTD::move(__lhs);
+ return std::move(__lhs);
}
#endif // _LIBCPP_CXX03_LANG
@@ -4304,7 +4499,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
// swap
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
basic_string<_CharT, _Traits, _Allocator>& __rhs)
@@ -4363,15 +4558,13 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type
template <class _CharT, class _Allocator>
struct _LIBCPP_TEMPLATE_VIS
hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> >
- : public unary_function<
- basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
+ : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
{
size_t
operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT
{ return __do_string_hash(__val.data(), __val.data() + __val.size()); }
};
-
template<class _CharT, class _Traits, class _Allocator>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
@@ -4388,68 +4581,68 @@ getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str);
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>&& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>&& __is,
basic_string<_CharT, _Traits, _Allocator>& __str);
#if _LIBCPP_STD_VER > 17
template <class _CharT, class _Traits, class _Allocator, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename basic_string<_CharT, _Traits, _Allocator>::size_type
erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {
auto __old_size = __str.size();
- __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end());
+ __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end());
return __old_size - __str.size();
}
template <class _CharT, class _Traits, class _Allocator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename basic_string<_CharT, _Traits, _Allocator>::size_type
erase_if(basic_string<_CharT, _Traits, _Allocator>& __str,
_Predicate __pred) {
auto __old_size = __str.size();
- __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred),
+ __str.erase(std::remove_if(__str.begin(), __str.end(), __pred),
__str.end());
return __old_size - __str.size();
}
#endif
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
template<class _CharT, class _Traits, class _Allocator>
bool
basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const
{
- return data() <= _VSTD::__to_address(__i->base()) &&
- _VSTD::__to_address(__i->base()) < data() + size();
+ return data() <= std::__to_address(__i->base()) &&
+ std::__to_address(__i->base()) < data() + size();
}
template<class _CharT, class _Traits, class _Allocator>
bool
basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const
{
- return data() < _VSTD::__to_address(__i->base()) &&
- _VSTD::__to_address(__i->base()) <= data() + size();
+ return data() < std::__to_address(__i->base()) &&
+ std::__to_address(__i->base()) <= data() + 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_address(__i->base()) + __n;
+ const value_type* __p = std::__to_address(__i->base()) + __n;
return data() <= __p && __p <= data() + size();
}
@@ -4457,11 +4650,11 @@ 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_address(__i->base()) + __n;
+ const value_type* __p = std::__to_address(__i->base()) + __n;
return data() <= __p && __p < data() + size();
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
#if _LIBCPP_STD_VER > 11
// Literal suffixes for basic_string [basic.string.literals]
@@ -4469,14 +4662,14 @@ inline namespace literals
{
inline namespace string_literals
{
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<char> operator "" s( const char *__str, size_t __len )
{
return basic_string<char> (__str, __len);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
{
return basic_string<wchar_t> (__str, __len);
@@ -4484,26 +4677,36 @@ inline namespace literals
#endif
#ifndef _LIBCPP_HAS_NO_CHAR8_T
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI constexpr
basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
{
return basic_string<char8_t> (__str, __len);
}
#endif
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
{
return basic_string<char16_t> (__str, __len);
}
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
{
return basic_string<char32_t> (__str, __len);
}
} // namespace string_literals
} // namespace literals
+
+#if _LIBCPP_STD_VER > 17
+template <>
+inline constexpr bool __format::__enable_insertable<std::basic_string<char>> = true;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+inline constexpr bool __format::__enable_insertable<std::basic_string<wchar_t>> = true;
+#endif
+#endif
+
#endif
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/string.h
@@ -54,7 +54,7 @@ size_t strlen(const char* s);
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <string.h>
lib/libcxx/include/string_view
@@ -11,7 +11,8 @@
#define _LIBCPP_STRING_VIEW
/*
-string_view synopsis
+
+ string_view synopsis
namespace std {
@@ -195,25 +196,48 @@ namespace std {
*/
+#include <__algorithm/min.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__debug>
+#include <__functional/hash.h>
+#include <__functional/unary_function.h>
+#include <__fwd/string_view.h>
+#include <__iterator/concepts.h>
+#include <__iterator/readable_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__memory/pointer_traits.h>
#include <__ranges/concepts.h>
#include <__ranges/data.h>
#include <__ranges/enable_borrowed_range.h>
#include <__ranges/enable_view.h>
#include <__ranges/size.h>
-#include <__string>
-#include <algorithm>
-#include <compare>
+#include <__string/char_traits.h>
#include <iosfwd>
-#include <iterator>
#include <limits>
#include <stdexcept>
#include <type_traits>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <functional>
+# include <iterator>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [string.view.synop]
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -222,18 +246,14 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-template<class _CharT, class _Traits = char_traits<_CharT> >
- class _LIBCPP_TEMPLATE_VIS basic_string_view;
-
-typedef basic_string_view<char> string_view;
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
-typedef basic_string_view<char8_t> u8string_view;
-#endif
-typedef basic_string_view<char16_t> u16string_view;
-typedef basic_string_view<char32_t> u32string_view;
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-typedef basic_string_view<wchar_t> wstring_view;
-#endif
+// TODO: This is a workaround for some vendors to carry a downstream diff to accept `nullptr` in
+// string_view constructors. This can be refactored when this exact form isn't needed anymore.
+template <class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT {
+ // This needs to be a single statement for C++11 constexpr
+ return _LIBCPP_ASSERT(__s != nullptr, "null pointer passed to non-null argument of char_traits<...>::length"), _Traits::length(__s);
+}
template<class _CharT, class _Traits>
class
@@ -286,7 +306,7 @@ public:
#endif
}
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
@@ -294,9 +314,9 @@ public:
{
_LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
}
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
-#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
template <class _Range>
requires (
!is_same_v<remove_cvref_t<_Range>, basic_string_view> &&
@@ -304,8 +324,8 @@ public:
ranges::sized_range<_Range> &&
is_same_v<ranges::range_value_t<_Range>, _CharT> &&
!is_convertible_v<_Range, const _CharT*> &&
- (!requires(remove_cvref_t<_Range>& d) {
- d.operator _VSTD::basic_string_view<_CharT, _Traits>();
+ (!requires(remove_cvref_t<_Range>& __d) {
+ __d.operator _VSTD::basic_string_view<_CharT, _Traits>();
}) &&
(!requires {
typename remove_reference_t<_Range>::traits_type;
@@ -313,7 +333,7 @@ public:
)
constexpr _LIBCPP_HIDE_FROM_ABI
basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {}
-#endif
+#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view(const _CharT* __s)
@@ -707,26 +727,26 @@ private:
size_type __size;
};
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <class _CharT, class _Traits>
inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;
template <class _CharT, class _Traits>
inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
// [string.view.deduct]
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
-#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
template <ranges::contiguous_range _Range>
basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;
-#endif
+#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
// [string.view.comparison]
// operator ==
@@ -900,7 +920,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
// [string.view.hash]
template<class _CharT>
struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
- : public unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
+ : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
@@ -908,7 +928,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> >
}
};
-
#if _LIBCPP_STD_VER > 11
inline namespace literals
{
lib/libcxx/include/strstream
@@ -129,13 +129,14 @@ private:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <istream>
#include <ostream>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -265,8 +266,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
istrstream& operator=(istrstream&& __rhs)
{
- istream::operator=(_VSTD::move(__rhs));
__sb_ = _VSTD::move(__rhs.__sb_);
+ istream::operator=(_VSTD::move(__rhs));
return *this;
}
#endif // _LIBCPP_CXX03_LANG
@@ -314,8 +315,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
ostrstream& operator=(ostrstream&& __rhs)
{
- ostream::operator=(_VSTD::move(__rhs));
__sb_ = _VSTD::move(__rhs.__sb_);
+ ostream::operator=(_VSTD::move(__rhs));
return *this;
}
#endif // _LIBCPP_CXX03_LANG
@@ -374,8 +375,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
strstream& operator=(strstream&& __rhs)
{
- iostream::operator=(_VSTD::move(__rhs));
__sb_ = _VSTD::move(__rhs.__sb_);
+ iostream::operator=(_VSTD::move(__rhs));
return *this;
}
#endif // _LIBCPP_CXX03_LANG
lib/libcxx/include/system_error
@@ -142,18 +142,21 @@ template <> struct hash<std::error_condition>;
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__errc>
+#include <__functional/hash.h>
#include <__functional/unary_function.h>
-#include <__functional_base>
-#include <compare>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <version>
+// standard-mandated includes
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -184,7 +187,7 @@ template <>
struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc>
: true_type { };
-#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+#ifdef _LIBCPP_CXX03_LANG
template <>
struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx>
: true_type { };
@@ -202,9 +205,8 @@ class _LIBCPP_TYPE_VIS error_category
public:
virtual ~error_category() _NOEXCEPT;
-#if defined(_LIBCPP_BUILDING_LIBRARY) && \
- defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
- error_category() _NOEXCEPT;
+#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS)
+ error_category() noexcept;
#else
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default;
@@ -234,7 +236,7 @@ class _LIBCPP_HIDDEN __do_message
: public error_category
{
public:
- virtual string message(int ev) const;
+ virtual string message(int __ev) const;
};
_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
@@ -436,7 +438,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
template <>
struct _LIBCPP_TEMPLATE_VIS hash<error_code>
- : public unary_function<error_code, size_t>
+ : public __unary_function<error_code, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const error_code& __ec) const _NOEXCEPT
@@ -447,7 +449,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<error_code>
template <>
struct _LIBCPP_TEMPLATE_VIS hash<error_condition>
- : public unary_function<error_condition, size_t>
+ : public __unary_function<error_condition, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const error_condition& __ec) const _NOEXCEPT
@@ -480,7 +482,7 @@ private:
};
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
-void __throw_system_error(int ev, const char* what_arg);
+void __throw_system_error(int __ev, const char* __what_arg);
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/tgmath.h
@@ -20,7 +20,7 @@
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef __cplusplus
lib/libcxx/include/thread
@@ -82,17 +82,15 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__debug>
-#include <__functional_base>
+#include <__functional/hash.h>
#include <__mutex_base>
#include <__thread/poll_with_backoff.h>
#include <__thread/timed_backoff_policy.h>
#include <__threading_support>
#include <__utility/forward.h>
-#include <chrono>
#include <cstddef>
-#include <functional>
#include <iosfwd>
#include <memory>
#include <system_error>
@@ -100,16 +98,24 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
#include <type_traits>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <chrono>
+# include <functional>
+#endif
+
+// standard-mandated includes
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
#ifdef _LIBCPP_HAS_NO_THREADS
-#error <thread> is not supported on this single threaded system
-#else // !_LIBCPP_HAS_NO_THREADS
+# error "<thread> is not supported since libc++ has been configured without support for threads."
+#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -200,7 +206,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p)
template<>
struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>
- : public unary_function<__thread_id, size_t>
+ : public __unary_function<__thread_id, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(__thread_id __v) const _NOEXCEPT
@@ -229,11 +235,7 @@ public:
thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
#ifndef _LIBCPP_CXX03_LANG
template <class _Fp, class ..._Args,
- class = typename enable_if
- <
- !is_same<typename __uncvref<_Fp>::type, thread>::value
- >::type
- >
+ class = __enable_if_t<!is_same<__uncvref_t<_Fp>, thread>::value> >
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
explicit thread(_Fp&& __f, _Args&&... __args);
#else // _LIBCPP_CXX03_LANG
@@ -408,8 +410,6 @@ void yield() _NOEXCEPT {__libcpp_thread_yield();}
_LIBCPP_END_NAMESPACE_STD
-#endif // !_LIBCPP_HAS_NO_THREADS
-
_LIBCPP_POP_MACROS
#endif // _LIBCPP_THREAD
lib/libcxx/include/tuple
@@ -25,14 +25,24 @@ public:
explicit(see-below) tuple(U&&...); // constexpr in C++14
tuple(const tuple&) = default;
tuple(tuple&&) = default;
+
+ template<class... UTypes>
+ constexpr explicit(see-below) tuple(tuple<UTypes...>&); // C++23
template <class... U>
explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14
template <class... U>
explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14
+ template<class... UTypes>
+ constexpr explicit(see-below) tuple(const tuple<UTypes...>&&); // C++23
+
+ template<class U1, class U2>
+ constexpr explicit(see-below) tuple(pair<U1, U2>&); // iff sizeof...(Types) == 2 // C++23
template <class U1, class U2>
explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
template <class U1, class U2>
explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
+ template<class U1, class U2>
+ constexpr explicit(see-below) tuple(const pair<U1, U2>&&); // iff sizeof...(Types) == 2 // C++23
// allocator-extended constructors
template <class Alloc>
@@ -45,25 +55,47 @@ public:
tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20
+ template<class Alloc, class... UTypes>
+ constexpr explicit(see-below)
+ tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&); // C++23
template <class Alloc, class... U>
explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); // constexpr in C++20
template <class Alloc, class... U>
explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); // constexpr in C++20
+ template<class Alloc, class... UTypes>
+ constexpr explicit(see-below)
+ tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&); // C++23
+ template<class Alloc, class U1, class U2>
+ constexpr explicit(see-below)
+ tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&); // C++23
template <class Alloc, class U1, class U2>
explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); // constexpr in C++20
template <class Alloc, class U1, class U2>
explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++20
+ template<class Alloc, class U1, class U2>
+ constexpr explicit(see-below)
+ tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&); // C++23
tuple& operator=(const tuple&); // constexpr in C++20
+ constexpr const tuple& operator=(const tuple&) const; // C++23
tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...); // constexpr in C++20
+ constexpr const tuple& operator=(tuple&&) const; // C++23
template <class... U>
tuple& operator=(const tuple<U...>&); // constexpr in C++20
+ template<class... UTypes>
+ constexpr const tuple& operator=(const tuple<UTypes...>&) const; // C++23
template <class... U>
tuple& operator=(tuple<U...>&&); // constexpr in C++20
+ template<class... UTypes>
+ constexpr const tuple& operator=(tuple<UTypes...>&&) const; // C++23
template <class U1, class U2>
tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++20
+ template<class U1, class U2>
+ constexpr const tuple& operator=(const pair<U1, U2>&) const; // iff sizeof...(Types) == 2 // C++23
template <class U1, class U2>
tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++20
+ template<class U1, class U2>
+ constexpr const tuple& operator=(pair<U1, U2>&&) const; // iff sizeof...(Types) == 2 // C++23
template<class U, size_t N>
tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION
@@ -71,6 +103,7 @@ public:
tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION
void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20
+ constexpr void swap(const tuple&) const noexcept(see-below); // C++23
};
@@ -161,29 +194,44 @@ template <class... Types>
void
swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
+template <class... Types>
+ constexpr void swap(const tuple<Types...>& x, const tuple<Types...>& y) noexcept(see-below); // C++23
+
} // std
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__compare/common_comparison_category.h>
#include <__compare/synth_three_way.h>
#include <__config>
#include <__functional/unwrap_ref.h>
-#include <__functional_base>
#include <__memory/allocator_arg_t.h>
#include <__memory/uses_allocator.h>
#include <__tuple>
#include <__utility/forward.h>
#include <__utility/integer_sequence.h>
#include <__utility/move.h>
-#include <compare>
+#include <__utility/pair.h>
+#include <__utility/piecewise_construct.h>
+#include <__utility/swap.h>
#include <cstddef>
#include <type_traits>
-#include <utility>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <exception>
+# include <iosfwd>
+# include <new>
+# include <typeinfo>
+# include <utility>
+#endif
+
+// standard-mandated includes
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -206,6 +254,13 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
swap(__x.get(), __y.get());
}
+template <size_t _Ip, class _Hp, bool _Ep>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)
+ _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {
+ swap(__x.get(), __y.get());
+}
+
template <size_t _Ip, class _Hp, bool>
class __tuple_leaf
{
@@ -294,6 +349,12 @@ public:
return 0;
}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
+ _VSTD::swap(*this, __t);
+ return 0;
+ }
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
};
@@ -360,6 +421,12 @@ public:
return 0;
}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
+ _VSTD::swap(*this, __rhs);
+ return 0;
+ }
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
};
@@ -415,10 +482,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
{}
template <class _Tuple,
- class = typename enable_if
- <
- __tuple_constructible<_Tuple, tuple<_Tp...> >::value
- >::type
+ class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
__tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
@@ -428,10 +492,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
{}
template <class _Alloc, class _Tuple,
- class = typename enable_if
- <
- __tuple_constructible<_Tuple, tuple<_Tp...> >::value
- >::type
+ class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
__tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
@@ -450,6 +511,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
{
_VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ void swap(const __tuple_impl& __t) const
+ _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value)
+ {
+ _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...);
+ }
};
template<class _Dest, class _Source, size_t ..._Np>
@@ -685,6 +753,7 @@ public:
template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
_And<is_copy_constructible<_Tp>...>::value
, int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
: __base_(allocator_arg_t(), __alloc, __t)
{ }
@@ -692,30 +761,39 @@ public:
template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
_And<is_move_constructible<_Tp>...>::value
, int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
: __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))
{ }
// tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
- template <class ..._Up>
- struct _EnableCopyFromOtherTuple : _And<
- _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >,
- _Lazy<_Or,
- _BoolConstant<sizeof...(_Tp) != 1>,
+
+ template <class _OtherTuple, class _DecayedOtherTuple = __uncvref_t<_OtherTuple>, class = void>
+ struct _EnableCtorFromUTypesTuple : false_type {};
+
+ template <class _OtherTuple, class... _Up>
+ struct _EnableCtorFromUTypesTuple<_OtherTuple, tuple<_Up...>,
+ // the length of the packs needs to checked first otherwise the 2 packs cannot be expanded simultaneously below
+ __enable_if_t<sizeof...(_Up) == sizeof...(_Tp)>> : _And<
+ // the two conditions below are not in spec. The purpose is to disable the UTypes Ctor when copy/move Ctor can work.
+ // Otherwise, is_constructible can trigger hard error in those cases https://godbolt.org/z/M94cGdKcE
+ _Not<is_same<_OtherTuple, const tuple&> >,
+ _Not<is_same<_OtherTuple, tuple&&> >,
+ is_constructible<_Tp, __copy_cvref_t<_OtherTuple, _Up> >...,
+ _Lazy<_Or, _BoolConstant<sizeof...(_Tp) != 1>,
// _Tp and _Up are 1-element packs - the pack expansions look
// weird to avoid tripping up the type traits in degenerate cases
_Lazy<_And,
- _Not<is_convertible<const tuple<_Up>&, _Tp> >...,
- _Not<is_constructible<_Tp, const tuple<_Up>&> >...
+ _Not<is_same<_Tp, _Up> >...,
+ _Not<is_convertible<_OtherTuple, _Tp> >...,
+ _Not<is_constructible<_Tp, _OtherTuple> >...
>
- >,
- is_constructible<_Tp, const _Up&>...
- > { };
+ >
+ > {};
template <class ..._Up, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
- _EnableCopyFromOtherTuple<_Up...>,
+ _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
is_convertible<const _Up&, _Tp>... // explicit check
>::value
, int> = 0>
@@ -727,8 +805,7 @@ public:
template <class ..._Up, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
- _EnableCopyFromOtherTuple<_Up...>,
+ _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
>::value
, int> = 0>
@@ -740,8 +817,7 @@ public:
template <class ..._Up, class _Alloc, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
- _EnableCopyFromOtherTuple<_Up...>,
+ _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
is_convertible<const _Up&, _Tp>... // explicit check
>::value
, int> = 0>
@@ -752,8 +828,7 @@ public:
template <class ..._Up, class _Alloc, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
- _EnableCopyFromOtherTuple<_Up...>,
+ _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
>::value
, int> = 0>
@@ -762,26 +837,27 @@ public:
: __base_(allocator_arg_t(), __a, __t)
{ }
+#if _LIBCPP_STD_VER > 20
+ // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)
+
+ template <class... _Up, enable_if_t<
+ _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!(is_convertible_v<_Up&, _Tp> && ...))
+ tuple(tuple<_Up...>& __t) : __base_(__t) {}
+
+ template <class _Alloc, class... _Up, enable_if_t<
+ _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!(is_convertible_v<_Up&, _Tp> && ...))
+ tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) : __base_(allocator_arg_t(), __alloc, __t) {}
+#endif // _LIBCPP_STD_VER > 20
+
// tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
- template <class ..._Up>
- struct _EnableMoveFromOtherTuple : _And<
- _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >,
- _Lazy<_Or,
- _BoolConstant<sizeof...(_Tp) != 1>,
- // _Tp and _Up are 1-element packs - the pack expansions look
- // weird to avoid tripping up the type traits in degenerate cases
- _Lazy<_And,
- _Not<is_convertible<tuple<_Up>, _Tp> >...,
- _Not<is_constructible<_Tp, tuple<_Up> > >...
- >
- >,
- is_constructible<_Tp, _Up>...
- > { };
template <class ..._Up, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
- _EnableMoveFromOtherTuple<_Up...>,
+ _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
is_convertible<_Up, _Tp>... // explicit check
>::value
, int> = 0>
@@ -793,8 +869,7 @@ public:
template <class ..._Up, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
- _EnableMoveFromOtherTuple<_Up...>,
+ _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
>::value
, int> = 0>
@@ -806,8 +881,7 @@ public:
template <class _Alloc, class ..._Up, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
- _EnableMoveFromOtherTuple<_Up...>,
+ _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
is_convertible<_Up, _Tp>... // explicit check
>::value
, int> = 0>
@@ -818,8 +892,7 @@ public:
template <class _Alloc, class ..._Up, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
- _EnableMoveFromOtherTuple<_Up...>,
+ _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
>::value
, int> = 0>
@@ -828,57 +901,77 @@ public:
: __base_(allocator_arg_t(), __a, _VSTD::move(__t))
{ }
+#if _LIBCPP_STD_VER > 20
+ // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)
+
+ template <class... _Up, enable_if_t<
+ _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!(is_convertible_v<const _Up&&, _Tp> && ...))
+ tuple(const tuple<_Up...>&& __t) : __base_(std::move(__t)) {}
+
+ template <class _Alloc, class... _Up, enable_if_t<
+ _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!(is_convertible_v<const _Up&&, _Tp> && ...))
+ tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
+ : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
+#endif // _LIBCPP_STD_VER > 20
+
// tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
- template <class _Up1, class _Up2, class ..._DependentTp>
- struct _EnableImplicitCopyFromPair : _And<
- is_constructible<_FirstType<_DependentTp...>, const _Up1&>,
- is_constructible<_SecondType<_DependentTp...>, const _Up2&>,
- is_convertible<const _Up1&, _FirstType<_DependentTp...> >, // explicit check
- is_convertible<const _Up2&, _SecondType<_DependentTp...> >
- > { };
- template <class _Up1, class _Up2, class ..._DependentTp>
- struct _EnableExplicitCopyFromPair : _And<
- is_constructible<_FirstType<_DependentTp...>, const _Up1&>,
- is_constructible<_SecondType<_DependentTp...>, const _Up2&>,
- _Not<is_convertible<const _Up1&, _FirstType<_DependentTp...> > >, // explicit check
- _Not<is_convertible<const _Up2&, _SecondType<_DependentTp...> > >
- > { };
+ template <template <class...> class Pred, class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
+ struct _CtorPredicateFromPair : false_type{};
+
+ template <template <class...> class Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
+ struct _CtorPredicateFromPair<Pred, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And<
+ Pred<_Tp1, __copy_cvref_t<_Pair, _Up1> >,
+ Pred<_Tp2, __copy_cvref_t<_Pair, _Up2> >
+ > {};
+
+ template <class _Pair>
+ struct _EnableCtorFromPair : _CtorPredicateFromPair<is_constructible, _Pair>{};
+
+ template <class _Pair>
+ struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair>{};
+
+ template <class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
+ struct _BothImplicitlyConvertible : false_type{};
+
+ template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
+ struct _BothImplicitlyConvertible<_Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And<
+ is_convertible<__copy_cvref_t<_Pair, _Up1>, _Tp1>,
+ is_convertible<__copy_cvref_t<_Pair, _Up2>, _Tp2>
+ > {};
template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Tp) == 2>,
- _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...>
+ _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
+ _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
>::value
, int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
tuple(const pair<_Up1, _Up2>& __p)
- _NOEXCEPT_((_And<
- is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>,
- is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&>
- >::value))
+ _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
: __base_(__p)
{ }
template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Tp) == 2>,
- _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...>
+ _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
+ _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
>::value
, int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit tuple(const pair<_Up1, _Up2>& __p)
- _NOEXCEPT_((_And<
- is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>,
- is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&>
- >::value))
+ _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
: __base_(__p)
{ }
template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Tp) == 2>,
- _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...>
+ _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
+ _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
>::value
, int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -888,8 +981,8 @@ public:
template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Tp) == 2>,
- _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...>
+ _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
+ _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
>::value
, int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -897,57 +990,52 @@ public:
: __base_(allocator_arg_t(), __a, __p)
{ }
- // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
- template <class _Up1, class _Up2, class ..._DependentTp>
- struct _EnableImplicitMoveFromPair : _And<
- is_constructible<_FirstType<_DependentTp...>, _Up1>,
- is_constructible<_SecondType<_DependentTp...>, _Up2>,
- is_convertible<_Up1, _FirstType<_DependentTp...> >, // explicit check
- is_convertible<_Up2, _SecondType<_DependentTp...> >
- > { };
+#if _LIBCPP_STD_VER > 20
+ // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)
+
+ template <class _U1, class _U2, enable_if_t<
+ _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
+ tuple(pair<_U1, _U2>& __p) : __base_(__p) {}
+
+ template <class _Alloc, class _U1, class _U2, enable_if_t<
+ _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
+ tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) : __base_(allocator_arg_t(), __alloc, __p) {}
+#endif
- template <class _Up1, class _Up2, class ..._DependentTp>
- struct _EnableExplicitMoveFromPair : _And<
- is_constructible<_FirstType<_DependentTp...>, _Up1>,
- is_constructible<_SecondType<_DependentTp...>, _Up2>,
- _Not<is_convertible<_Up1, _FirstType<_DependentTp...> > >, // explicit check
- _Not<is_convertible<_Up2, _SecondType<_DependentTp...> > >
- > { };
+ // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Tp) == 2>,
- _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>
+ _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
+ _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
>::value
, int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
tuple(pair<_Up1, _Up2>&& __p)
- _NOEXCEPT_((_And<
- is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
- is_nothrow_constructible<_SecondType<_Tp...>, _Up2>
- >::value))
+ _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
: __base_(_VSTD::move(__p))
{ }
template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Tp) == 2>,
- _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>
+ _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
+ _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
>::value
, int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit tuple(pair<_Up1, _Up2>&& __p)
- _NOEXCEPT_((_And<
- is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
- is_nothrow_constructible<_SecondType<_Tp...>, _Up2>
- >::value))
+ _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
: __base_(_VSTD::move(__p))
{ }
template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Tp) == 2>,
- _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>
+ _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
+ _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
>::value
, int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -957,8 +1045,8 @@ public:
template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
_And<
- _BoolConstant<sizeof...(_Tp) == 2>,
- _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>
+ _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
+ _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
>::value
, int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -966,6 +1054,23 @@ public:
: __base_(allocator_arg_t(), __a, _VSTD::move(__p))
{ }
+#if _LIBCPP_STD_VER > 20
+ // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)
+
+ template <class _U1, class _U2, enable_if_t<
+ _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
+ tuple(const pair<_U1, _U2>&& __p) : __base_(std::move(__p)) {}
+
+ template <class _Alloc, class _U1, class _U2, enable_if_t<
+ _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
+ tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)
+ : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
+#endif // _LIBCPP_STD_VER > 20
+
// [tuple.assign]
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
@@ -976,6 +1081,25 @@ public:
return *this;
}
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const tuple& operator=(tuple const& __tuple) const
+ requires (_And<is_copy_assignable<const _Tp>...>::value) {
+ std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const tuple& operator=(tuple&& __tuple) const
+ requires (_And<is_assignable<const _Tp&, _Tp>...>::value) {
+ std::__memberwise_forward_assign(*this,
+ std::move(__tuple),
+ __tuple_types<_Tp...>(),
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
+#endif // _LIBCPP_STD_VER > 20
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
_NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
@@ -1017,38 +1141,89 @@ public:
return *this;
}
- template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t<
- _And<_Dep,
- _BoolConstant<sizeof...(_Tp) == 2>,
- is_assignable<_FirstType<_Tp..., _Dep>&, _Up1 const&>,
- is_assignable<_SecondType<_Tp..., _Dep>&, _Up2 const&>
- >::value
+
+#if _LIBCPP_STD_VER > 20
+ template <class... _UTypes, enable_if_t<
+ _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
+ is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const tuple& operator=(const tuple<_UTypes...>& __u) const {
+ std::__memberwise_copy_assign(*this,
+ __u,
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
+
+ template <class... _UTypes, enable_if_t<
+ _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
+ is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const tuple& operator=(tuple<_UTypes...>&& __u) const {
+ std::__memberwise_forward_assign(*this,
+ __u,
+ __tuple_types<_UTypes...>(),
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
+#endif // _LIBCPP_STD_VER > 20
+
+ template <template<class...> class Pred, bool _Const,
+ class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
+ struct _AssignPredicateFromPair : false_type {};
+
+ template <template<class...> class Pred, bool _Const,
+ class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
+ struct _AssignPredicateFromPair<Pred, _Const, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > :
+ _And<Pred<__maybe_const<_Const, _Tp1>&, __copy_cvref_t<_Pair, _Up1> >,
+ Pred<__maybe_const<_Const, _Tp2>&, __copy_cvref_t<_Pair, _Up2> >
+ > {};
+
+ template <bool _Const, class _Pair>
+ struct _EnableAssignFromPair : _AssignPredicateFromPair<is_assignable, _Const, _Pair> {};
+
+ template <bool _Const, class _Pair>
+ struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {};
+
+#if _LIBCPP_STD_VER > 20
+ template <class _U1, class _U2, enable_if_t<
+ _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const tuple& operator=(const pair<_U1, _U2>& __pair) const
+ noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) {
+ std::get<0>(*this) = __pair.first;
+ std::get<1>(*this) = __pair.second;
+ return *this;
+ }
+
+ template <class _U1, class _U2, enable_if_t<
+ _EnableAssignFromPair<true, pair<_U1, _U2>&&>::value>* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const tuple& operator=(pair<_U1, _U2>&& __pair) const
+ noexcept(_NothrowAssignFromPair<true, pair<_U1, _U2>&&>::value) {
+ std::get<0>(*this) = std::move(__pair.first);
+ std::get<1>(*this) = std::move(__pair.second);
+ return *this;
+ }
+#endif // _LIBCPP_STD_VER > 20
+
+ template<class _Up1, class _Up2, __enable_if_t<
+ _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value
,int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple& operator=(pair<_Up1, _Up2> const& __pair)
- _NOEXCEPT_((_And<
- is_nothrow_assignable<_FirstType<_Tp...>&, _Up1 const&>,
- is_nothrow_assignable<_SecondType<_Tp...>&, _Up2 const&>
- >::value))
+ _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value))
{
_VSTD::get<0>(*this) = __pair.first;
_VSTD::get<1>(*this) = __pair.second;
return *this;
}
- template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t<
- _And<_Dep,
- _BoolConstant<sizeof...(_Tp) == 2>,
- is_assignable<_FirstType<_Tp..., _Dep>&, _Up1>,
- is_assignable<_SecondType<_Tp..., _Dep>&, _Up2>
- >::value
+ template<class _Up1, class _Up2, __enable_if_t<
+ _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value
,int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple& operator=(pair<_Up1, _Up2>&& __pair)
- _NOEXCEPT_((_And<
- is_nothrow_assignable<_FirstType<_Tp...>&, _Up1>,
- is_nothrow_assignable<_SecondType<_Tp...>&, _Up2>
- >::value))
+ _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value))
{
_VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first);
_VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second);
@@ -1092,6 +1267,13 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
{__base_.swap(__t.__base_);}
+
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ void swap(const tuple& __t) const noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) {
+ __base_.swap(__t.__base_);
+ }
+#endif // _LIBCPP_STD_VER > 20
};
template <>
@@ -1114,6 +1296,9 @@ public:
tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void swap(tuple&) _NOEXCEPT {}
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
+#endif
};
#if _LIBCPP_STD_VER > 20
@@ -1128,7 +1313,7 @@ template <class... _TTypes, class... _UTypes>
struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
using type = tuple<common_type_t<_TTypes, _UTypes>...>;
};
-#endif
+#endif // _LIBCPP_STD_VER > 20
#if _LIBCPP_STD_VER > 14
template <class ..._Tp>
@@ -1145,15 +1330,21 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
template <class ..._Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-typename enable_if
-<
- __all<__is_swappable<_Tp>::value...>::value,
- void
->::type
+__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void>
swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
_NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
{__t.swap(__u);}
+#if _LIBCPP_STD_VER > 20
+template <class... _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr
+enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void>
+swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs)
+ noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) {
+ __lhs.swap(__rhs);
+}
+#endif
+
// get
template <size_t _Ip, class ..._Tp>
@@ -1333,7 +1524,7 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
}
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if _LIBCPP_STD_VER > 17
// operator<=>
@@ -1355,7 +1546,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
}
-#else // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#else // _LIBCPP_STD_VER > 17
template <class ..._Tp, class ..._Up>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -1425,7 +1616,7 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
return !(__y < __x);
}
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // _LIBCPP_STD_VER > 17
// tuple_cat
@@ -1445,9 +1636,10 @@ struct __tuple_cat_return_1
template <class ..._Types, class _Tuple0>
struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
{
- typedef _LIBCPP_NODEBUG typename __tuple_cat_type<tuple<_Types...>,
- typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type
- type;
+ using type _LIBCPP_NODEBUG = typename __tuple_cat_type<
+ tuple<_Types...>,
+ typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
+ >::type;
};
template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
@@ -1455,7 +1647,7 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...
: public __tuple_cat_return_1<
typename __tuple_cat_type<
tuple<_Types...>,
- typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type
+ typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
>::type,
__tuple_like<typename remove_reference<_Tuple1>::type>::value,
_Tuple1, _Tuples...>
@@ -1529,6 +1721,7 @@ 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)
{
+ (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
return _VSTD::forward_as_tuple(
_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
@@ -1539,6 +1732,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
{
+ (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1;
return __tuple_cat<
@@ -1593,7 +1787,7 @@ inline _LIBCPP_INLINE_VISIBILITY
constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
__tuple_indices<_Id...>)
_LIBCPP_NOEXCEPT_RETURN(
- _VSTD::__invoke_constexpr(
+ _VSTD::__invoke(
_VSTD::forward<_Fn>(__f),
_VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
)
lib/libcxx/include/type_traits
@@ -416,3457 +416,178 @@ namespace std
}
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__functional/invoke.h>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_cv.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/add_pointer.h>
+#include <__type_traits/add_rvalue_reference.h>
+#include <__type_traits/add_volatile.h>
+#include <__type_traits/aligned_storage.h>
+#include <__type_traits/aligned_union.h>
+#include <__type_traits/alignment_of.h>
+#include <__type_traits/apply_cv.h>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/disjunction.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/extent.h>
+#include <__type_traits/has_unique_object_representation.h>
+#include <__type_traits/has_virtual_destructor.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_abstract.h>
+#include <__type_traits/is_aggregate.h>
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/is_bounded_array.h>
+#include <__type_traits/is_callable.h>
+#include <__type_traits/is_class.h>
+#include <__type_traits/is_compound.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_copy_assignable.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__type_traits/is_default_constructible.h>
+#include <__type_traits/is_destructible.h>
+#include <__type_traits/is_empty.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_final.h>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_fundamental.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_literal_type.h>
+#include <__type_traits/is_member_function_pointer.h>
+#include <__type_traits/is_member_object_pointer.h>
+#include <__type_traits/is_member_pointer.h>
+#include <__type_traits/is_move_assignable.h>
+#include <__type_traits/is_move_constructible.h>
+#include <__type_traits/is_nothrow_assignable.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_nothrow_copy_assignable.h>
+#include <__type_traits/is_nothrow_copy_constructible.h>
+#include <__type_traits/is_nothrow_default_constructible.h>
+#include <__type_traits/is_nothrow_destructible.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/is_null_pointer.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_pod.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_polymorphic.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_reference_wrapper.h>
+#include <__type_traits/is_referenceable.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_scalar.h>
+#include <__type_traits/is_scoped_enum.h>
+#include <__type_traits/is_signed.h>
+#include <__type_traits/is_standard_layout.h>
+#include <__type_traits/is_trivial.h>
+#include <__type_traits/is_trivially_assignable.h>
+#include <__type_traits/is_trivially_constructible.h>
+#include <__type_traits/is_trivially_copy_assignable.h>
+#include <__type_traits/is_trivially_copy_constructible.h>
+#include <__type_traits/is_trivially_copyable.h>
+#include <__type_traits/is_trivially_default_constructible.h>
+#include <__type_traits/is_trivially_destructible.h>
+#include <__type_traits/is_trivially_move_assignable.h>
+#include <__type_traits/is_trivially_move_constructible.h>
+#include <__type_traits/is_unbounded_array.h>
+#include <__type_traits/is_union.h>
+#include <__type_traits/is_unsigned.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/is_volatile.h>
+#include <__type_traits/make_signed.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/negation.h>
+#include <__type_traits/rank.h>
+#include <__type_traits/remove_all_extents.h>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_extent.h>
+#include <__type_traits/remove_pointer.h>
+#include <__type_traits/remove_reference.h>
+#include <__type_traits/remove_volatile.h>
+#include <__type_traits/type_identity.h>
+#include <__type_traits/underlying_type.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
#include <cstddef>
+#include <cstdint>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
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
-{
- static _LIBCPP_CONSTEXPR const _Tp value = __v;
- typedef _Tp value_type;
- typedef integral_constant type;
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
-#if _LIBCPP_STD_VER > 11
- _LIBCPP_INLINE_VISIBILITY
- constexpr value_type operator ()() const _NOEXCEPT {return value;}
-#endif
-};
-
-template <class _Tp, _Tp __v>
-_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
-
-#if _LIBCPP_STD_VER > 14
-template <bool __b>
-using bool_constant = integral_constant<bool, __b>;
-#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
-#else
-#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
-#endif
-
-template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
-
-template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type;
-
-#if _LIBCPP_STD_VER > 11
-template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
-#endif
-
-typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
-typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
-
-template <bool _Val>
-using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>;
-
-template <bool> struct _MetaBase;
-template <>
-struct _MetaBase<true> {
- template <class _Tp, class _Up>
- using _SelectImpl _LIBCPP_NODEBUG = _Tp;
- template <template <class...> class _FirstFn, template <class...> class, class ..._Args>
- using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>;
- template <class _First, class...>
- using _FirstImpl _LIBCPP_NODEBUG = _First;
- template <class, class _Second, class...>
- using _SecondImpl _LIBCPP_NODEBUG = _Second;
- template <class _Result, class _First, class ..._Rest>
- using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
-};
-
-template <>
-struct _MetaBase<false> {
- template <class _Tp, class _Up>
- using _SelectImpl _LIBCPP_NODEBUG = _Up;
- template <template <class...> class, template <class...> class _SecondFn, class ..._Args>
- using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>;
- template <class _Result, class ...>
- using _OrImpl _LIBCPP_NODEBUG = _Result;
-};
-template <bool _Cond, class _IfRes, class _ElseRes>
-using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
-template <class ..._Rest>
-using _Or _LIBCPP_NODEBUG = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
-template <class _Pred>
-struct _Not : _BoolConstant<!_Pred::value> {};
-template <class ..._Args>
-using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>;
-template <class ..._Args>
-using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
-
-template <class ...> using __expand_to_true = true_type;
-template <class ..._Pred>
-__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
-template <class ...>
-false_type __and_helper(...);
-template <class ..._Pred>
-using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
-
-template <template <class...> class _Func, class ..._Args>
-struct _Lazy : _Func<_Args...> {};
-
-// Member detector base
-
-template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> >
-true_type __sfinae_test_impl(int);
-template <template <class...> class, class ...>
-false_type __sfinae_test_impl(...);
-
-template <template <class ...> class _Templ, class ..._Args>
-using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
-
-template <class>
-struct __void_t { typedef void type; };
-
-template <class _Tp>
-struct __identity { typedef _Tp type; };
-
-template <class _Tp>
-using __identity_t _LIBCPP_NODEBUG = typename __identity<_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>
- struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
-
-#if _LIBCPP_STD_VER > 11
-template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
-#endif
-
-// is_same
-
-template <class _Tp, class _Up>
-struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class _Up>
-inline constexpr bool is_same_v = __is_same(_Tp, _Up);
-#endif
-
-// _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:
-// is_same<A,B> and is_same<C,D> are guaranteed to be different types, but
-// _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type).
-// Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame
-// mustn't be directly used anywhere that contributes to name-mangling
-// (such as in a dependent return type).
-
-template <class _Tp, class _Up>
-using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;
-
-template <class _Tp, class _Up>
-using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>;
-
-template <class _Tp>
-using __test_for_primary_template = __enable_if_t<
- _IsSame<_Tp, typename _Tp::__primary_template>::value
- >;
-template <class _Tp>
-using __is_primary_template = _IsValidExpansion<
- __test_for_primary_template, _Tp
- >;
-
-// helper class
-
-struct __two {char __lx[2];};
-
-// is_const
-
-#if __has_keyword(__is_const)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_const_v = __is_const(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_const_v = is_const<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_const)
-
-// is_volatile
-
-#if __has_keyword(__is_volatile)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_volatile_v = __is_volatile(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_volatile)
-
-// remove_const
-
-#if __has_keyword(__remove_const)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS remove_const {typedef __remove_const(_Tp) type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_const_t = __remove_const(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
-#endif
-
-#endif // __has_keyword(__remove_const)
-
-// remove_volatile
-
-#if __has_keyword(__remove_volatile)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef __remove_volatile(_Tp) type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_volatile_t = __remove_volatile(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
-#endif
-
-#endif // __has_keyword(__remove_volatile)
-
-// remove_cv
-
-#if __has_keyword(__remove_cv)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS remove_cv {typedef __remove_cv(_Tp) type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_cv_t = __remove_cv(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
-{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
-#endif
-
-#endif // __has_keyword(__remove_cv)
-
-// is_void
-
-#if __has_keyword(__is_void)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_void_v = __is_void(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
- : public is_same<typename remove_cv<_Tp>::type, void> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_void_v = is_void<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_void)
-
-// __is_nullptr_t
-
-template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
-template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
- : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
- : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
-#endif
-#endif // _LIBCPP_STD_VER > 11
-
-// is_integral
-
-#if __has_keyword(__is_integral)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_integral_v = __is_integral(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
- : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_integral_v = is_integral<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_integral)
-
-// [basic.fundamental] defines five standard signed integer types;
-// __int128_t is an extended signed integer type.
-// The signed and unsigned integer types, plus bool and the
-// five types with "char" in their name, compose the "integral" types.
-
-template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
-template <> struct __libcpp_is_signed_integer<signed char> : public true_type {};
-template <> struct __libcpp_is_signed_integer<signed short> : public true_type {};
-template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
-template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
-template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
-#ifndef _LIBCPP_HAS_NO_INT128
-template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};
-#endif
-
-template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
-template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {};
-template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {};
-template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
-template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
-template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
-#ifndef _LIBCPP_HAS_NO_INT128
-template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};
-#endif
-
-// is_floating_point
-// <concepts> implements __libcpp_floating_point
-
-template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
-template <> struct __libcpp_is_floating_point<float> : public true_type {};
-template <> struct __libcpp_is_floating_point<double> : public true_type {};
-template <> struct __libcpp_is_floating_point<long double> : public true_type {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
- : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
-#endif
-
-// is_array
-
-#if __has_keyword(__is_array)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_array_v = __is_array(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array
- : public false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]>
- : public true_type {};
-template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]>
- : public true_type {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_array_v = is_array<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_array)
-
-// is_pointer
-
-// Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types.
-#if __has_keyword(__is_pointer) && \
- !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_pointer_v = __is_pointer(_Tp);
-#endif
-
-#else // __has_keyword(__is_pointer)
-
-template <class _Tp> struct __libcpp_is_pointer : public false_type {};
-template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
-
-template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; };
-#if defined(_LIBCPP_HAS_OBJC_ARC)
-template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
-template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
-template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
-template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
-#endif
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
- : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_pointer)
-
-// is_reference
-
-#if __has_keyword(__is_lvalue_reference) && \
- __has_keyword(__is_rvalue_reference) && \
- __has_keyword(__is_reference)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { };
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_reference_v = __is_reference(_Tp);
-template <class _Tp>
-inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
-template <class _Tp>
-inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
-#endif
-
-#else // __has_keyword(__is_lvalue_reference) && etc...
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_reference_v = is_reference<_Tp>::value;
-
-template <class _Tp>
-inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
-
-template <class _Tp>
-inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_lvalue_reference) && etc...
-
-// is_union
-
-#if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
- : public integral_constant<bool, __is_union(_Tp)> {};
-
-#else
-
-template <class _Tp> struct __libcpp_union : public false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union
- : public __libcpp_union<typename remove_cv<_Tp>::type> {};
-
-#endif
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_union_v = is_union<_Tp>::value;
-#endif
-
-// is_class
-
-#if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
- : public integral_constant<bool, __is_class(_Tp)> {};
-
-#else
-
-namespace __is_class_imp
-{
-template <class _Tp> char __test(int _Tp::*);
-template <class _Tp> __two __test(...);
-}
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class
- : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
-
-#endif
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_class_v = is_class<_Tp>::value;
-#endif
-
-// is_function
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function
- : public _BoolConstant<
-#ifdef __clang__
- __is_function(_Tp)
-#else
- !(is_reference<_Tp>::value || is_const<const _Tp>::value)
-#endif
- > {};
-
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_function_v = is_function<_Tp>::value;
-#endif
-
-template <class _Tp> struct __libcpp_is_member_pointer {
- enum {
- __is_member = false,
- __is_func = false,
- __is_obj = false
- };
-};
-template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> {
- enum {
- __is_member = true,
- __is_func = is_function<_Tp>::value,
- __is_obj = !__is_func,
- };
-};
-
-#if __has_keyword(__is_member_function_pointer)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
- : _BoolConstant<__is_member_function_pointer(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
-#endif
-
-#else // __has_keyword(__is_member_function_pointer)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
- : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_member_function_pointer)
-
-// is_member_pointer
-
-#if __has_keyword(__is_member_pointer)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
-#endif
-
-#else // __has_keyword(__is_member_pointer)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
- : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_member_pointer)
-
-// is_member_object_pointer
-
-#if __has_keyword(__is_member_object_pointer)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
- : _BoolConstant<__is_member_object_pointer(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
-#endif
-
-#else // __has_keyword(__is_member_object_pointer)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
- : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_member_object_pointer)
-
-// is_enum
-
-#if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
- : public integral_constant<bool, __is_enum(_Tp)> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_enum_v = __is_enum(_Tp);
-#endif
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum
- : public integral_constant<bool, !is_void<_Tp>::value &&
- !is_integral<_Tp>::value &&
- !is_floating_point<_Tp>::value &&
- !is_array<_Tp>::value &&
- !is_pointer<_Tp>::value &&
- !is_reference<_Tp>::value &&
- !is_member_pointer<_Tp>::value &&
- !is_union<_Tp>::value &&
- !is_class<_Tp>::value &&
- !is_function<_Tp>::value > {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_enum_v = is_enum<_Tp>::value;
-#endif
-
-#endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC)
-
-// is_arithmetic
-
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic
- : public integral_constant<bool, is_integral<_Tp>::value ||
- is_floating_point<_Tp>::value> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
-#endif
-
-// is_fundamental
-
-// Before Clang 10, __is_fundamental didn't work for nullptr_t.
-// In C++03 nullptr_t is library-provided but must still count as "fundamental."
-#if __has_keyword(__is_fundamental) && \
- !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000) && \
- !defined(_LIBCPP_CXX03_LANG)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
-#endif
-
-#else // __has_keyword(__is_fundamental)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental
- : public integral_constant<bool, is_void<_Tp>::value ||
- __is_nullptr_t<_Tp>::value ||
- is_arithmetic<_Tp>::value> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_fundamental)
-
-// is_scalar
-
-// In C++03 nullptr_t is library-provided but must still count as "scalar."
-#if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_scalar_v = __is_scalar(_Tp);
-#endif
-
-#else // __has_keyword(__is_scalar)
-
-template <class _Tp> struct __is_block : false_type {};
-#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
-template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
-#endif
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
- : public integral_constant<bool, is_arithmetic<_Tp>::value ||
- is_member_pointer<_Tp>::value ||
- is_pointer<_Tp>::value ||
- __is_nullptr_t<_Tp>::value ||
- __is_block<_Tp>::value ||
- is_enum<_Tp>::value > {};
-
-template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_scalar)
-
-// is_object
-
-#if __has_keyword(__is_object)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_object_v = __is_object(_Tp);
-#endif
-
-#else // __has_keyword(__is_object)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object
- : public integral_constant<bool, is_scalar<_Tp>::value ||
- is_array<_Tp>::value ||
- is_union<_Tp>::value ||
- is_class<_Tp>::value > {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_object_v = is_object<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_object)
-
-// is_compound
-
-// >= 11 because in C++03 nullptr isn't actually nullptr
-#if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_compound_v = __is_compound(_Tp);
-#endif
-
-#else // __has_keyword(__is_compound)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound
- : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_compound_v = is_compound<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_compound)
-
-// __is_referenceable [defns.referenceable]
-
-struct __is_referenceable_impl {
- template <class _Tp> static _Tp& __test(int);
- template <class _Tp> static __two __test(...);
-};
-
-template <class _Tp>
-struct __is_referenceable : integral_constant<bool,
- _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
-
-
-// add_const
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const {
- typedef _LIBCPP_NODEBUG const _Tp type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
-#endif
-
-// add_volatile
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile {
- typedef _LIBCPP_NODEBUG volatile _Tp type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
-#endif
-
-// add_cv
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv {
- typedef _LIBCPP_NODEBUG const volatile _Tp type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
-#endif
-
-// remove_reference
-
-#if __has_keyword(__remove_reference)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS remove_reference { typedef __remove_reference(_Tp) type; };
-
-#else // __has_keyword(__remove_reference)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
-#endif
-
-#endif // __has_keyword(__remove_reference)
-
-// add_lvalue_reference
-
-template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
-template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; };
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
-{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
-#endif
-
-template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
-template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; };
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
-{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
-#endif
-
-// Suppress deprecation notice for volatile-qualified return type resulting
-// from volatile-qualified types _Tp.
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-template <class _Tp> _Tp&& __declval(int);
-template <class _Tp> _Tp __declval(long);
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-
-template <class _Tp>
-decltype(__declval<_Tp>(0))
-declval() _NOEXCEPT;
-
-// __uncvref
-
-template <class _Tp>
-struct __uncvref {
- typedef _LIBCPP_NODEBUG typename remove_cv<typename remove_reference<_Tp>::type>::type type;
-};
-
-template <class _Tp>
-struct __unconstref {
- typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
-};
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Tp>
-using __uncvref_t _LIBCPP_NODEBUG = typename __uncvref<_Tp>::type;
-#endif
-
-// __is_same_uncvref
-
-template <class _Tp, class _Up>
-struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type,
- typename __uncvref<_Up>::type> {};
-
-#if _LIBCPP_STD_VER > 17
-// remove_cvref - same as __uncvref
-template <class _Tp>
-struct remove_cvref : public __uncvref<_Tp> {};
-
-template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
-#endif
-
-
-struct __any
-{
- __any(...);
-};
-
-// remove_pointer
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
-#endif
-
-// add_pointer
-
-template <class _Tp,
- bool = __is_referenceable<_Tp>::value ||
- _IsSame<typename remove_cv<_Tp>::type, void>::value>
-struct __add_pointer_impl
- {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;};
-template <class _Tp> struct __add_pointer_impl<_Tp, false>
- {typedef _LIBCPP_NODEBUG _Tp type;};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
- {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
-#endif
-
-// type_identity
-#if _LIBCPP_STD_VER > 17
-template<class _Tp> struct type_identity { typedef _Tp type; };
-template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
-#endif
-
-// is_signed
-
-#if __has_keyword(__is_signed)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_signed_v = __is_signed(_Tp);
-#endif
-
-#else // __has_keyword(__is_signed)
-
-template <class _Tp, bool = is_integral<_Tp>::value>
-struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
-
-template <class _Tp>
-struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
-
-template <class _Tp, bool = is_arithmetic<_Tp>::value>
-struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
-
-template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_signed_v = is_signed<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_signed)
-
-// is_unsigned
-
-// Before Clang 13, __is_unsigned returned true for enums with signed underlying type.
-// No currently-released version of AppleClang contains the fixed intrinsic.
-#if __has_keyword(__is_unsigned) && \
- !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1300) && \
- !defined(_LIBCPP_APPLE_CLANG_VER)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
-#endif
-
-#else // __has_keyword(__is_unsigned)
-
-template <class _Tp, bool = is_integral<_Tp>::value>
-struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
-
-template <class _Tp>
-struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
-
-template <class _Tp, bool = is_arithmetic<_Tp>::value>
-struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
-
-template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_unsigned)
-
-// rank
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
- : public integral_constant<size_t, 0> {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
- : public integral_constant<size_t, rank<_Tp>::value + 1> {};
-template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
- : public integral_constant<size_t, rank<_Tp>::value + 1> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr size_t rank_v = rank<_Tp>::value;
-#endif
-
-// extent
-
-#if __has_keyword(__array_extent)
-
-template<class _Tp, size_t _Dim = 0>
-struct _LIBCPP_TEMPLATE_VIS extent
- : integral_constant<size_t, __array_extent(_Tp, _Dim)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, unsigned _Ip = 0>
-inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
-#endif
-
-#else // __has_keyword(__array_extent)
-
-template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent
- : public integral_constant<size_t, 0> {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0>
- : public integral_constant<size_t, 0> {};
-template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip>
- : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
-template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0>
- : public integral_constant<size_t, _Np> {};
-template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip>
- : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, unsigned _Ip = 0>
-inline constexpr size_t extent_v = extent<_Tp, _Ip>::value;
-#endif
-
-#endif // __has_keyword(__array_extent)
-
-// remove_extent
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
- {typedef _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
- {typedef _Tp type;};
-template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
- {typedef _Tp type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
-#endif
-
-// remove_all_extents
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
- {typedef _Tp type;};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
- {typedef typename remove_all_extents<_Tp>::type type;};
-template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
- {typedef typename remove_all_extents<_Tp>::type type;};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
-#endif
-
-#if _LIBCPP_STD_VER > 17
-// is_bounded_array
-
-template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};
-template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
-
-template <class _Tp>
-inline constexpr
-bool is_bounded_array_v = is_bounded_array<_Tp>::value;
-
-// is_unbounded_array
-
-template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
-
-template <class _Tp>
-inline constexpr
-bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
-#endif
-
-// decay
-
-template <class _Up, bool>
-struct __decay {
- typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;
-};
-
-template <class _Up>
-struct __decay<_Up, true> {
-public:
- typedef _LIBCPP_NODEBUG typename conditional
- <
- is_array<_Up>::value,
- typename remove_extent<_Up>::type*,
- typename conditional
- <
- is_function<_Up>::value,
- typename add_pointer<_Up>::type,
- typename remove_cv<_Up>::type
- >::type
- >::type type;
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS decay
-{
-private:
- typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
-public:
- typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using decay_t = typename decay<_Tp>::type;
-#endif
-
-// is_abstract
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
- : public integral_constant<bool, __is_abstract(_Tp)> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
-#endif
-
-// is_final
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
-__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
-is_final : public integral_constant<bool, __is_final(_Tp)> {};
-#endif
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_final_v = is_final<_Tp>::value;
-#endif
-
-// is_aggregate
-#if _LIBCPP_STD_VER > 14
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS
-is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};
-
-template <class _Tp>
-inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
-
-#endif // _LIBCPP_STD_VER > 14
-
-// is_base_of
-
-template <class _Bp, class _Dp>
-struct _LIBCPP_TEMPLATE_VIS is_base_of
- : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Bp, class _Dp>
-inline constexpr bool is_base_of_v = is_base_of<_Bp, _Dp>::value;
-#endif
-
-// __is_core_convertible
-
-// [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed.
-// We can't test for that, but we can test implicit convertibility by passing it
-// to a function. Notice that __is_core_convertible<void,void> is false,
-// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
-
-template <class _Tp, class _Up, class = void>
-struct __is_core_convertible : public false_type {};
-
-template <class _Tp, class _Up>
-struct __is_core_convertible<_Tp, _Up, decltype(
- static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
-)> : public true_type {};
-
-// is_convertible
-
-#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
-
-template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
- : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
-
-#else // __has_feature(is_convertible_to)
-
-namespace __is_convertible_imp
-{
-template <class _Tp> void __test_convert(_Tp);
-
-template <class _From, class _To, class = void>
-struct __is_convertible_test : public false_type {};
-
-template <class _From, class _To>
-struct __is_convertible_test<_From, _To,
- decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
-{};
-
-template <class _Tp, bool _IsArray = is_array<_Tp>::value,
- bool _IsFunction = is_function<_Tp>::value,
- bool _IsVoid = is_void<_Tp>::value>
- struct __is_array_function_or_void {enum {value = 0};};
-template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
-template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
-template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
-}
-
-template <class _Tp,
- unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
-struct __is_convertible_check
-{
- static const size_t __v = 0;
-};
-
-template <class _Tp>
-struct __is_convertible_check<_Tp, 0>
-{
- static const size_t __v = sizeof(_Tp);
-};
-
-template <class _T1, class _T2,
- unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
- unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
-struct __is_convertible
- : public integral_constant<bool,
- __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
- >
-{};
-
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
-
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
-
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
-template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
-
-template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
- : public __is_convertible<_T1, _T2>
-{
- static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
- static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
-};
-
-#endif // __has_feature(is_convertible_to)
-
-#if _LIBCPP_STD_VER > 14
-template <class _From, class _To>
-inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
-#endif
-
-// is_nothrow_convertible
-
-#if _LIBCPP_STD_VER > 17
-
-template <typename _Tp>
-static void __test_noexcept(_Tp) noexcept;
-
-template<typename _Fm, typename _To>
-static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
-__is_nothrow_convertible_test();
-
-template <typename _Fm, typename _To>
-struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
-{ };
-
-template <typename _Fm, typename _To>
-struct is_nothrow_convertible : _Or<
- _And<is_void<_To>, is_void<_Fm>>,
- _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
->::type { };
-
-template <typename _Fm, typename _To>
-inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
-
-#endif // _LIBCPP_STD_VER > 17
-
-// is_empty
-
-#if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_empty
- : public integral_constant<bool, __is_empty(_Tp)> {};
-
-#else // __has_feature(is_empty)
-
-template <class _Tp>
-struct __is_empty1
- : public _Tp
-{
- double __lx;
-};
-
-struct __is_empty2
-{
- double __lx;
-};
-
-template <class _Tp, bool = is_class<_Tp>::value>
-struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
-
-template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
-
-#endif // __has_feature(is_empty)
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_empty_v = is_empty<_Tp>::value;
-#endif
-
-// is_polymorphic
-
-#if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC)
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_polymorphic
- : public integral_constant<bool, __is_polymorphic(_Tp)> {};
-
-#else
-
-template<typename _Tp> char &__is_polymorphic_impl(
- typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
- int>::type);
-template<typename _Tp> __two &__is_polymorphic_impl(...);
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic
- : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
-
-#endif // __has_feature(is_polymorphic)
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
-#endif
-
-// has_virtual_destructor
-
-#if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
- : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
- : public false_type {};
-
-#endif
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value;
-#endif
-
-// has_unique_object_representations
-
-#if _LIBCPP_STD_VER > 14
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
- : public integral_constant<bool,
- __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
-
-template <class _Tp>
-inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value;
-
-#endif
-
-// alignment_of
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
- : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
-#endif
-
-// aligned_storage
-
-template <class _Hp, class _Tp>
-struct __type_list
-{
- typedef _Hp _Head;
- typedef _Tp _Tail;
-};
-
-struct __nat
-{
-#ifndef _LIBCPP_CXX03_LANG
- __nat() = delete;
- __nat(const __nat&) = delete;
- __nat& operator=(const __nat&) = delete;
- ~__nat() = delete;
-#endif
-};
-
-template <class _Tp>
-struct __align_type
-{
- static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp);
- typedef _Tp type;
-};
-
-struct __struct_double {long double __lx;};
-struct __struct_double4 {double __lx[4];};
-
-typedef
- __type_list<__align_type<unsigned char>,
- __type_list<__align_type<unsigned short>,
- __type_list<__align_type<unsigned int>,
- __type_list<__align_type<unsigned long>,
- __type_list<__align_type<unsigned long long>,
- __type_list<__align_type<double>,
- __type_list<__align_type<long double>,
- __type_list<__align_type<__struct_double>,
- __type_list<__align_type<__struct_double4>,
- __type_list<__align_type<int*>,
- __nat
- > > > > > > > > > > __all_types;
-
-template <size_t _Align>
-struct _ALIGNAS(_Align) __fallback_overaligned {};
-
-template <class _TL, size_t _Align> struct __find_pod;
-
-template <class _Hp, size_t _Align>
-struct __find_pod<__type_list<_Hp, __nat>, _Align>
-{
- typedef typename conditional<
- _Align == _Hp::value,
- typename _Hp::type,
- __fallback_overaligned<_Align>
- >::type type;
-};
-
-template <class _Hp, class _Tp, size_t _Align>
-struct __find_pod<__type_list<_Hp, _Tp>, _Align>
-{
- typedef typename conditional<
- _Align == _Hp::value,
- typename _Hp::type,
- typename __find_pod<_Tp, _Align>::type
- >::type type;
-};
-
-template <class _TL, size_t _Len> struct __find_max_align;
-
-template <class _Hp, size_t _Len>
-struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
-
-template <size_t _Len, size_t _A1, size_t _A2>
-struct __select_align
-{
-private:
- static const size_t __min = _A2 < _A1 ? _A2 : _A1;
- static const size_t __max = _A1 < _A2 ? _A2 : _A1;
-public:
- static const size_t value = _Len < __max ? __min : __max;
-};
-
-template <class _Hp, class _Tp, size_t _Len>
-struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
- : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
-
-template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
-struct _LIBCPP_TEMPLATE_VIS aligned_storage
-{
- typedef typename __find_pod<__all_types, _Align>::type _Aligner;
- union type
- {
- _Aligner __align;
- unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
- };
-};
-
-#if _LIBCPP_STD_VER > 11
-template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
- using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
-#endif
-
-#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
-template <size_t _Len>\
-struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
-{\
- struct _ALIGNAS(n) type\
- {\
- unsigned char __lx[(_Len + n - 1)/n * n];\
- };\
-}
-
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
-// PE/COFF does not support alignment beyond 8192 (=0x2000)
-#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
-_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
-#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
-
-#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
-
-
-// aligned_union
-
-template <size_t _I0, size_t ..._In>
-struct __static_max;
-
-template <size_t _I0>
-struct __static_max<_I0>
-{
- static const size_t value = _I0;
-};
-
-template <size_t _I0, size_t _I1, size_t ..._In>
-struct __static_max<_I0, _I1, _In...>
-{
- static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
- __static_max<_I1, _In...>::value;
-};
-
-template <size_t _Len, class _Type0, class ..._Types>
-struct aligned_union
-{
- static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
- _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
- static const size_t __len = __static_max<_Len, sizeof(_Type0),
- sizeof(_Types)...>::value;
- typedef typename aligned_storage<__len, alignment_value>::type type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
-#endif
-
-template <class _Tp>
-struct __numeric_type
-{
- static void __test(...);
- static float __test(float);
- static double __test(char);
- static double __test(int);
- static double __test(unsigned);
- static double __test(long);
- static double __test(unsigned long);
- static double __test(long long);
- static double __test(unsigned long long);
- static double __test(double);
- static long double __test(long double);
-
- typedef decltype(__test(declval<_Tp>())) type;
- static const bool value = _IsNotSame<type, void>::value;
-};
-
-template <>
-struct __numeric_type<void>
-{
- static const bool value = true;
-};
-
-// __promote
-
-template <class _A1, class _A2 = void, class _A3 = void,
- bool = __numeric_type<_A1>::value &&
- __numeric_type<_A2>::value &&
- __numeric_type<_A3>::value>
-class __promote_imp
-{
-public:
- static const bool value = false;
-};
-
-template <class _A1, class _A2, class _A3>
-class __promote_imp<_A1, _A2, _A3, true>
-{
-private:
- typedef typename __promote_imp<_A1>::type __type1;
- typedef typename __promote_imp<_A2>::type __type2;
- typedef typename __promote_imp<_A3>::type __type3;
-public:
- typedef decltype(__type1() + __type2() + __type3()) type;
- static const bool value = true;
-};
-
-template <class _A1, class _A2>
-class __promote_imp<_A1, _A2, void, true>
-{
-private:
- typedef typename __promote_imp<_A1>::type __type1;
- typedef typename __promote_imp<_A2>::type __type2;
-public:
- typedef decltype(__type1() + __type2()) type;
- static const bool value = true;
-};
-
-template <class _A1>
-class __promote_imp<_A1, void, void, true>
-{
-public:
- typedef typename __numeric_type<_A1>::type type;
- static const bool value = true;
-};
-
-template <class _A1, class _A2 = void, class _A3 = void>
-class __promote : public __promote_imp<_A1, _A2, _A3> {};
-
-// make_signed / make_unsigned
-
-typedef
- __type_list<signed char,
- __type_list<signed short,
- __type_list<signed int,
- __type_list<signed long,
- __type_list<signed long long,
-#ifndef _LIBCPP_HAS_NO_INT128
- __type_list<__int128_t,
-#endif
- __nat
-#ifndef _LIBCPP_HAS_NO_INT128
- >
-#endif
- > > > > > __signed_types;
-
-typedef
- __type_list<unsigned char,
- __type_list<unsigned short,
- __type_list<unsigned int,
- __type_list<unsigned long,
- __type_list<unsigned long long,
-#ifndef _LIBCPP_HAS_NO_INT128
- __type_list<__uint128_t,
-#endif
- __nat
-#ifndef _LIBCPP_HAS_NO_INT128
- >
-#endif
- > > > > > __unsigned_types;
-
-template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
-
-template <class _Hp, class _Tp, size_t _Size>
-struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
-{
- typedef _LIBCPP_NODEBUG _Hp type;
-};
-
-template <class _Hp, class _Tp, size_t _Size>
-struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
-{
- typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
-};
-
-template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
- bool = is_volatile<typename remove_reference<_Tp>::type>::value>
-struct __apply_cv
-{
- typedef _LIBCPP_NODEBUG _Up type;
-};
-
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp, _Up, true, false>
-{
- typedef _LIBCPP_NODEBUG const _Up type;
-};
-
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp, _Up, false, true>
-{
- typedef volatile _Up type;
-};
-
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp, _Up, true, true>
-{
- typedef const volatile _Up type;
-};
-
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp&, _Up, false, false>
-{
- typedef _Up& type;
-};
-
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp&, _Up, true, false>
-{
- typedef const _Up& type;
-};
-
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp&, _Up, false, true>
-{
- typedef volatile _Up& type;
-};
-
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp&, _Up, true, true>
-{
- typedef const volatile _Up& type;
-};
-
-template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
-struct __make_signed {};
-
-template <class _Tp>
-struct __make_signed<_Tp, true>
-{
- typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
-};
-
-template <> struct __make_signed<bool, true> {};
-template <> struct __make_signed< signed short, true> {typedef short type;};
-template <> struct __make_signed<unsigned short, true> {typedef short type;};
-template <> struct __make_signed< signed int, true> {typedef int type;};
-template <> struct __make_signed<unsigned int, true> {typedef int type;};
-template <> struct __make_signed< signed long, true> {typedef long type;};
-template <> struct __make_signed<unsigned long, true> {typedef long type;};
-template <> struct __make_signed< signed long long, true> {typedef long long type;};
-template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
-#ifndef _LIBCPP_HAS_NO_INT128
-template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
-template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
-#endif
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS make_signed
-{
- typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
-#endif
-
-template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
-struct __make_unsigned {};
-
-template <class _Tp>
-struct __make_unsigned<_Tp, true>
-{
- typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
-};
-
-template <> struct __make_unsigned<bool, true> {};
-template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
-template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
-template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
-template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
-template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
-template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
-template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
-template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
-#ifndef _LIBCPP_HAS_NO_INT128
-template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
-template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
-#endif
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS make_unsigned
-{
- typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
-#endif
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr
-typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
- return static_cast<typename make_unsigned<_Tp>::type>(__x);
-}
-#endif
-
-#if _LIBCPP_STD_VER > 14
-template <class...> using void_t = void;
-#endif
-
-#if _LIBCPP_STD_VER > 17
-// Let COND_RES(X, Y) be:
-template <class _Tp, class _Up>
-using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
-
-template <class _Tp, class _Up, class = void>
-struct __common_type3 {};
-
-// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
-template <class _Tp, class _Up>
-struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>>
-{
- using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
-};
-
-template <class _Tp, class _Up, class = void>
-struct __common_type2_imp : __common_type3<_Tp, _Up> {};
-#else
-template <class _Tp, class _Up, class = void>
-struct __common_type2_imp {};
-#endif
-
-// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
-template <class _Tp, class _Up>
-struct __common_type2_imp<_Tp, _Up,
- typename __void_t<decltype(
- true ? declval<_Tp>() : declval<_Up>()
- )>::type>
-{
- typedef _LIBCPP_NODEBUG typename decay<decltype(
- true ? declval<_Tp>() : declval<_Up>()
- )>::type type;
-};
-
-template <class, class = void>
-struct __common_type_impl {};
-
-// Clang provides variadic templates in C++03 as an extension.
-#if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__)
-# define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__
-template <class... _Tp>
-struct __common_types;
-template <class... _Tp>
-struct _LIBCPP_TEMPLATE_VIS common_type;
-#else
-# define _LIBCPP_OPTIONAL_PACK(...)
-struct __no_arg;
-template <class _Tp, class _Up, class = __no_arg>
-struct __common_types;
-template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg,
- class _Unused = __no_arg>
-struct common_type {
- static_assert(sizeof(_Unused) == 0,
- "common_type accepts at most 3 arguments in C++03");
-};
-#endif // _LIBCPP_CXX03_LANG
-
-template <class _Tp, class _Up>
-struct __common_type_impl<
- __common_types<_Tp, _Up>,
- typename __void_t<typename common_type<_Tp, _Up>::type>::type>
-{
- typedef typename common_type<_Tp, _Up>::type type;
-};
-
-template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
-struct __common_type_impl<
- __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
- typename __void_t<typename common_type<_Tp, _Up>::type>::type>
- : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
- _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
-};
-
-// bullet 1 - sizeof...(Tp) == 0
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS common_type<> {};
-
-// bullet 2 - sizeof...(Tp) == 1
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
- : public common_type<_Tp, _Tp> {};
-
-// bullet 3 - sizeof...(Tp) == 2
-
-// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
-template <class _Tp, class _Up>
-struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
- : conditional<
- _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value,
- __common_type2_imp<_Tp, _Up>,
- common_type<typename decay<_Tp>::type, typename decay<_Up>::type>
- >::type
-{};
-
-// bullet 4 - sizeof...(Tp) > 2
-
-template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
-struct _LIBCPP_TEMPLATE_VIS
- common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>
- : __common_type_impl<
- __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {};
-
-#undef _LIBCPP_OPTIONAL_PACK
-
-#if _LIBCPP_STD_VER > 11
-template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
-#endif
-
-#if _LIBCPP_STD_VER > 11
-// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
-// top-level cv-qualifiers.
-template <class _From, class _To>
-struct __copy_cv
-{
- using type = _To;
-};
-
-template <class _From, class _To>
-struct __copy_cv<const _From, _To>
-{
- using type = add_const_t<_To>;
-};
-
-template <class _From, class _To>
-struct __copy_cv<volatile _From, _To>
-{
- using type = add_volatile_t<_To>;
-};
-
-template <class _From, class _To>
-struct __copy_cv<const volatile _From, _To>
-{
- using type = add_cv_t<_To>;
-};
-
-template <class _From, class _To>
-using __copy_cv_t = typename __copy_cv<_From, _To>::type;
-
-template <class _From, class _To>
-struct __copy_cvref
-{
- using type = __copy_cv_t<_From, _To>;
-};
-
-template <class _From, class _To>
-struct __copy_cvref<_From&, _To>
-{
- using type = add_lvalue_reference_t<__copy_cv_t<_From, _To>>;
-};
-
-template <class _From, class _To>
-struct __copy_cvref<_From&&, _To>
-{
- using type = add_rvalue_reference_t<__copy_cv_t<_From, _To>>;
-};
-
-template <class _From, class _To>
-using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;
-
-#endif // _LIBCPP_STD_VER > 11
-
-// common_reference
-#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-// Let COND_RES(X, Y) be:
-template <class _Xp, class _Yp>
-using __cond_res =
- decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
-
-// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
-// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
-// `U`.
-// [Note: `XREF(A)` is `__xref<A>::template __apply`]
-template <class _Tp>
-struct __xref {
- template<class _Up>
- using __apply = __copy_cvref_t<_Tp, _Up>;
-};
-
-// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
-// and let COMMON-REF(A, B) be:
-template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>>
-struct __common_ref;
-
-template<class _Xp, class _Yp>
-using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;
-
-template<class _Xp, class _Yp>
-using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
-
-
-// If A and B are both lvalue reference types, COMMON-REF(A, B) is
-// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
-template<class _Ap, class _Bp, class _Xp, class _Yp>
-requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>>
-struct __common_ref<_Ap&, _Bp&, _Xp, _Yp>
-{
- using __type = __cv_cond_res<_Xp, _Yp>;
-};
-
-// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
-template <class _Xp, class _Yp>
-using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
-
-
-// .... If A and B are both rvalue reference types, C is well-formed, and
-// is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.
-template<class _Ap, class _Bp, class _Xp, class _Yp>
-requires
- requires { typename __common_ref_C<_Xp, _Yp>; } &&
- is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
- is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
-struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp>
-{
- using __type = __common_ref_C<_Xp, _Yp>;
-};
-
-// Otherwise, let D be COMMON-REF(const X&, Y&). ...
-template <class _Tp, class _Up>
-using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;
-
-// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
-// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
-template<class _Ap, class _Bp, class _Xp, class _Yp>
-requires requires { typename __common_ref_D<_Xp, _Yp>; } &&
- is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
-struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp>
-{
- using __type = __common_ref_D<_Xp, _Yp>;
-};
-
-// Otherwise, if A is an lvalue reference and B is an rvalue reference, then
-// COMMON-REF(A, B) is COMMON-REF(B, A).
-template<class _Ap, class _Bp, class _Xp, class _Yp>
-struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {};
-
-// Otherwise, COMMON-REF(A, B) is ill-formed.
-template<class _Ap, class _Bp, class _Xp, class _Yp>
-struct __common_ref {};
-
-// Note C: For the common_reference trait applied to a parameter pack [...]
-
-template <class...>
-struct common_reference;
-
-template <class... _Types>
-using common_reference_t = typename common_reference<_Types...>::type;
-
-// bullet 1 - sizeof...(T) == 0
-template<>
-struct common_reference<> {};
-
-// bullet 2 - sizeof...(T) == 1
-template <class _Tp>
-struct common_reference<_Tp>
-{
- using type = _Tp;
-};
-
-// bullet 3 - sizeof...(T) == 2
-template <class _Tp, class _Up> struct __common_reference_sub_bullet3;
-template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {};
-template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
-
-// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
-// the member typedef `type` denotes that type.
-template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
-
-template <class _Tp, class _Up>
-requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
-struct __common_reference_sub_bullet1<_Tp, _Up>
-{
- using type = __common_ref_t<_Tp, _Up>;
-};
-
-// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
-// is well-formed, then the member typedef `type` denotes that type.
-template <class, class, template <class> class, template <class> class> struct basic_common_reference {};
-
-template <class _Tp, class _Up>
-using __basic_common_reference_t = typename basic_common_reference<
- remove_cvref_t<_Tp>, remove_cvref_t<_Up>,
- __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type;
-
-template <class _Tp, class _Up>
-requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
-struct __common_reference_sub_bullet2<_Tp, _Up>
-{
- using type = __basic_common_reference_t<_Tp, _Up>;
-};
-
-// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
-// then the member typedef `type` denotes that type.
-template <class _Tp, class _Up>
-requires requires { typename __cond_res<_Tp, _Up>; }
-struct __common_reference_sub_bullet3<_Tp, _Up>
-{
- using type = __cond_res<_Tp, _Up>;
-};
-
-
-// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
-// then the member typedef `type` denotes that type.
-// - Otherwise, there shall be no member `type`.
-template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
-
-// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if
-// any, as `common_reference_t<C, Rest...>`.
-template <class _Tp, class _Up, class _Vp, class... _Rest>
-requires requires { typename common_reference_t<_Tp, _Up>; }
-struct common_reference<_Tp, _Up, _Vp, _Rest...>
- : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...>
-{};
-
-// bullet 5 - Otherwise, there shall be no member `type`.
-template <class...> struct common_reference {};
-
-#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
-
-// is_assignable
-
-template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
-
-#if __has_keyword(__is_assignable)
-
-template<class _Tp, class _Up>
-struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class _Arg>
-inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
-#endif
-
-#else // __has_keyword(__is_assignable)
-
-template <class _Tp, class _Arg>
-typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
-__is_assignable_test(int);
-
-template <class, class>
-false_type __is_assignable_test(...);
-
-
-template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
-struct __is_assignable_imp
- : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
-
-template <class _Tp, class _Arg>
-struct __is_assignable_imp<_Tp, _Arg, true>
- : public false_type
-{
-};
-
-template <class _Tp, class _Arg>
-struct is_assignable
- : public __is_assignable_imp<_Tp, _Arg> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class _Arg>
-inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
-#endif
-
-#endif // __has_keyword(__is_assignable)
-
-// is_copy_assignable
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
- : public is_assignable<typename add_lvalue_reference<_Tp>::type,
- typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
-#endif
-
-// is_move_assignable
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
- : public is_assignable<typename add_lvalue_reference<_Tp>::type,
- typename add_rvalue_reference<_Tp>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
-#endif
-
-// is_destructible
-
-#if __has_keyword(__is_destructible)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_destructible_v = __is_destructible(_Tp);
-#endif
-
-#else // __has_keyword(__is_destructible)
-
-// if it's a reference, return true
-// if it's a function, return false
-// if it's void, return false
-// if it's an array of unknown bound, return false
-// Otherwise, return "declval<_Up&>().~_Up()" is well-formed
-// where _Up is remove_all_extents<_Tp>::type
-
-template <class>
-struct __is_destructible_apply { typedef int type; };
-
-template <typename _Tp>
-struct __is_destructor_wellformed {
- template <typename _Tp1>
- static char __test (
- typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
- );
-
- template <typename _Tp1>
- static __two __test (...);
-
- static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
-};
-
-template <class _Tp, bool>
-struct __destructible_imp;
-
-template <class _Tp>
-struct __destructible_imp<_Tp, false>
- : public integral_constant<bool,
- __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
-
-template <class _Tp>
-struct __destructible_imp<_Tp, true>
- : public true_type {};
-
-template <class _Tp, bool>
-struct __destructible_false;
-
-template <class _Tp>
-struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};
-
-template <class _Tp>
-struct __destructible_false<_Tp, true> : public false_type {};
-
-template <class _Tp>
-struct is_destructible
- : public __destructible_false<_Tp, is_function<_Tp>::value> {};
-
-template <class _Tp>
-struct is_destructible<_Tp[]>
- : public false_type {};
-
-template <>
-struct is_destructible<void>
- : public false_type {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
-#endif
-
-#endif // __has_keyword(__is_destructible)
-
-template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
-struct __member_pointer_traits_imp
-{
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
-{
- typedef _Class _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
-{
- typedef _Class _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
-{
- typedef _Class const _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
-{
- typedef _Class const _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
-{
- typedef _Class volatile _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
-{
- typedef _Class volatile _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
-{
- typedef _Class const volatile _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
-{
- typedef _Class const volatile _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-#if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
-{
- typedef _Class& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
-{
- typedef _Class& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
-{
- typedef _Class const& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
-{
- typedef _Class const& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
-{
- typedef _Class volatile& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
-{
- typedef _Class volatile& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
-{
- typedef _Class const volatile& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
-{
- typedef _Class const volatile& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
-{
- typedef _Class&& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
-{
- typedef _Class&& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
-{
- typedef _Class const&& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
-{
- typedef _Class const&& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
-{
- typedef _Class volatile&& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
-{
- typedef _Class volatile&& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
-{
- typedef _Class const volatile&& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param...);
-};
-
-template <class _Rp, class _Class, class ..._Param>
-struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
-{
- typedef _Class const volatile&& _ClassType;
- typedef _Rp _ReturnType;
- typedef _Rp (_FnType) (_Param..., ...);
-};
-
-#endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
-
-
-template <class _Rp, class _Class>
-struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
-{
- typedef _Class _ClassType;
- typedef _Rp _ReturnType;
-};
-
-template <class _MP>
-struct __member_pointer_traits
- : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
- is_member_function_pointer<_MP>::value,
- is_member_object_pointer<_MP>::value>
-{
-// typedef ... _ClassType;
-// typedef ... _ReturnType;
-// typedef ... _FnType;
-};
-
-
-template <class _DecayedFp>
-struct __member_pointer_class_type {};
-
-template <class _Ret, class _ClassType>
-struct __member_pointer_class_type<_Ret _ClassType::*> {
- typedef _ClassType type;
-};
-
-// template <class T, class... Args> struct is_constructible;
-
-template <class _Tp, class ..._Args>
-struct _LIBCPP_TEMPLATE_VIS is_constructible
- : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
-{ };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class ..._Args>
-inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
-#endif
-
-// is_default_constructible
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_default_constructible
- : public is_constructible<_Tp>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
-#endif
-
-#ifndef _LIBCPP_CXX03_LANG
-// First of all, we can't implement this check in C++03 mode because the {}
-// default initialization syntax isn't valid.
-// Second, we implement the trait in a funny manner with two defaulted template
-// arguments to workaround Clang's PR43454.
-template <class _Tp>
-void __test_implicit_default_constructible(_Tp);
-
-template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
-struct __is_implicitly_default_constructible
- : false_type
-{ };
-
-template <class _Tp>
-struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
- : true_type
-{ };
-
-template <class _Tp>
-struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
- : false_type
-{ };
-#endif // !C++03
-
-// is_copy_constructible
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
- : public is_constructible<_Tp,
- typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
-#endif
-
-// is_move_constructible
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_move_constructible
- : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
-#endif
-
-// is_trivially_constructible
-
-template <class _Tp, class... _Args>
-struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
- : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
-{
-};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class... _Args>
-inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
-#endif
-
-// is_trivially_default_constructible
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
- : public is_trivially_constructible<_Tp>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value;
-#endif
-
-// is_trivially_copy_constructible
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
- : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
-#endif
-
-// is_trivially_move_constructible
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
- : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
-#endif
-
-// is_trivially_assignable
-
-template <class _Tp, class _Arg>
-struct is_trivially_assignable
- : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
-{ };
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class _Arg>
-inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
-#endif
-
-// is_trivially_copy_assignable
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
- : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
- typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
-#endif
-
-// is_trivially_move_assignable
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
- : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
- typename add_rvalue_reference<_Tp>::type>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
-#endif
-
-// is_trivially_destructible
-
-#if __has_keyword(__is_trivially_destructible)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
- : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
-
-#elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
- : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
-
-#else
-
-template <class _Tp> struct __libcpp_trivial_destructor
- : public integral_constant<bool, is_scalar<_Tp>::value ||
- is_reference<_Tp>::value> {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
- : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
- : public false_type {};
-
-#endif
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
-#endif
-
-// is_nothrow_constructible
-
-#if __has_keyword(__is_nothrow_constructible)
-
-template <class _Tp, class... _Args>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
- : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
-
-#else
-
-template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
-
-template <class _Tp, class... _Args>
-struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
- : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
-{
-};
-
-template <class _Tp>
-void __implicit_conversion_to(_Tp) noexcept { }
-
-template <class _Tp, class _Arg>
-struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
- : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
-{
-};
-
-template <class _Tp, bool _IsReference, class... _Args>
-struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
- : public false_type
-{
-};
-
-template <class _Tp, class... _Args>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
- : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
-{
-};
-
-template <class _Tp, size_t _Ns>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
- : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
-{
-};
-
-#endif // _LIBCPP_HAS_NO_NOEXCEPT
-
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class ..._Args>
-inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
-#endif
-
-// is_nothrow_default_constructible
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
- : public is_nothrow_constructible<_Tp>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value;
-#endif
-
-// is_nothrow_copy_constructible
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
- : public is_nothrow_constructible<_Tp,
- typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
-#endif
-
-// is_nothrow_move_constructible
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
- : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
-#endif
-
-// is_nothrow_assignable
-
-#if __has_keyword(__is_nothrow_assignable)
-
-template <class _Tp, class _Arg>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
- : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
-
-#else
-
-template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
-
-template <class _Tp, class _Arg>
-struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
- : public false_type
-{
-};
-
-template <class _Tp, class _Arg>
-struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
- : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
-{
-};
-
-template <class _Tp, class _Arg>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
- : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
-{
-};
-
-#endif // _LIBCPP_HAS_NO_NOEXCEPT
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class _Arg>
-inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
-#endif
-
-// is_nothrow_copy_assignable
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
- : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
- typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
-#endif
-
-// is_nothrow_move_assignable
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
- : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
- typename add_rvalue_reference<_Tp>::type>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
-#endif
-
-// is_nothrow_destructible
-
-#if !defined(_LIBCPP_CXX03_LANG)
-
-template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
-
-template <class _Tp>
-struct __libcpp_is_nothrow_destructible<false, _Tp>
- : public false_type
-{
-};
-
-template <class _Tp>
-struct __libcpp_is_nothrow_destructible<true, _Tp>
- : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
-{
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
- : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
-{
-};
+// Member detector base
-template <class _Tp, size_t _Ns>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
- : public is_nothrow_destructible<_Tp>
-{
-};
+template <class _Tp, bool>
+struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
- : public true_type
-{
-};
+// is_integral
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
- : public true_type
-{
+struct __unconstref {
+ typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
};
-#else
-
-template <class _Tp> struct __libcpp_nothrow_destructor
- : public integral_constant<bool, is_scalar<_Tp>::value ||
- is_reference<_Tp>::value> {};
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
- : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
- : public false_type {};
-
-#endif
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
-#endif
-
-// is_pod
-
-#if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC)
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
- : public integral_constant<bool, __is_pod(_Tp)> {};
-
-#else
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
- : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
- is_trivially_copy_constructible<_Tp>::value &&
- is_trivially_copy_assignable<_Tp>::value &&
- is_trivially_destructible<_Tp>::value> {};
-
-#endif
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-inline constexpr bool is_pod_v = is_pod<_Tp>::value;
-#endif
-
-// is_literal_type;
-
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type
- : public integral_constant<bool, __is_literal_type(_Tp)>
- {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
-#endif // _LIBCPP_STD_VER > 14
-#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
-
-// is_standard_layout;
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
-#if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC)
- : public integral_constant<bool, __is_standard_layout(_Tp)>
-#else
- : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
-#endif
- {};
-
-#if _LIBCPP_STD_VER > 14
+#ifndef _LIBCPP_CXX03_LANG
+// First of all, we can't implement this check in C++03 mode because the {}
+// default initialization syntax isn't valid.
+// Second, we implement the trait in a funny manner with two defaulted template
+// arguments to workaround Clang's PR43454.
template <class _Tp>
-inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
-#endif
-
-// is_trivially_copyable;
+void __test_implicit_default_constructible(_Tp);
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
- : public integral_constant<bool, __is_trivially_copyable(_Tp)>
- {};
+template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
+struct __is_implicitly_default_constructible
+ : false_type
+{ };
-#if _LIBCPP_STD_VER > 14
template <class _Tp>
-inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
-#endif
-
-// is_trivial;
-
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
-#if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC)
- : public integral_constant<bool, __is_trivial(_Tp)>
-#else
- : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
- is_trivially_default_constructible<_Tp>::value>
-#endif
- {};
+struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
+ : true_type
+{ };
-#if _LIBCPP_STD_VER > 14
template <class _Tp>
-inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
-#endif
-
-template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
-template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
-template <class _Tp> struct __is_reference_wrapper
- : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template <class _Fp, class _A0,
- class _DecayFp = typename decay<_Fp>::type,
- class _DecayA0 = typename decay<_A0>::type,
- class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
-using __enable_if_bullet1 = typename enable_if
- <
- is_member_function_pointer<_DecayFp>::value
- && is_base_of<_ClassT, _DecayA0>::value
- >::type;
-
-template <class _Fp, class _A0,
- class _DecayFp = typename decay<_Fp>::type,
- class _DecayA0 = typename decay<_A0>::type>
-using __enable_if_bullet2 = typename enable_if
- <
- is_member_function_pointer<_DecayFp>::value
- && __is_reference_wrapper<_DecayA0>::value
- >::type;
-
-template <class _Fp, class _A0,
- class _DecayFp = typename decay<_Fp>::type,
- class _DecayA0 = typename decay<_A0>::type,
- class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
-using __enable_if_bullet3 = typename enable_if
- <
- is_member_function_pointer<_DecayFp>::value
- && !is_base_of<_ClassT, _DecayA0>::value
- && !__is_reference_wrapper<_DecayA0>::value
- >::type;
-
-template <class _Fp, class _A0,
- class _DecayFp = typename decay<_Fp>::type,
- class _DecayA0 = typename decay<_A0>::type,
- class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
-using __enable_if_bullet4 = typename enable_if
- <
- is_member_object_pointer<_DecayFp>::value
- && is_base_of<_ClassT, _DecayA0>::value
- >::type;
-
-template <class _Fp, class _A0,
- class _DecayFp = typename decay<_Fp>::type,
- class _DecayA0 = typename decay<_A0>::type>
-using __enable_if_bullet5 = typename enable_if
- <
- is_member_object_pointer<_DecayFp>::value
- && __is_reference_wrapper<_DecayA0>::value
- >::type;
-
-template <class _Fp, class _A0,
- class _DecayFp = typename decay<_Fp>::type,
- class _DecayA0 = typename decay<_A0>::type,
- class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
-using __enable_if_bullet6 = typename enable_if
- <
- is_member_object_pointer<_DecayFp>::value
- && !is_base_of<_ClassT, _DecayA0>::value
- && !__is_reference_wrapper<_DecayA0>::value
- >::type;
-
-// __invoke forward declarations
-
-// fall back - none of the bullets
-
-template <class ..._Args>
-auto __invoke(__any, _Args&& ...__args) -> __nat;
-
-template <class ..._Args>
-auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
-
-// bullets 1, 2 and 3
-
-template <class _Fp, class _A0, class ..._Args,
- class = __enable_if_bullet1<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
-__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
- noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
- -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
- { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
-
-template <class _Fp, class _A0, class ..._Args,
- class = __enable_if_bullet1<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR auto
-__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
- noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
- -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
- { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
-
-template <class _Fp, class _A0, class ..._Args,
- class = __enable_if_bullet2<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
-__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
- noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
- -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
- { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
-
-template <class _Fp, class _A0, class ..._Args,
- class = __enable_if_bullet2<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR auto
-__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
- noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
- -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
- { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
-
-template <class _Fp, class _A0, class ..._Args,
- class = __enable_if_bullet3<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
-__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
- noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
- -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
- { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
-
-template <class _Fp, class _A0, class ..._Args,
- class = __enable_if_bullet3<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR auto
-__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
- noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
- -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
- { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
-
-// bullets 4, 5 and 6
-
-template <class _Fp, class _A0,
- class = __enable_if_bullet4<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
-__invoke(_Fp&& __f, _A0&& __a0)
- noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
- -> decltype( static_cast<_A0&&>(__a0).*__f)
- { return static_cast<_A0&&>(__a0).*__f; }
-
-template <class _Fp, class _A0,
- class = __enable_if_bullet4<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR auto
-__invoke_constexpr(_Fp&& __f, _A0&& __a0)
- noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
- -> decltype( static_cast<_A0&&>(__a0).*__f)
- { return static_cast<_A0&&>(__a0).*__f; }
-
-template <class _Fp, class _A0,
- class = __enable_if_bullet5<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
-__invoke(_Fp&& __f, _A0&& __a0)
- noexcept(noexcept(__a0.get().*__f))
- -> decltype( __a0.get().*__f)
- { return __a0.get().*__f; }
-
-template <class _Fp, class _A0,
- class = __enable_if_bullet5<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR auto
-__invoke_constexpr(_Fp&& __f, _A0&& __a0)
- noexcept(noexcept(__a0.get().*__f))
- -> decltype( __a0.get().*__f)
- { return __a0.get().*__f; }
-
-template <class _Fp, class _A0,
- class = __enable_if_bullet6<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
-__invoke(_Fp&& __f, _A0&& __a0)
- noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
- -> decltype( (*static_cast<_A0&&>(__a0)).*__f)
- { return (*static_cast<_A0&&>(__a0)).*__f; }
-
-template <class _Fp, class _A0,
- class = __enable_if_bullet6<_Fp, _A0>>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR auto
-__invoke_constexpr(_Fp&& __f, _A0&& __a0)
- noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
- -> decltype( (*static_cast<_A0&&>(__a0)).*__f)
- { return (*static_cast<_A0&&>(__a0)).*__f; }
-
-// bullet 7
-
-template <class _Fp, class ..._Args>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
-__invoke(_Fp&& __f, _Args&& ...__args)
- noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
- -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
- { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
-
-template <class _Fp, class ..._Args>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR auto
-__invoke_constexpr(_Fp&& __f, _Args&& ...__args)
- noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
- -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
- { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
-
-// __invokable
-template <class _Ret, class _Fp, class ..._Args>
-struct __invokable_r
-{
- template <class _XFp, class ..._XArgs>
- static auto __try_call(int) -> decltype(
- _VSTD::__invoke(declval<_XFp>(), declval<_XArgs>()...));
- template <class _XFp, class ..._XArgs>
- static __nat __try_call(...);
-
- // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
- // or incomplete array types as required by the standard.
- using _Result = decltype(__try_call<_Fp, _Args...>(0));
-
- using type =
- typename conditional<
- _IsNotSame<_Result, __nat>::value,
- typename conditional<
- is_void<_Ret>::value,
- true_type,
- is_convertible<_Result, _Ret>
- >::type,
- false_type
- >::type;
- static const bool value = type::value;
-};
-template <class _Fp, class ..._Args>
-using __invokable = __invokable_r<void, _Fp, _Args...>;
-
-template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
-struct __nothrow_invokable_r_imp {
- static const bool value = false;
-};
-
-template <class _Ret, class _Fp, class ..._Args>
-struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
-{
- typedef __nothrow_invokable_r_imp _ThisT;
-
- template <class _Tp>
- static void __test_noexcept(_Tp) noexcept;
-
- static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
- _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
-};
-
-template <class _Ret, class _Fp, class ..._Args>
-struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
-{
- static const bool value = noexcept(
- _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
-};
-
-template <class _Ret, class _Fp, class ..._Args>
-using __nothrow_invokable_r =
- __nothrow_invokable_r_imp<
- __invokable_r<_Ret, _Fp, _Args...>::value,
- is_void<_Ret>::value,
- _Ret, _Fp, _Args...
- >;
-
-template <class _Fp, class ..._Args>
-using __nothrow_invokable =
- __nothrow_invokable_r_imp<
- __invokable<_Fp, _Args...>::value,
- true, void, _Fp, _Args...
- >;
-
-template <class _Fp, class ..._Args>
-struct __invoke_of
- : public enable_if<
- __invokable<_Fp, _Args...>::value,
- typename __invokable_r<void, _Fp, _Args...>::_Result>
-{
-};
-
-#endif // _LIBCPP_CXX03_LANG
+struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
+ : false_type
+{ };
+#endif // !C++03
// result_of
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Fp, class ..._Args>
class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
: public __invoke_of<_Fp, _Args...>
{
};
-#else // C++03
-
-template <class _Fn, bool, bool>
-class __result_of
-{
-};
-
-template <class _Fn, class ..._Args>
-class __result_of<_Fn(_Args...), true, false>
-{
-public:
- typedef decltype(declval<_Fn>()(declval<_Args>()...)) type;
-};
-
-template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
-struct __result_of_mp;
-
-// member function pointer
-
-template <class _MP, class _Tp>
-struct __result_of_mp<_MP, _Tp, true>
-{
- using type = typename __member_pointer_traits<_MP>::_ReturnType;
-};
-
-// member data pointer
-
-template <class _MP, class _Tp, bool>
-struct __result_of_mdp;
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mdp<_Rp _Class::*, _Tp, false>
-{
- using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&;
-};
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mdp<_Rp _Class::*, _Tp, true>
-{
- using type = typename __apply_cv<_Tp, _Rp>::type&;
-};
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mp<_Rp _Class::*, _Tp, false>
- : public __result_of_mdp<_Rp _Class::*, _Tp,
- is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
-{
-};
-
-template <class _Fn, class _Tp>
-class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
- : public __result_of_mp<typename remove_reference<_Fn>::type,
- _Tp,
- is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
-{
-};
-
-template <class _Fn, class _Tp, class ..._Args>
-class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer
- : public __result_of_mp<typename remove_reference<_Fn>::type,
- _Tp,
- is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
-{
-};
-
-template <class _Fn, class ..._Args>
-class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
- : public __result_of<_Fn(_Args...),
- is_class<typename remove_reference<_Fn>::type>::value ||
- is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
- is_member_pointer<typename remove_reference<_Fn>::type>::value
- >
-{
-};
-
-#endif // C++03
-
#if _LIBCPP_STD_VER > 11
template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
#endif // _LIBCPP_STD_VER > 11
#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
-#if _LIBCPP_STD_VER > 14
-
-// invoke_result
-
-template <class _Fn, class... _Args>
-struct _LIBCPP_TEMPLATE_VIS invoke_result
- : __invoke_of<_Fn, _Args...>
-{
-};
-
-template <class _Fn, class... _Args>
-using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
-
-// is_invocable
-
-template <class _Fn, class ..._Args>
-struct _LIBCPP_TEMPLATE_VIS is_invocable
- : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
-
-template <class _Ret, class _Fn, class ..._Args>
-struct _LIBCPP_TEMPLATE_VIS is_invocable_r
- : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
-
-template <class _Fn, class ..._Args>
-inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
-
-template <class _Ret, class _Fn, class ..._Args>
-inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
-
-// is_nothrow_invocable
-
-template <class _Fn, class ..._Args>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
- : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
-
-template <class _Ret, class _Fn, class ..._Args>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
- : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
-
-template <class _Fn, class ..._Args>
-inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
-
-template <class _Ret, class _Fn, class ..._Args>
-inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
-
-#endif // _LIBCPP_STD_VER > 14
-
// __swappable
template <class _Tp> struct __is_swappable;
@@ -3999,24 +720,6 @@ inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
#endif // _LIBCPP_STD_VER > 14
-template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl;
-
-template <class _Tp>
-struct __underlying_type_impl<_Tp, false> {};
-
-template <class _Tp>
-struct __underlying_type_impl<_Tp, true>
-{
- typedef __underlying_type(_Tp) type;
-};
-
-template <class _Tp>
-struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
-#endif
-
template <class _Tp, bool = is_enum<_Tp>::value>
struct __sfinae_underlying_type
{
@@ -4063,42 +766,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename __sfinae_underlying_type<_Tp>::__promoted_type
__convert_to_integral(_Tp __val) { return __val; }
-// is_scoped_enum [meta.unary.prop]
-
-#if _LIBCPP_STD_VER > 20
-template <class _Tp, bool = is_enum_v<_Tp> >
-struct __is_scoped_enum_helper : false_type {};
-
-template <class _Tp>
-struct __is_scoped_enum_helper<_Tp, true>
- : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
- : public __is_scoped_enum_helper<_Tp> {};
-
-template <class _Tp>
-inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
-#endif
-
-#if _LIBCPP_STD_VER > 14
-
-template <class... _Args>
-struct conjunction : _And<_Args...> {};
-template<class... _Args>
-inline constexpr bool conjunction_v = conjunction<_Args...>::value;
-
-template <class... _Args>
-struct disjunction : _Or<_Args...> {};
-template<class... _Args>
-inline constexpr bool disjunction_v = disjunction<_Args...>::value;
-
-template <class _Tp>
-struct negation : _Not<_Tp> {};
-template<class _Tp>
-inline constexpr bool negation_v = negation<_Tp>::value;
-#endif // _LIBCPP_STD_VER > 14
-
// These traits are used in __tree and __hash_table
struct __extract_key_fail_tag {};
struct __extract_key_self_tag {};
@@ -4129,26 +796,14 @@ template <class _ValTy, class _Key, class _RawValTy>
struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
: false_type {};
-#if _LIBCPP_STD_VER > 17
-_LIBCPP_INLINE_VISIBILITY
-inline constexpr bool is_constant_evaluated() noexcept {
- return __builtin_is_constant_evaluated();
-}
-#endif
-
-inline _LIBCPP_CONSTEXPR
-bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
-
template <class _CharT>
using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
template<class _Tp>
using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&;
-#if _LIBCPP_STD_VER > 17
template<bool _Const, class _Tp>
-using __maybe_const = conditional_t<_Const, const _Tp, _Tp>;
-#endif // _LIBCPP_STD_VER > 17
+using __maybe_const = typename conditional<_Const, const _Tp, _Tp>::type;
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/typeindex
@@ -44,15 +44,23 @@ struct hash<type_index>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__functional/unary_function.h>
-#include <__functional_base>
-#include <compare>
#include <typeinfo>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iosfwd>
+# include <new>
+# include <utility>
+#endif
+
+// standard-mandated includes
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -93,7 +101,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
template <>
struct _LIBCPP_TEMPLATE_VIS hash<type_index>
- : public unary_function<type_index, size_t>
+ : public __unary_function<type_index, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(type_index __index) const _NOEXCEPT
lib/libcxx/include/typeinfo
@@ -56,6 +56,7 @@ public:
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <cstddef>
@@ -68,7 +69,7 @@ public:
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#if defined(_LIBCPP_ABI_VCRUNTIME)
lib/libcxx/include/uchar.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_UCHAR_H
+#define _LIBCPP_UCHAR_H
+
+/*
+ uchar.h synopsis // since C++11
+
+Macros:
+
+ __STDC_UTF_16__
+ __STDC_UTF_32__
+
+Types:
+
+ mbstate_t
+ size_t
+
+size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
+size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
+size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
+size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+// Some platforms don't implement <uchar.h> and we don't want to give a hard
+// error on those platforms. When the platform doesn't provide <uchar.h>, at
+// least include <stddef.h> so we get the declaration for size_t.
+#if __has_include_next(<uchar.h>)
+# include_next <uchar.h>
+#else
+# include <stddef.h>
+#endif
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP_UCHAR_H
lib/libcxx/include/unordered_map
@@ -514,23 +514,44 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
*/
+#include <__algorithm/is_permutation.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__debug>
#include <__functional/is_transparent.h>
+#include <__functional/operations.h>
#include <__hash_table>
+#include <__iterator/distance.h>
+#include <__iterator/erase_if_container.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
#include <__node_handle>
#include <__utility/forward.h>
-#include <compare>
-#include <functional>
-#include <iterator> // __libcpp_erase_if_container
#include <stdexcept>
#include <tuple>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <bit>
+# include <iterator>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [unord.map.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -855,9 +876,7 @@ public:
}
template <class _ValueTp,
- class = typename enable_if<
- __is_same_uncvref<_ValueTp, value_type>::value
- >::type
+ class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value>
>
_LIBCPP_INLINE_VISIBILITY
__hash_value_type& operator=(_ValueTp&& __v)
@@ -1012,9 +1031,9 @@ public:
// types
typedef _Key key_type;
typedef _Tp mapped_type;
- typedef __identity_t<_Hash> hasher;
- typedef __identity_t<_Pred> key_equal;
- typedef __identity_t<_Alloc> allocator_type;
+ typedef __type_identity_t<_Hash> hasher;
+ typedef __type_identity_t<_Pred> key_equal;
+ typedef __type_identity_t<_Alloc> allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -1216,13 +1235,13 @@ public:
}
template <class _Pp,
- class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert(_Pp&& __x)
{return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
template <class _Pp,
- class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __p, _Pp&& __x)
{
@@ -1506,11 +1525,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY
- void rehash(size_type __n) {__table_.rehash(__n);}
+ void rehash(size_type __n) {__table_.__rehash_unique(__n);}
_LIBCPP_INLINE_VISIBILITY
- void reserve(size_type __n) {__table_.reserve(__n);}
+ void reserve(size_type __n) {__table_.__reserve_unique(__n);}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
@@ -1521,7 +1540,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
@@ -1607,7 +1626,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1617,7 +1636,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1646,7 +1665,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__first, __last);
}
@@ -1658,7 +1677,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__first, __last);
}
@@ -1668,7 +1687,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__u.__table_)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -1678,7 +1697,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__u.__table_, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -1692,9 +1711,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(_VSTD::move(__u.__table_))
{
_VSTD::__debug_db_insert_c(this);
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1711,10 +1728,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
__u.__table_.remove((__i++).__i_)->__value_.__move());
}
}
-#if _LIBCPP_DEBUG_LEVEL == 2
else
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1732,7 +1747,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__il.begin(), __il.end());
}
@@ -1743,7 +1758,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__il.begin(), __il.end());
}
@@ -1906,9 +1921,9 @@ public:
// types
typedef _Key key_type;
typedef _Tp mapped_type;
- typedef __identity_t<_Hash> hasher;
- typedef __identity_t<_Pred> key_equal;
- typedef __identity_t<_Alloc> allocator_type;
+ typedef __type_identity_t<_Hash> hasher;
+ typedef __type_identity_t<_Pred> key_equal;
+ typedef __type_identity_t<_Alloc> allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -2097,13 +2112,13 @@ public:
{return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));}
template <class _Pp,
- class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
_LIBCPP_INLINE_VISIBILITY
iterator insert(_Pp&& __x)
{return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
template <class _Pp,
- class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+ class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __p, _Pp&& __x)
{return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
@@ -2286,11 +2301,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY
- void rehash(size_type __n) {__table_.rehash(__n);}
+ void rehash(size_type __n) {__table_.__rehash_multi(__n);}
_LIBCPP_INLINE_VISIBILITY
- void reserve(size_type __n) {__table_.reserve(__n);}
+ void reserve(size_type __n) {__table_.__reserve_multi(__n);}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
@@ -2301,7 +2316,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
};
@@ -2383,7 +2398,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -2393,7 +2408,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -2413,7 +2428,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__first, __last);
}
@@ -2425,7 +2440,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__first, __last);
}
@@ -2444,7 +2459,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__u.__table_)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -2454,7 +2469,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__u.__table_, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -2468,9 +2483,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(_VSTD::move(__u.__table_))
{
_VSTD::__debug_db_insert_c(this);
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -2488,10 +2501,8 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
__u.__table_.remove((__i++).__i_)->__value_.__move());
}
}
-#if _LIBCPP_DEBUG_LEVEL == 2
else
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -2509,7 +2520,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__il.begin(), __il.end());
}
@@ -2520,7 +2531,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__il.begin(), __il.end());
}
lib/libcxx/include/unordered_set
@@ -459,20 +459,41 @@ template <class Value, class Hash, class Pred, class Alloc>
*/
+#include <__algorithm/is_permutation.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__debug>
#include <__functional/is_transparent.h>
+#include <__functional/operations.h>
#include <__hash_table>
+#include <__iterator/distance.h>
+#include <__iterator/erase_if_container.h>
+#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
#include <__node_handle>
#include <__utility/forward.h>
-#include <compare>
-#include <functional>
-#include <iterator> // __libcpp_erase_if_container
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <functional>
+# include <iterator>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [unord.set.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -488,9 +509,9 @@ public:
// types
typedef _Value key_type;
typedef key_type value_type;
- typedef __identity_t<_Hash> hasher;
- typedef __identity_t<_Pred> key_equal;
- typedef __identity_t<_Alloc> allocator_type;
+ typedef __type_identity_t<_Hash> hasher;
+ typedef __type_identity_t<_Pred> key_equal;
+ typedef __type_identity_t<_Alloc> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
@@ -637,36 +658,27 @@ public:
pair<iterator, bool> emplace(_Args&&... __args)
{return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL == 2
- iterator emplace_hint(const_iterator __p, _Args&&... __args)
- {
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
- "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
- " referring to this unordered_set");
- return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
- }
-#else
- iterator emplace_hint(const_iterator, _Args&&... __args)
- {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
-#endif
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace_hint(const_iterator __p, _Args&&... __args) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
+ "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
+ " referring to this unordered_set");
+ (void)__p;
+ return __table_.__emplace_unique(std::forward<_Args>(__args)...).first;
+ }
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert(value_type&& __x)
{return __table_.__insert_unique(_VSTD::move(__x));}
_LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL == 2
- iterator insert(const_iterator __p, value_type&& __x)
- {
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
- "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
- " referring to this unordered_set");
- return insert(_VSTD::move(__x)).first;
- }
-#else
- iterator insert(const_iterator, value_type&& __x)
- {return insert(_VSTD::move(__x)).first;}
-#endif
+ iterator insert(const_iterator __p, value_type&& __x) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
+ "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
+ " referring to this unordered_set");
+ (void)__p;
+ return insert(std::move(__x)).first;
+ }
+
_LIBCPP_INLINE_VISIBILITY
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
@@ -676,18 +688,13 @@ public:
{return __table_.__insert_unique(__x);}
_LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL == 2
- iterator insert(const_iterator __p, const value_type& __x)
- {
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
- "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
- " referring to this unordered_set");
- return insert(__x).first;
- }
-#else
- iterator insert(const_iterator, const value_type& __x)
- {return insert(__x).first;}
-#endif
+ iterator insert(const_iterator __p, const value_type& __x) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
+ "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
+ " referring to this unordered_set");
+ (void)__p;
+ return insert(__x).first;
+ }
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
void insert(_InputIterator __first, _InputIterator __last);
@@ -851,11 +858,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY
- void rehash(size_type __n) {__table_.rehash(__n);}
+ void rehash(size_type __n) {__table_.__rehash_unique(__n);}
_LIBCPP_INLINE_VISIBILITY
- void reserve(size_type __n) {__table_.reserve(__n);}
+ void reserve(size_type __n) {__table_.__reserve_unique(__n);}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(__i);}
@@ -866,7 +873,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(__i, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
};
@@ -935,7 +942,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -944,7 +951,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -964,7 +971,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__first, __last);
}
@@ -976,7 +983,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__first, __last);
}
@@ -995,7 +1002,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__u.__table_)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -1005,7 +1012,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__u.__table_, __a)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -1019,9 +1026,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(_VSTD::move(__u.__table_))
{
_VSTD::__debug_db_insert_c(this);
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -1036,10 +1041,8 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
while (__u.size() != 0)
__table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
}
-#if _LIBCPP_DEBUG_LEVEL == 2
else
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -1057,7 +1060,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__il.begin(), __il.end());
}
@@ -1068,7 +1071,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_unique(__n);
insert(__il.begin(), __il.end());
}
@@ -1162,9 +1165,9 @@ public:
// types
typedef _Value key_type;
typedef key_type value_type;
- typedef __identity_t<_Hash> hasher;
- typedef __identity_t<_Pred> key_equal;
- typedef __identity_t<_Alloc> allocator_type;
+ typedef __type_identity_t<_Hash> hasher;
+ typedef __type_identity_t<_Pred> key_equal;
+ typedef __type_identity_t<_Alloc> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
@@ -1493,11 +1496,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY
- void rehash(size_type __n) {__table_.rehash(__n);}
+ void rehash(size_type __n) {__table_.__rehash_multi(__n);}
_LIBCPP_INLINE_VISIBILITY
- void reserve(size_type __n) {__table_.reserve(__n);}
+ void reserve(size_type __n) {__table_.__reserve_multi(__n);}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(__i);}
@@ -1508,7 +1511,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(__i, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
};
@@ -1575,7 +1578,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -1585,7 +1588,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -1605,7 +1608,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__first, __last);
}
@@ -1617,7 +1620,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__first, __last);
}
@@ -1636,7 +1639,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__u.__table_)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -1646,7 +1649,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__u.__table_, __a)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__u.bucket_count());
+ __table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@@ -1660,9 +1663,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(_VSTD::move(__u.__table_))
{
_VSTD::__debug_db_insert_c(this);
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -1677,10 +1678,8 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
while (__u.size() != 0)
__table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
}
-#if _LIBCPP_DEBUG_LEVEL == 2
else
- __get_db()->swap(this, _VSTD::addressof(__u));
-#endif
+ std::__debug_db_swap(this, std::addressof(__u));
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@@ -1698,7 +1697,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__il.begin(), __il.end());
}
@@ -1709,7 +1708,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
- __table_.rehash(__n);
+ __table_.__rehash_multi(__n);
insert(__il.begin(), __il.end());
}
lib/libcxx/include/utility
@@ -95,6 +95,12 @@ struct pair
is_nothrow_swappable_v<T2>); // constexpr in C++20
};
+template<class T1, class T2, class U1, class U2, template<class> class TQual, template<class> class UQual>
+struct basic_common_reference<pair<T1, T2>, pair<U1, U2>, TQual, UQual>; // since C++23
+
+template<class T1, class T2, class U1, class U2>
+struct common_type<pair<T1, T2>, pair<U1, U2>>; // since C++23
+
template<class T1, class T2> pair(T1, T2) -> pair<T1, T2>;
template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
@@ -214,8 +220,8 @@ template <class T>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__debug>
#include <__tuple>
#include <__utility/as_const.h>
#include <__utility/auto_cast.h>
@@ -233,12 +239,20 @@ template <class T>
#include <__utility/swap.h>
#include <__utility/to_underlying.h>
#include <__utility/transaction.h>
+#include <__utility/unreachable.h>
+#include <type_traits>
+#include <version>
+
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <iosfwd>
+#endif
+
+// standard-mandated includes
#include <compare>
#include <initializer_list>
-#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#endif // _LIBCPP_UTILITY
lib/libcxx/include/valarray
@@ -341,17 +341,35 @@ template <class T> unspecified2 end(const valarray<T>& v);
*/
+#include <__algorithm/copy.h>
+#include <__algorithm/count.h>
+#include <__algorithm/fill.h>
+#include <__algorithm/max_element.h>
+#include <__algorithm/min.h>
+#include <__algorithm/min_element.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <algorithm>
+#include <__functional/operations.h>
+#include <__memory/allocator.h>
+#include <__memory/uninitialized_algorithms.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <cmath>
#include <cstddef>
-#include <functional>
-#include <initializer_list>
#include <new>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <functional>
+#endif
+
+// standard-mandated includes
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -912,10 +930,14 @@ public:
#endif // _LIBCPP_CXX03_LANG
// unary operators:
- valarray operator+() const;
- valarray operator-() const;
- valarray operator~() const;
- valarray<bool> operator!() const;
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const;
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const;
+ _LIBCPP_INLINE_VISIBILITY
+ __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const;
// computed assignment:
_LIBCPP_INLINE_VISIBILITY
@@ -1089,7 +1111,7 @@ template<class _Tp, size_t _Size>
valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>;
#endif
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
+extern template _LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t);
template <class _Op, class _Tp>
struct _UnaryOp<_Op, valarray<_Tp> >
@@ -1530,21 +1552,21 @@ public:
gslice(size_t __start, const valarray<size_t>& __size,
valarray<size_t>&& __stride)
: __size_(__size),
- __stride_(move(__stride))
+ __stride_(std::move(__stride))
{__init(__start);}
_LIBCPP_INLINE_VISIBILITY
gslice(size_t __start, valarray<size_t>&& __size,
const valarray<size_t>& __stride)
- : __size_(move(__size)),
+ : __size_(std::move(__size)),
__stride_(__stride)
{__init(__start);}
_LIBCPP_INLINE_VISIBILITY
gslice(size_t __start, valarray<size_t>&& __size,
valarray<size_t>&& __stride)
- : __size_(move(__size)),
- __stride_(move(__stride))
+ : __size_(std::move(__size)),
+ __stride_(std::move(__stride))
{__init(__start);}
#endif // _LIBCPP_CXX03_LANG
@@ -1695,7 +1717,7 @@ private:
#ifndef _LIBCPP_CXX03_LANG
gslice_array(gslice&& __gs, const valarray<value_type>& __v)
: __vp_(const_cast<value_type*>(__v.__begin_)),
- __1d_(move(__gs.__1d_))
+ __1d_(std::move(__gs.__1d_))
{}
#endif // _LIBCPP_CXX03_LANG
@@ -2389,7 +2411,7 @@ private:
_LIBCPP_INLINE_VISIBILITY
indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
: __vp_(const_cast<value_type*>(__v.__begin_)),
- __1d_(move(__ia))
+ __1d_(std::move(__ia))
{}
#endif // _LIBCPP_CXX03_LANG
@@ -2608,7 +2630,7 @@ private:
_LIBCPP_INLINE_VISIBILITY
__indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
: __expr_(__e),
- __1d_(move(__ia))
+ __1d_(std::move(__ia))
{}
#endif // _LIBCPP_CXX03_LANG
@@ -3203,7 +3225,7 @@ inline
__val_expr<__indirect_expr<const valarray<_Tp>&> >
valarray<_Tp>::operator[](gslice&& __gs) const
{
- return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
+ return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this));
}
template <class _Tp>
@@ -3211,7 +3233,7 @@ inline
gslice_array<_Tp>
valarray<_Tp>::operator[](gslice&& __gs)
{
- return gslice_array<value_type>(move(__gs), *this);
+ return gslice_array<value_type>(std::move(__gs), *this);
}
#endif // _LIBCPP_CXX03_LANG
@@ -3239,7 +3261,7 @@ inline
__val_expr<__mask_expr<const valarray<_Tp>&> >
valarray<_Tp>::operator[](valarray<bool>&& __vb) const
{
- return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
+ return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this));
}
template <class _Tp>
@@ -3247,7 +3269,7 @@ inline
mask_array<_Tp>
valarray<_Tp>::operator[](valarray<bool>&& __vb)
{
- return mask_array<value_type>(move(__vb), *this);
+ return mask_array<value_type>(std::move(__vb), *this);
}
#endif // _LIBCPP_CXX03_LANG
@@ -3275,7 +3297,7 @@ inline
__val_expr<__indirect_expr<const valarray<_Tp>&> >
valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
{
- return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
+ return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this));
}
template <class _Tp>
@@ -3283,69 +3305,45 @@ inline
indirect_array<_Tp>
valarray<_Tp>::operator[](valarray<size_t>&& __vs)
{
- return indirect_array<value_type>(move(__vs), *this);
+ return indirect_array<value_type>(std::move(__vs), *this);
}
#endif // _LIBCPP_CXX03_LANG
template <class _Tp>
-valarray<_Tp>
+inline
+__val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> >
valarray<_Tp>::operator+() const
{
- valarray<value_type> __r;
- size_t __n = size();
- if (__n)
- {
- __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
- for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new ((void*)__r.__end_) value_type(+*__p);
- }
- return __r;
+ using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>;
+ return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this));
}
template <class _Tp>
-valarray<_Tp>
+inline
+__val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> >
valarray<_Tp>::operator-() const
{
- valarray<value_type> __r;
- size_t __n = size();
- if (__n)
- {
- __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
- for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new ((void*)__r.__end_) value_type(-*__p);
- }
- return __r;
+ using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>;
+ return __val_expr<_Op>(_Op(negate<_Tp>(), *this));
}
template <class _Tp>
-valarray<_Tp>
+inline
+__val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> >
valarray<_Tp>::operator~() const
{
- valarray<value_type> __r;
- size_t __n = size();
- if (__n)
- {
- __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
- for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new ((void*)__r.__end_) value_type(~*__p);
- }
- return __r;
+ using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>;
+ return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this));
}
template <class _Tp>
-valarray<bool>
+inline
+__val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> >
valarray<_Tp>::operator!() const
{
- valarray<bool> __r;
- size_t __n = size();
- if (__n)
- {
- __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n);
- for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
- ::new ((void*)__r.__end_) bool(!*__p);
- }
- return __r;
+ using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>;
+ return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this));
}
template <class _Tp>
lib/libcxx/include/variant
@@ -199,24 +199,36 @@ namespace std {
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <__functional/hash.h>
+#include <__functional/operations.h>
+#include <__functional/unary_function.h>
#include <__tuple>
#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <__variant/monostate.h>
-#include <compare>
#include <exception>
#include <initializer_list>
#include <limits>
#include <new>
#include <tuple>
#include <type_traits>
-#include <utility>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <typeinfo>
+# include <utility>
+#endif
+
+// standard-mandated includes
+#include <compare>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -533,7 +545,7 @@ private:
template <class _Fp, class... _Vs>
inline _LIBCPP_INLINE_VISIBILITY
static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
- return _VSTD::__invoke_constexpr(
+ return _VSTD::__invoke(
static_cast<_Fp>(__f),
__access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);
}
@@ -549,7 +561,7 @@ private:
inline _LIBCPP_INLINE_VISIBILITY
static constexpr auto __make_fdiagonal_impl() {
return __make_dispatch<_Fp, _Vs...>(
- index_sequence<((void)__identity<_Vs>{}, _Ip)...>{});
+ index_sequence<((void)__type_identity<_Vs>{}, _Ip)...>{});
}
template <class _Fp, class... _Vs, size_t... _Is>
@@ -653,8 +665,8 @@ private:
__std_visit_exhaustive_visitor_check<
_Visitor,
decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
- return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
- _VSTD::forward<_Alts>(__alts).__value...);
+ return _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Alts>(__alts).__value...);
}
_Visitor&& __visitor;
};
@@ -669,12 +681,12 @@ private:
_Visitor,
decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
if constexpr (is_void_v<_Rp>) {
- _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
- _VSTD::forward<_Alts>(__alts).__value...);
+ _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Alts>(__alts).__value...);
}
else {
- return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
- _VSTD::forward<_Alts>(__alts).__value...);
+ return _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Alts>(__alts).__value...);
}
}
@@ -765,8 +777,8 @@ public:
using __index_t = __variant_index_t<sizeof...(_Types)>;
inline _LIBCPP_INLINE_VISIBILITY
- explicit constexpr __base(__valueless_t tag) noexcept
- : __data(tag), __index(__variant_npos<__index_t>) {}
+ explicit constexpr __base(__valueless_t __tag) noexcept
+ : __data(__tag), __index(__variant_npos<__index_t>) {}
template <size_t _Ip, class... _Args>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1121,8 +1133,11 @@ class _LIBCPP_TEMPLATE_VIS __impl
using __base_type = __copy_assignment<__traits<_Types...>>;
public:
- using __base_type::__base_type;
- using __base_type::operator=;
+ using __base_type::__base_type; // get in_place_index_t constructor & friends
+ __impl(__impl const&) = default;
+ __impl(__impl&&) = default;
+ __impl& operator=(__impl const&) = default;
+ __impl& operator=(__impl&&) = default;
template <size_t _Ip, class _Arg>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1186,12 +1201,12 @@ private:
struct __no_narrowing_check {
template <class _Dest, class _Source>
- using _Apply = __identity<_Dest>;
+ using _Apply = __type_identity<_Dest>;
};
struct __narrowing_check {
template <class _Dest>
- static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>;
+ static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>;
template <class _Dest, class _Source>
using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()}));
};
@@ -1217,7 +1232,7 @@ template <class _Tp, size_t>
struct __overload_bool {
template <class _Up, class _Ap = __uncvref_t<_Up>>
auto operator()(bool, _Up&&) const
- -> enable_if_t<is_same_v<_Ap, bool>, __identity<_Tp>>;
+ -> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>;
};
template <size_t _Idx>
lib/libcxx/include/vector
@@ -271,20 +271,35 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
*/
+#include <__algorithm/copy.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__algorithm/rotate.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__bit_reference>
#include <__config>
#include <__debug>
-#include <__functional_base>
+#include <__format/enable_insertable.h>
+#include <__functional/hash.h>
+#include <__functional/unary_function.h>
+#include <__iterator/advance.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
#include <__iterator/wrap_iter.h>
+#include <__memory/allocate_at_least.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/swap_allocator.h>
#include <__split_buffer>
#include <__utility/forward.h>
-#include <algorithm>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <climits>
-#include <compare>
#include <cstdlib>
#include <cstring>
-#include <initializer_list>
#include <iosfwd> // for forward declaration of vector
#include <limits>
#include <memory>
@@ -292,8 +307,27 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
#include <type_traits>
#include <version>
+#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+# include <algorithm>
+# include <typeinfo>
+# include <utility>
+#endif
+
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
+// [vector.syn]
+#include <compare>
+#include <initializer_list>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
@@ -326,12 +360,12 @@ public:
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
{
_VSTD::__debug_db_insert_c(this);
}
- _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
@@ -341,13 +375,14 @@ public:
{
_VSTD::__debug_db_insert_c(this);
}
- explicit vector(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
- explicit vector(size_type __n, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
#endif
- vector(size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x);
template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
@@ -360,21 +395,22 @@ public:
}
template <class _InputIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(_InputIterator __first,
- typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
_InputIterator>::type __last);
template <class _InputIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(_ForwardIterator __first,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
@@ -382,19 +418,18 @@ public:
typename iterator_traits<_ForwardIterator>::reference>::value,
_ForwardIterator>::type __last);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
~vector()
{
__annotate_delete();
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__erase_c(this);
-#endif
+ std::__debug_db_erase_c(this);
if (this->__begin_ != nullptr)
{
@@ -403,43 +438,39 @@ public:
}
}
- vector(const vector& __x);
- vector(const vector& __x, const __identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector& operator=(const vector& __x);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il, const allocator_type& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ vector& operator=(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end()); return *this;}
+#endif // !_LIBCPP_CXX03_LANG
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
- _NOEXCEPT;
+ noexcept;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
- _LIBCPP_INLINE_VISIBILITY
- vector(vector&& __x, const __identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
- _LIBCPP_INLINE_VISIBILITY
- vector& operator=(initializer_list<value_type> __il)
- {assign(__il.begin(), __il.end()); return *this;}
-
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _InputIterator>
- typename enable_if
- <
- __is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -447,6 +478,7 @@ public:
>::type
assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -457,137 +489,120 @@ public:
>::type
assign(_ForwardIterator __first, _ForwardIterator __last);
- void assign(size_type __n, const_reference __u);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const_reference __u);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
{return this->__alloc();}
- _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_iterator cbegin() const _NOEXCEPT
{return begin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_iterator cend() const _NOEXCEPT
{return end();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT
{return static_cast<size_type>(this->__end_ - this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
size_type capacity() const _NOEXCEPT
{return static_cast<size_type>(__end_cap() - this->__begin_);}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{return this->__begin_ == this->__end_;}
- size_type max_size() const _NOEXCEPT;
- void reserve(size_type __n);
- void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
- reference at(size_type __n);
- const_reference at(size_type __n) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
- _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
return *this->__begin_;
}
- _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
return *this->__begin_;
}
- _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
return *(this->__end_ - 1);
}
- _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
return *(this->__end_ - 1);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
value_type* data() _NOEXCEPT
{return _VSTD::__to_address(this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const value_type* data() const _NOEXCEPT
{return _VSTD::__to_address(this->__begin_);}
-#ifdef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
- void __emplace_back(const value_type& __x) { push_back(__x); }
-#else
- template <class _Arg>
- _LIBCPP_INLINE_VISIBILITY
- void __emplace_back(_Arg&& __arg) {
- emplace_back(_VSTD::forward<_Arg>(__arg));
- }
-#endif
-
- _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
#if _LIBCPP_STD_VER > 14
reference emplace_back(_Args&&... __args);
#else
void emplace_back(_Args&&... __args);
#endif
-#endif // !_LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void pop_back();
- iterator insert(const_iterator __position, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const_reference __x);
-#ifndef _LIBCPP_CXX03_LANG
- iterator insert(const_iterator __position, value_type&& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, value_type&& __x);
template <class... _Args>
- iterator emplace(const_iterator __position, _Args&&... __args);
-#endif // !_LIBCPP_CXX03_LANG
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args);
- iterator insert(const_iterator __position, size_type __n, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const_reference __x);
template <class _InputIterator>
- typename enable_if
- <
- __is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -595,6 +610,7 @@ public:
>::type
insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -606,27 +622,27 @@ public:
insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
- iterator erase(const_iterator __first, const_iterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{
size_type __old_size = size();
__clear();
__annotate_shrink(__old_size);
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
}
- void resize(size_type __sz);
- void resize(size_type __sz, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, const_reference __x);
- void swap(vector&)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
@@ -634,16 +650,16 @@ public:
__is_nothrow_swappable<allocator_type>::value);
#endif
- bool __invariants() const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
pointer __begin_ = nullptr;
@@ -651,95 +667,108 @@ private:
__compressed_pair<pointer, allocator_type> __end_cap_ =
__compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());
- _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
- void __vallocate(size_type __n);
- void __vdeallocate() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
- void __construct_at_end(size_type __n);
- _LIBCPP_INLINE_VISIBILITY
+
+ // Allocate space for __n objects
+ // throws length_error if __n > max_size()
+ // throws (probably bad_alloc) if memory run out
+ // Precondition: __begin_ == __end_ == __end_cap() == 0
+ // Precondition: __n > 0
+ // Postcondition: capacity() >= __n
+ // Postcondition: size() == 0
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
+ if (__n > max_size())
+ __throw_length_error();
+ auto __allocation = std::__allocate_at_least(__alloc(), __n);
+ __begin_ = __allocation.ptr;
+ __end_ = __allocation.ptr;
+ __end_cap() = __begin_ + __allocation.count;
+ __annotate_new(0);
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __construct_at_end(size_type __n, const_reference __x);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
- void __append(size_type __n);
- void __append(size_type __n, const_reference __x);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
iterator __make_iter(pointer __p) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
- void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
- pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
- void __move_range(pointer __from_s, pointer __from_e, pointer __to);
- void __move_assign(vector& __c, true_type)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_range(pointer __from_s, pointer __from_e, pointer __to);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
- void __move_assign(vector& __c, false_type)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{
- __invalidate_iterators_past(__new_last);
+ if (!__libcpp_is_constant_evaluated())
+ __invalidate_iterators_past(__new_last);
size_type __old_size = size();
__base_destruct_at_end(__new_last);
__annotate_shrink(__old_size);
}
-#ifndef _LIBCPP_CXX03_LANG
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
inline void __push_back_slow_path(_Up&& __x);
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
inline void __emplace_back_slow_path(_Args&&... __args);
-#else
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- inline void __push_back_slow_path(_Up& __x);
-#endif
// The following functions are no-ops outside of AddressSanitizer mode.
// We call annotatations only for the default Allocator because other allocators
// may not meet the AddressSanitizer alignment constraints.
// See the documentation for __sanitizer_annotate_contiguous_container for more details.
#ifndef _LIBCPP_HAS_NO_ASAN
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
void __annotate_contiguous_container(const void *__beg, const void *__end,
const void *__old_mid,
const void *__new_mid) const
{
- if (__beg && is_same<allocator_type, __default_allocator_type>::value)
+ if (!__libcpp_is_constant_evaluated() && __beg && is_same<allocator_type, __default_allocator_type>::value)
__sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
}
#else
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_contiguous_container(const void*, const void*, const void*,
const void*) const _NOEXCEPT {}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_new(size_type __current_size) const _NOEXCEPT {
__annotate_contiguous_container(data(), data() + capacity(),
data() + capacity(), data() + __current_size);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_delete() const _NOEXCEPT {
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + capacity());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_increase(size_type __n) const _NOEXCEPT
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + size() + __n);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_shrink(size_type __old_size) const _NOEXCEPT
{
__annotate_contiguous_container(data(), data() + capacity(),
@@ -747,13 +776,14 @@ private:
}
struct _ConstructTransaction {
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit _ConstructTransaction(vector &__v, size_type __n)
: __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
#ifndef _LIBCPP_HAS_NO_ASAN
__v_.__annotate_increase(__n);
#endif
}
- ~_ConstructTransaction() {
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
__v_.__end_ = __pos_;
#ifndef _LIBCPP_HAS_NO_ASAN
if (__pos_ != __new_end_) {
@@ -772,7 +802,7 @@ private:
};
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __construct_one_at_end(_Args&& ...__args) {
_ConstructTransaction __tx(*this, 1);
__alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
@@ -780,23 +810,23 @@ private:
++__tx.__pos_;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
allocator_type& __alloc() _NOEXCEPT
{return this->__end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const allocator_type& __alloc() const _NOEXCEPT
{return this->__end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
pointer& __end_cap() _NOEXCEPT
{return this->__end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const pointer& __end_cap() const _NOEXCEPT
{return this->__end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
pointer __soon_to_be_end = this->__end_;
while (__new_last != __soon_to_be_end)
@@ -804,12 +834,12 @@ private:
this->__end_ = __new_last;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector& __c)
{__copy_assign_alloc(__c, integral_constant<bool,
__alloc_traits::propagate_on_container_copy_assignment::value>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector& __c)
_NOEXCEPT_(
!__alloc_traits::propagate_on_container_move_assignment::value ||
@@ -827,7 +857,7 @@ private:
_VSTD::__throw_out_of_range("vector");
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector& __c, true_type)
{
if (__alloc() != __c.__alloc())
@@ -839,18 +869,18 @@ private:
__alloc() = __c.__alloc();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector&, false_type)
{}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector&, false_type)
_NOEXCEPT
{}
@@ -875,56 +905,46 @@ vector(_InputIterator, _InputIterator, _Alloc)
#endif
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
{
-
__annotate_delete();
- _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
+ using _RevIter = std::reverse_iterator<pointer>;
+ __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
+ __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_))
+ .base();
_VSTD::swap(this->__begin_, __v.__begin_);
_VSTD::swap(this->__end_, __v.__end_);
_VSTD::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::pointer
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
{
__annotate_delete();
pointer __r = __v.__begin_;
- _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_);
- _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_);
+ using _RevIter = std::reverse_iterator<pointer>;
+ __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
+ __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_))
+ .base();
+ __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_);
_VSTD::swap(this->__begin_, __v.__begin_);
_VSTD::swap(this->__end_, __v.__end_);
_VSTD::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
return __r;
}
-// Allocate space for __n objects
-// throws length_error if __n > max_size()
-// throws (probably bad_alloc) if memory run out
-// Precondition: __begin_ == __end_ == __end_cap() == 0
-// Precondition: __n > 0
-// Postcondition: capacity() == __n
-// Postcondition: size() == 0
-template <class _Tp, class _Allocator>
-void
-vector<_Tp, _Allocator>::__vallocate(size_type __n)
-{
- if (__n > max_size())
- this->__throw_length_error();
- this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n);
- this->__end_cap() = this->__begin_ + __n;
- __annotate_new(0);
-}
-
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
{
@@ -937,6 +957,7 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
{
@@ -946,6 +967,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
// Precondition: __new_size > capacity()
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
@@ -965,6 +987,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
@@ -982,6 +1005,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
@@ -995,6 +1019,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -1002,8 +1027,8 @@ typename enable_if
>::type
vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
{
- _ConstructTransaction __tx(*this, __n);
- _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);
+ _ConstructTransaction __tx(*this, __n);
+ __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_);
}
// Default constructs __n objects starting at __end_
@@ -1011,6 +1036,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
// Postcondition: size() == size() + __n
// Exception safety: strong.
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__append(size_type __n)
{
@@ -1030,6 +1056,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)
// Postcondition: size() == size() + __n
// Exception safety: strong.
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
{
@@ -1045,6 +1072,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(size_type __n)
{
_VSTD::__debug_db_insert_c(this);
@@ -1057,6 +1085,7 @@ vector<_Tp, _Allocator>::vector(size_type __n)
#if _LIBCPP_STD_VER > 11
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
@@ -1070,6 +1099,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
#endif
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
{
_VSTD::__debug_db_insert_c(this);
@@ -1082,9 +1112,9 @@ vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
template <class _Tp, class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(_InputIterator __first,
- typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -1092,14 +1122,14 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
{
_VSTD::__debug_db_insert_c(this);
for (; __first != __last; ++__first)
- __emplace_back(*__first);
+ emplace_back(*__first);
}
template <class _Tp, class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value &&
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value>::type*)
@@ -1107,11 +1137,12 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
{
_VSTD::__debug_db_insert_c(this);
for (; __first != __last; ++__first)
- __emplace_back(*__first);
+ emplace_back(*__first);
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
@@ -1130,6 +1161,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
@@ -1147,6 +1179,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(const vector& __x)
: __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
{
@@ -1160,7 +1193,8 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
}
template <class _Tp, class _Allocator>
-vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_type>& __a)
+_LIBCPP_CONSTEXPR_AFTER_CXX17
+vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
: __end_cap_(nullptr, __a)
{
_VSTD::__debug_db_insert_c(this);
@@ -1172,22 +1206,19 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_
}
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
- _NOEXCEPT
+ noexcept
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
#endif
: __end_cap_(nullptr, _VSTD::move(__x.__alloc()))
{
_VSTD::__debug_db_insert_c(this);
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__x));
-#endif
+ std::__debug_db_swap(this, std::addressof(__x));
this->__begin_ = __x.__begin_;
this->__end_ = __x.__end_;
this->__end_cap() = __x.__end_cap();
@@ -1195,8 +1226,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
-vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>& __a)
+vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
: __end_cap_(nullptr, __a)
{
_VSTD::__debug_db_insert_c(this);
@@ -1206,9 +1238,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>
this->__end_ = __x.__end_;
this->__end_cap() = __x.__end_cap();
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__x));
-#endif
+ std::__debug_db_swap(this, std::addressof(__x));
}
else
{
@@ -1217,7 +1247,10 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>
}
}
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
{
@@ -1230,6 +1263,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __end_cap_(nullptr, __a)
@@ -1242,7 +1276,10 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
}
}
+#endif // _LIBCPP_CXX03_LANG
+
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
vector<_Tp, _Allocator>::operator=(vector&& __x)
@@ -1254,6 +1291,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value)
@@ -1268,6 +1306,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
@@ -1278,14 +1317,11 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
this->__end_ = __c.__end_;
this->__end_cap() = __c.__end_cap();
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__c));
-#endif
+ std::__debug_db_swap(this, std::addressof(__c));
}
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
vector<_Tp, _Allocator>::operator=(const vector& __x)
@@ -1300,10 +1336,7 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)
template <class _Tp, class _Allocator>
template <class _InputIterator>
-typename enable_if
-<
- __is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value &&
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -1313,11 +1346,12 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
{
clear();
for (; __first != __last; ++__first)
- __emplace_back(*__first);
+ emplace_back(*__first);
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -1351,10 +1385,11 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
__vallocate(__recommend(__new_size));
__construct_at_end(__first, __last, __new_size);
}
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
{
@@ -1373,66 +1408,47 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
__vallocate(__recommend(static_cast<size_type>(__n)));
__construct_at_end(__n, __u);
}
- __invalidate_all_iterators();
-}
-
-template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-typename vector<_Tp, _Allocator>::iterator
-vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT
-{
-#if _LIBCPP_DEBUG_LEVEL == 2
- return iterator(this, __p);
-#else
- return iterator(__p);
-#endif
-}
-
-template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-typename vector<_Tp, _Allocator>::const_iterator
-vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT
-{
-#if _LIBCPP_DEBUG_LEVEL == 2
- return const_iterator(this, __p);
-#else
- return const_iterator(__p);
-#endif
+ std::__debug_db_invalidate_all(this);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::begin() _NOEXCEPT
{
- return __make_iter(this->__begin_);
+ return iterator(this, this->__begin_);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::begin() const _NOEXCEPT
{
- return __make_iter(this->__begin_);
+ return const_iterator(this, this->__begin_);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::end() _NOEXCEPT
{
- return __make_iter(this->__end_);
+ return iterator(this, this->__end_);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::end() const _NOEXCEPT
{
- return __make_iter(this->__end_);
+ return const_iterator(this, this->__end_);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
@@ -1442,6 +1458,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_reference
vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
@@ -1451,6 +1468,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::at(size_type __n)
{
@@ -1460,6 +1478,7 @@ vector<_Tp, _Allocator>::at(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::const_reference
vector<_Tp, _Allocator>::at(size_type __n) const
{
@@ -1469,6 +1488,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::reserve(size_type __n)
{
@@ -1483,6 +1503,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@@ -1506,12 +1527,9 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
template <class _Tp, class _Allocator>
template <class _Up>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
-#ifndef _LIBCPP_CXX03_LANG
vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
-#else
-vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
-#endif
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
@@ -1522,6 +1540,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::push_back(const_reference __x)
@@ -1534,9 +1553,8 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
__push_back_slow_path(__x);
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::push_back(value_type&& __x)
@@ -1551,6 +1569,7 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
{
@@ -1564,6 +1583,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
#if _LIBCPP_STD_VER > 14
typename vector<_Tp, _Allocator>::reference
@@ -1583,9 +1603,8 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
#endif
}
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
vector<_Tp, _Allocator>::pop_back()
@@ -1595,6 +1614,7 @@ vector<_Tp, _Allocator>::pop_back()
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __position)
@@ -1606,12 +1626,14 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
difference_type __ps = __position - cbegin();
pointer __p = this->__begin_ + __ps;
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
- this->__invalidate_iterators_past(__p-1);
- iterator __r = __make_iter(__p);
+ if (!__libcpp_is_constant_evaluated())
+ this->__invalidate_iterators_past(__p - 1);
+ iterator __r = iterator(this, __p);
return __r;
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
@@ -1624,13 +1646,15 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
pointer __p = this->__begin_ + (__first - begin());
if (__first != __last) {
this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
- this->__invalidate_iterators_past(__p - 1);
+ if (!__libcpp_is_constant_evaluated())
+ this->__invalidate_iterators_past(__p - 1);
}
- iterator __r = __make_iter(__p);
+ iterator __r = iterator(this, __p);
return __r;
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
{
@@ -1650,13 +1674,15 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::insert(iterator, x) called with an iterator not referring to this vector");
pointer __p = this->__begin_ + (__position - begin());
- if (this->__end_ < this->__end_cap())
+ // We can't compare unrelated pointers inside constant expressions
+ if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap())
{
if (__p == this->__end_)
{
@@ -1678,12 +1704,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
__v.push_back(__x);
__p = __swap_out_circular_buffer(__v, __p);
}
- return __make_iter(__p);
+ return iterator(this, __p);
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
{
@@ -1709,11 +1734,12 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
__v.push_back(_VSTD::move(__x));
__p = __swap_out_circular_buffer(__v, __p);
}
- return __make_iter(__p);
+ return iterator(this, __p);
}
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
{
@@ -1740,12 +1766,11 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
__v.emplace_back(_VSTD::forward<_Args>(__args)...);
__p = __swap_out_circular_buffer(__v, __p);
}
- return __make_iter(__p);
+ return iterator(this, __p);
}
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
{
@@ -1754,7 +1779,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
pointer __p = this->__begin_ + (__position - begin());
if (__n > 0)
{
- if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_))
+ // We can't compare unrelated pointers inside constant expressions
+ if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_))
{
size_type __old_n = __n;
pointer __old_last = this->__end_;
@@ -1781,15 +1807,12 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
__p = __swap_out_circular_buffer(__v, __p);
}
}
- return __make_iter(__p);
+ return iterator(this, __p);
}
template <class _Tp, class _Allocator>
template <class _InputIterator>
-typename enable_if
-<
- __is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value &&
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -1824,19 +1847,20 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
}
catch (...)
{
- erase(__make_iter(__old_last), end());
+ erase(iterator(this, __old_last), end());
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
__p = _VSTD::rotate(__p, __old_last, this->__end_);
- insert(__make_iter(__p), _VSTD::make_move_iterator(__v.begin()),
- _VSTD::make_move_iterator(__v.end()));
+ insert(iterator(this, __p), _VSTD::make_move_iterator(__v.begin()),
+ _VSTD::make_move_iterator(__v.end()));
return begin() + __off;
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -1881,10 +1905,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
__p = __swap_out_circular_buffer(__v, __p);
}
}
- return __make_iter(__p);
+ return iterator(this, __p);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::resize(size_type __sz)
{
@@ -1896,6 +1921,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
{
@@ -1907,6 +1933,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
@@ -1925,12 +1952,11 @@ vector<_Tp, _Allocator>::swap(vector& __x)
_VSTD::swap(this->__end_cap(), __x.__end_cap());
_VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, _VSTD::addressof(__x));
-#endif
+ std::__debug_db_swap(this, std::addressof(__x));
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
bool
vector<_Tp, _Allocator>::__invariants() const
{
@@ -1951,7 +1977,7 @@ vector<_Tp, _Allocator>::__invariants() const
return true;
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Allocator>
bool
@@ -1983,24 +2009,13 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __
return this->__begin_ <= __p && __p < this->__end_;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
-
-template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-vector<_Tp, _Allocator>::__invalidate_all_iterators()
-{
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__invalidate_all(this);
-#endif
-}
-
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
--__p;
@@ -2058,182 +2073,181 @@ private:
__compressed_pair<size_type, __storage_allocator> __cap_alloc_;
public:
typedef __bit_reference<vector> reference;
+#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
+ using const_reference = bool;
+#else
typedef __bit_const_reference<vector> const_reference;
+#endif
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type& __cap() _NOEXCEPT
{return __cap_alloc_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const size_type& __cap() const _NOEXCEPT
{return __cap_alloc_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__storage_allocator& __alloc() _NOEXCEPT
{return __cap_alloc_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const __storage_allocator& __alloc() const _NOEXCEPT
{return __cap_alloc_.second();}
static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
{return __n * __bits_per_word;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
{return (__n - 1) / __bits_per_word + 1;}
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
#else
_NOEXCEPT;
#endif
- ~vector();
- explicit vector(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~vector();
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
- explicit vector(size_type __n, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
#endif
- vector(size_type __n, const value_type& __v);
- vector(size_type __n, const value_type& __v, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIterator>
- vector(_InputIterator __first, _InputIterator __last,
- typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last,
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
template <class _InputIterator>
- vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
template <class _ForwardIterator>
- vector(_ForwardIterator __first, _ForwardIterator __last,
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
template <class _ForwardIterator>
- vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
- vector(const vector& __v);
- vector(const vector& __v, const allocator_type& __a);
- vector& operator=(const vector& __v);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(const vector& __v);
#ifndef _LIBCPP_CXX03_LANG
- vector(initializer_list<value_type> __il);
- vector(initializer_list<value_type> __il, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il, const allocator_type& __a);
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ vector& operator=(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end()); return *this;}
+
+#endif // !_LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
- _NOEXCEPT;
+ noexcept;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
- vector(vector&& __v, const __identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector& operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
- _LIBCPP_INLINE_VISIBILITY
- vector& operator=(initializer_list<value_type> __il)
- {assign(__il.begin(), __il.end()); return *this;}
-
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _InputIterator>
- typename enable_if
- <
- __is_cpp17_input_iterator<_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value,
+ typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
void
>::type
- assign(_InputIterator __first, _InputIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
- assign(_ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_ForwardIterator __first, _ForwardIterator __last);
- void assign(size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const value_type& __x);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(this->__alloc());}
- size_type max_size() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type capacity() const _NOEXCEPT
{return __internal_cap_to_external(__cap());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type size() const _NOEXCEPT
{return __size_;}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool empty() const _NOEXCEPT
{return __size_ == 0;}
- void reserve(size_type __n);
- void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator begin() _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator begin() const _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator end() _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator end() const _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator cbegin() const _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator cend() const _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
- _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);}
- _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __n) {return __make_ref(__n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference operator[](size_type __n) const {return __make_ref(__n);}
reference at(size_type __n);
const_reference at(size_type __n) const;
- _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);}
- _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);}
- _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);}
- _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() {return __make_ref(0);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const {return __make_ref(0);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() {return __make_ref(__size_ - 1);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const {return __make_ref(__size_ - 1);}
- void push_back(const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(const value_type& __x);
#if _LIBCPP_STD_VER > 11
template <class... _Args>
#if _LIBCPP_STD_VER > 14
- _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference emplace_back(_Args&&... __args)
#else
_LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
#endif
@@ -2245,58 +2259,54 @@ public:
}
#endif
- _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back() {--__size_;}
#if _LIBCPP_STD_VER > 11
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args)
- { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args)
+ { return insert ( __position, value_type ( _VSTD::forward<_Args>(__args)... )); }
#endif
- iterator insert(const_iterator __position, const value_type& __x);
- iterator insert(const_iterator __position, size_type __n, const value_type& __x);
- iterator insert(const_iterator __position, size_type __n, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const value_type& __x);
template <class _InputIterator>
- typename enable_if
- <
- __is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value,
+ typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
iterator
>::type
- insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
iterator
>::type
- insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
- iterator erase(const_iterator __first, const_iterator __last);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __position);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void clear() _NOEXCEPT {__size_ = 0;}
- void swap(vector&)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
- static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
- void resize(size_type __sz, value_type __x = false);
- void flip() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, value_type __x = false);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT;
- bool __invariants() const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
private:
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
@@ -2309,43 +2319,63 @@ private:
_VSTD::__throw_out_of_range("vector");
}
- _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
- void __vallocate(size_type __n);
- void __vdeallocate() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ // Allocate space for __n objects
+ // throws length_error if __n > max_size()
+ // throws (probably bad_alloc) if memory run out
+ // Precondition: __begin_ == __end_ == __cap() == 0
+ // Precondition: __n > 0
+ // Postcondition: capacity() >= __n
+ // Postcondition: size() == 0
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vallocate(size_type __n) {
+ if (__n > max_size())
+ __throw_length_error();
+ auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));
+ __begin_ = __allocation.ptr;
+ __size_ = 0;
+ __cap() = __allocation.count;
+ if (__libcpp_is_constant_evaluated()) {
+ for (size_type __i = 0; __i != __cap(); ++__i)
+ std::__construct_at(std::__to_address(__begin_) + __i);
+ }
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static size_type __align_it(size_type __new_size) _NOEXCEPT
- {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);}
- _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
- _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
+ {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __recommend(size_type __new_size) const;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, bool __x);
template <class _ForwardIterator>
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
- __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
- void __append(size_type __n, const_reference __x);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reference __make_ref(size_type __pos) _NOEXCEPT
{return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
- _LIBCPP_INLINE_VISIBILITY
- const_reference __make_ref(size_type __pos) const _NOEXCEPT
- {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ const_reference __make_ref(size_type __pos) const _NOEXCEPT {
+ return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word,
+ __storage_type(1) << __pos % __bits_per_word);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator __make_iter(size_type __pos) _NOEXCEPT
{return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator __make_iter(size_type __pos) const _NOEXCEPT
{return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
{return begin() + (__p - cbegin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const vector& __v)
{__copy_assign_alloc(__v, integral_constant<bool,
__storage_traits::propagate_on_container_copy_assignment::value>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const vector& __c, true_type)
{
if (__alloc() != __c.__alloc())
@@ -2353,33 +2383,33 @@ private:
__alloc() = __c.__alloc();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const vector&, false_type)
{}
- void __move_assign(vector& __c, false_type);
- void __move_assign(vector& __c, true_type)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign_alloc(vector& __c)
_NOEXCEPT_(
!__storage_traits::propagate_on_container_move_assignment::value ||
is_nothrow_move_assignable<allocator_type>::value)
{__move_assign_alloc(__c, integral_constant<bool,
__storage_traits::propagate_on_container_move_assignment::value>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign_alloc(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign_alloc(vector&, false_type)
_NOEXCEPT
{}
- size_t __hash_code() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t __hash_code() const _NOEXCEPT;
friend class __bit_reference<vector>;
friend class __bit_const_reference<vector>;
@@ -2390,45 +2420,20 @@ private:
};
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-vector<bool, _Allocator>::__invalidate_all_iterators()
-{
-}
-
-// Allocate space for __n objects
-// throws length_error if __n > max_size()
-// throws (probably bad_alloc) if memory run out
-// Precondition: __begin_ == __end_ == __cap() == 0
-// Precondition: __n > 0
-// Postcondition: capacity() == __n
-// Postcondition: size() == 0
-template <class _Allocator>
-void
-vector<bool, _Allocator>::__vallocate(size_type __n)
-{
- if (__n > max_size())
- this->__throw_length_error();
- __n = __external_cap_to_internal(__n);
- this->__begin_ = __storage_traits::allocate(this->__alloc(), __n);
- this->__size_ = 0;
- this->__cap() = __n;
-}
-
-template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
{
if (this->__begin_ != nullptr)
{
__storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
this->__begin_ = nullptr;
this->__size_ = this->__cap() = 0;
}
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<bool, _Allocator>::size_type
vector<bool, _Allocator>::max_size() const _NOEXCEPT
{
@@ -2441,7 +2446,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT
// Precondition: __new_size > capacity()
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<bool, _Allocator>::size_type
vector<bool, _Allocator>::__recommend(size_type __new_size) const
{
@@ -2459,7 +2464,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
{
@@ -2477,6 +2482,7 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2497,7 +2503,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
@@ -2507,7 +2513,7 @@ vector<bool, _Allocator>::vector()
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
@@ -2521,6 +2527,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(size_type __n)
: __begin_(nullptr),
__size_(0),
@@ -2535,6 +2542,7 @@ vector<bool, _Allocator>::vector(size_type __n)
#if _LIBCPP_STD_VER > 11
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2549,6 +2557,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
#endif
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
: __begin_(nullptr),
__size_(0),
@@ -2562,6 +2571,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2576,9 +2586,9 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
template <class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
- typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value>::type*)
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, __default_init_tag())
@@ -2595,7 +2605,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
@@ -2603,9 +2613,9 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
template <class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value>::type*)
+ typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
@@ -2622,7 +2632,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
@@ -2630,6 +2640,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
: __begin_(nullptr),
@@ -2646,6 +2657,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
: __begin_(nullptr),
@@ -2663,6 +2675,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
#ifndef _LIBCPP_CXX03_LANG
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
: __begin_(nullptr),
__size_(0),
@@ -2677,6 +2690,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2693,14 +2707,16 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
#endif // _LIBCPP_CXX03_LANG
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::~vector()
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(const vector& __v)
: __begin_(nullptr),
__size_(0),
@@ -2714,6 +2730,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2727,6 +2744,7 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>&
vector<bool, _Allocator>::operator=(const vector& __v)
{
@@ -2747,10 +2765,8 @@ vector<bool, _Allocator>::operator=(const vector& __v)
return *this;
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _Allocator>::vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT
#else
@@ -2765,7 +2781,8 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
}
template <class _Allocator>
-vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type>& __a)
+_LIBCPP_CONSTEXPR_AFTER_CXX17
+vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, __a)
@@ -2786,7 +2803,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>&
vector<bool, _Allocator>::operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
@@ -2797,7 +2814,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
{
if (__alloc() != __c.__alloc())
@@ -2807,7 +2824,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
@@ -2820,10 +2837,8 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
__c.__cap() = __c.__size_ = 0;
}
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
{
__size_ = 0;
@@ -2841,15 +2856,12 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
}
_VSTD::fill_n(begin(), __n, __x);
}
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
}
template <class _Allocator>
template <class _InputIterator>
-typename enable_if
-<
- __is_cpp17_input_iterator<_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value,
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
void
>::type
vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
@@ -2861,6 +2873,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2884,7 +2897,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::reserve(size_type __n)
{
if (__n > capacity())
@@ -2895,12 +2908,12 @@ vector<bool, _Allocator>::reserve(size_type __n)
__v.__vallocate(__n);
__v.__construct_at_end(this->begin(), this->end());
swap(__v);
- __invalidate_all_iterators();
+ std::__debug_db_invalidate_all(this);
}
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
{
if (__external_cap_to_internal(size()) > __cap())
@@ -2938,7 +2951,7 @@ vector<bool, _Allocator>::at(size_type __n) const
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::push_back(const value_type& __x)
{
if (this->__size_ == this->capacity())
@@ -2948,7 +2961,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)
}
template <class _Allocator>
-typename vector<bool, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
{
iterator __r;
@@ -2973,7 +2986,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
}
template <class _Allocator>
-typename vector<bool, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
{
iterator __r;
@@ -3000,10 +3013,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
template <class _Allocator>
template <class _InputIterator>
-typename enable_if
-<
- __is_cpp17_input_iterator <_InputIterator>::value &&
- !__is_cpp17_forward_iterator<_InputIterator>::value,
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
typename vector<bool, _Allocator>::iterator
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
@@ -3045,6 +3055,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -3078,7 +3089,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::erase(const_iterator __position)
{
@@ -3089,6 +3100,7 @@ vector<bool, _Allocator>::erase(const_iterator __position)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
@@ -3100,7 +3112,7 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
@@ -3117,7 +3129,7 @@ vector<bool, _Allocator>::swap(vector& __x)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
{
size_type __cs = size();
@@ -3146,7 +3158,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::flip() _NOEXCEPT
{
// do middle whole words
@@ -3165,7 +3177,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT
}
template <class _Allocator>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
vector<bool, _Allocator>::__invariants() const
{
if (this->__begin_ == nullptr)
@@ -3184,7 +3196,7 @@ vector<bool, _Allocator>::__invariants() const
}
template <class _Allocator>
-size_t
+_LIBCPP_CONSTEXPR_AFTER_CXX17 size_t
vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
{
size_t __h = 0;
@@ -3204,14 +3216,15 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
template <class _Allocator>
struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
- : public unary_function<vector<bool, _Allocator>, size_t>
+ : public __unary_function<vector<bool, _Allocator>, size_t>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
{return __vec.__hash_code();}
};
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3221,6 +3234,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3229,6 +3243,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3237,6 +3252,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3245,6 +3261,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3253,6 +3270,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3261,6 +3279,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
@@ -3271,6 +3290,7 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
#if _LIBCPP_STD_VER > 17
template <class _Tp, class _Allocator, class _Up>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
auto __old_size = __c.size();
@@ -3279,14 +3299,23 @@ erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
}
template <class _Tp, class _Allocator, class _Predicate>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
auto __old_size = __c.size();
__c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());
return __old_size - __c.size();
}
+
+template <>
+inline constexpr bool __format::__enable_insertable<std::vector<char>> = true;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true;
#endif
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
lib/libcxx/include/version
@@ -38,6 +38,7 @@ __cpp_lib_atomic_shared_ptr 201711L <atomic>
__cpp_lib_atomic_value_initialization 201911L <atomic> <memory>
__cpp_lib_atomic_wait 201907L <atomic>
__cpp_lib_barrier 201907L <barrier>
+__cpp_lib_bind_back 202202L <functional>
__cpp_lib_bind_front 201907L <functional>
__cpp_lib_bit_cast 201806L <bit>
__cpp_lib_bitops 201907L <bit>
@@ -46,7 +47,7 @@ __cpp_lib_bounded_array_traits 201902L <type_traits>
__cpp_lib_boyer_moore_searcher 201603L <functional>
__cpp_lib_byte 201603L <cstddef>
__cpp_lib_byteswap 202110L <bit>
-__cpp_lib_char8_t 201811L <atomic> <filesystem> <istream>
+__cpp_lib_char8_t 201907L <atomic> <filesystem> <istream>
<limits> <locale> <ostream>
<string> <string_view>
__cpp_lib_chrono 201611L <chrono>
@@ -55,13 +56,14 @@ __cpp_lib_clamp 201603L <algorithm>
__cpp_lib_complex_udls 201309L <complex>
__cpp_lib_concepts 202002L <concepts>
__cpp_lib_constexpr_algorithms 201806L <algorithm>
+__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
__cpp_lib_constexpr_complex 201711L <complex>
__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
__cpp_lib_constexpr_functional 201907L <functional>
__cpp_lib_constexpr_iterator 201811L <iterator>
__cpp_lib_constexpr_memory 201811L <memory>
__cpp_lib_constexpr_numeric 201911L <numeric>
-__cpp_lib_constexpr_string 201811L <string>
+__cpp_lib_constexpr_string 201907L <string>
__cpp_lib_constexpr_string_view 201811L <string_view>
__cpp_lib_constexpr_tuple 201811L <tuple>
__cpp_lib_constexpr_typeinfo 202106L <typeinfo>
@@ -115,7 +117,6 @@ __cpp_lib_map_try_emplace 201411L <map>
__cpp_lib_math_constants 201907L <numbers>
__cpp_lib_math_special_functions 201603L <cmath>
__cpp_lib_memory_resource 201603L <memory_resource>
-__cpp_lib_monadic_optional 202110L <optional>
__cpp_lib_move_only_function 202110L <functional>
__cpp_lib_node_extract 201606L <map> <set> <unordered_map>
<unordered_set>
@@ -125,16 +126,27 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque>
<unordered_map> <unordered_set> <vector>
__cpp_lib_not_fn 201603L <functional>
__cpp_lib_null_iterators 201304L <iterator>
-__cpp_lib_optional 201606L <optional>
+__cpp_lib_optional 202110L <optional>
+ 201606L // C++17
__cpp_lib_out_ptr 202106L <memory>
__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>
__cpp_lib_polymorphic_allocator 201902L <memory_resource>
__cpp_lib_quoted_string_io 201304L <iomanip>
__cpp_lib_ranges 201811L <algorithm> <functional> <iterator>
<memory> <ranges>
+__cpp_lib_ranges_chunk 202202L <ranges>
+__cpp_lib_ranges_chunk_by 202202L <ranges>
+__cpp_lib_ranges_iota 202202L <numeric>
+__cpp_lib_ranges_join_with 202202L <ranges>
+__cpp_lib_ranges_slide 202202L <ranges>
__cpp_lib_ranges_starts_ends_with 202106L <algorithm>
+__cpp_lib_ranges_to_container 202202L <deque> <forward_list> <list>
+ <map> <priority_queue> <queue>
+ <set> <stack> <string>
+ <unordered_map> <unordered_set> <vector>
__cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility>
__cpp_lib_raw_memory_algorithms 201606L <memory>
+__cpp_lib_reference_from_temporary 202202L <type_traits>
__cpp_lib_remove_cvref 201711L <type_traits>
__cpp_lib_result_of_sfinae 201210L <functional> <type_traits>
__cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm>
@@ -142,7 +154,8 @@ __cpp_lib_sample 201603L <algorithm>
__cpp_lib_scoped_lock 201703L <mutex>
__cpp_lib_semaphore 201907L <semaphore>
__cpp_lib_shared_mutex 201505L <shared_mutex>
-__cpp_lib_shared_ptr_arrays 201611L <memory>
+__cpp_lib_shared_ptr_arrays 201707L <memory>
+ 201611L // C++17
__cpp_lib_shared_ptr_weak_type 201606L <memory>
__cpp_lib_shared_timed_mutex 201402L <shared_mutex>
__cpp_lib_shift 201806L <algorithm>
@@ -174,16 +187,18 @@ __cpp_lib_type_identity 201806L <type_traits>
__cpp_lib_type_trait_variable_templates 201510L <type_traits>
__cpp_lib_uncaught_exceptions 201411L <exception>
__cpp_lib_unordered_map_try_emplace 201411L <unordered_map>
+__cpp_lib_unreachable 202202L <utility>
__cpp_lib_unwrap_ref 201811L <functional>
__cpp_lib_variant 202102L <variant>
__cpp_lib_void_t 201411L <type_traits>
*/
+#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
// clang-format off
@@ -222,7 +237,7 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_as_const 201510L
# define __cpp_lib_atomic_is_always_lock_free 201603L
# define __cpp_lib_bool_constant 201505L
-// # define __cpp_lib_boyer_moore_searcher 201603L
+# define __cpp_lib_boyer_moore_searcher 201603L
# define __cpp_lib_byte 201603L
# define __cpp_lib_chrono 201611L
# define __cpp_lib_clamp 201603L
@@ -232,7 +247,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_filesystem 201703L
# endif
# define __cpp_lib_gcd_lcm 201606L
-// # define __cpp_lib_hardware_interference_size 201703L
+# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
+# define __cpp_lib_hardware_interference_size 201703L
+# endif
# define __cpp_lib_has_unique_object_representations 201606L
# define __cpp_lib_hypot 201603L
# define __cpp_lib_incomplete_container_elements 201505L
@@ -273,7 +290,7 @@ __cpp_lib_void_t 201411L <type_traits>
#if _LIBCPP_STD_VER > 17
# undef __cpp_lib_array_constexpr
# define __cpp_lib_array_constexpr 201811L
-// # define __cpp_lib_assume_aligned 201811L
+# define __cpp_lib_assume_aligned 201811L
# define __cpp_lib_atomic_flag_test 201907L
// # define __cpp_lib_atomic_float 201711L
# define __cpp_lib_atomic_lock_free_type_aliases 201907L
@@ -291,7 +308,7 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_bitops 201907L
# define __cpp_lib_bounded_array_traits 201902L
# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
-# define __cpp_lib_char8_t 201811L
+# define __cpp_lib_char8_t 201907L
# endif
# define __cpp_lib_concepts 202002L
# define __cpp_lib_constexpr_algorithms 201806L
@@ -301,7 +318,7 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_constexpr_iterator 201811L
# define __cpp_lib_constexpr_memory 201811L
# define __cpp_lib_constexpr_numeric 201911L
-# define __cpp_lib_constexpr_string 201811L
+# define __cpp_lib_constexpr_string 201907L
# define __cpp_lib_constexpr_string_view 201811L
# define __cpp_lib_constexpr_tuple 201811L
# define __cpp_lib_constexpr_utility 201811L
@@ -319,9 +336,7 @@ __cpp_lib_void_t 201411L <type_traits>
# endif
# define __cpp_lib_generic_unordered_lookup 201811L
# define __cpp_lib_int_pow2 202002L
-# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-# define __cpp_lib_integer_comparison_functions 202002L
-# endif
+# define __cpp_lib_integer_comparison_functions 202002L
# define __cpp_lib_interpolate 201902L
# define __cpp_lib_is_constant_evaluated 201811L
// # define __cpp_lib_is_layout_compatible 201907L
@@ -334,15 +349,15 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_latch 201907L
# endif
# define __cpp_lib_list_remove_return_type 201806L
-# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
-# define __cpp_lib_math_constants 201907L
-# endif
+# define __cpp_lib_math_constants 201907L
// # define __cpp_lib_polymorphic_allocator 201902L
// # define __cpp_lib_ranges 201811L
# define __cpp_lib_remove_cvref 201711L
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore)
# define __cpp_lib_semaphore 201907L
# endif
+# undef __cpp_lib_shared_ptr_arrays
+# define __cpp_lib_shared_ptr_arrays 201707L
# define __cpp_lib_shift 201806L
// # define __cpp_lib_smart_ptr_for_overwrite 202002L
// # define __cpp_lib_source_location 201907L
@@ -361,23 +376,34 @@ __cpp_lib_void_t 201411L <type_traits>
#if _LIBCPP_STD_VER > 20
# define __cpp_lib_adaptor_iterator_pair_constructor 202106L
-// # define __cpp_lib_allocate_at_least 202106L
+# define __cpp_lib_allocate_at_least 202106L
// # define __cpp_lib_associative_heterogeneous_erasure 202110L
+// # define __cpp_lib_bind_back 202202L
# define __cpp_lib_byteswap 202110L
+// # define __cpp_lib_constexpr_cmath 202202L
// # define __cpp_lib_constexpr_typeinfo 202106L
// # define __cpp_lib_invoke_r 202106L
# define __cpp_lib_is_scoped_enum 202011L
-# define __cpp_lib_monadic_optional 202110L
// # define __cpp_lib_move_only_function 202110L
+# undef __cpp_lib_optional
+# define __cpp_lib_optional 202110L
// # define __cpp_lib_out_ptr 202106L
+// # define __cpp_lib_ranges_chunk 202202L
+// # define __cpp_lib_ranges_chunk_by 202202L
+// # define __cpp_lib_ranges_iota 202202L
+// # define __cpp_lib_ranges_join_with 202202L
+// # define __cpp_lib_ranges_slide 202202L
// # define __cpp_lib_ranges_starts_ends_with 202106L
+// # define __cpp_lib_ranges_to_container 202202L
// # define __cpp_lib_ranges_zip 202110L
+// # define __cpp_lib_reference_from_temporary 202202L
// # define __cpp_lib_spanstream 202106L
// # define __cpp_lib_stacktrace 202011L
-// # define __cpp_lib_stdatomic_h 202011L
+# define __cpp_lib_stdatomic_h 202011L
# define __cpp_lib_string_contains 202011L
# define __cpp_lib_string_resize_and_overwrite 202110L
# define __cpp_lib_to_underlying 202102L
+# define __cpp_lib_unreachable 202202L
#endif
// clang-format on
lib/libcxx/include/wchar.h
@@ -10,7 +10,7 @@
#if defined(__need_wint_t) || defined(__need_mbstate_t)
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#include_next <wchar.h>
@@ -113,7 +113,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef __cplusplus
@@ -176,10 +176,10 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))
extern "C" {
-size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
- size_t nmc, size_t len, mbstate_t *__restrict ps);
-size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
- size_t nwc, size_t len, mbstate_t *__restrict ps);
+size_t mbsnrtowcs(wchar_t *__restrict __dst, const char **__restrict __src,
+ size_t __nmc, size_t __len, mbstate_t *__restrict __ps);
+size_t wcsnrtombs(char *__restrict __dst, const wchar_t **__restrict __src,
+ size_t __nwc, size_t __len, mbstate_t *__restrict __ps);
} // extern "C"
#endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)
lib/libcxx/include/wctype.h
@@ -51,7 +51,7 @@ wctrans_t wctrans(const char* property);
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
// TODO:
lib/libcxx/src/experimental/memory_resource.cpp
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#include "experimental/memory_resource"
+#include <experimental/memory_resource>
#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
-#include "atomic"
+# include <atomic>
#elif !defined(_LIBCPP_HAS_NO_THREADS)
-#include "mutex"
-#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
-#pragma comment(lib, "pthread")
-#endif
+# include <mutex>
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
@@ -97,7 +97,7 @@ static memory_resource *
__default_memory_resource(bool set = false, memory_resource * new_res = nullptr) noexcept
{
#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
- _LIBCPP_SAFE_STATIC static atomic<memory_resource*> __res{&res_init.resources.new_delete_res};
+ static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res};
if (set) {
new_res = new_res ? new_res : new_delete_resource();
// TODO: Can a weaker ordering be used?
@@ -109,7 +109,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr)
&__res, memory_order_acquire);
}
#elif !defined(_LIBCPP_HAS_NO_THREADS)
- _LIBCPP_SAFE_STATIC static memory_resource * res = &res_init.resources.new_delete_res;
+ static constinit memory_resource *res = &res_init.resources.new_delete_res;
static mutex res_lock;
if (set) {
new_res = new_res ? new_res : new_delete_resource();
@@ -122,7 +122,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr)
return res;
}
#else
- _LIBCPP_SAFE_STATIC static memory_resource* res = &res_init.resources.new_delete_res;
+ static constinit memory_resource *res = &res_init.resources.new_delete_res;
if (set) {
new_res = new_res ? new_res : new_delete_resource();
memory_resource * old_res = res;
lib/libcxx/src/experimental/memory_resource_init_helper.h
@@ -1,2 +1,2 @@
#pragma GCC system_header
-_LIBCPP_SAFE_STATIC ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
+static constinit ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
lib/libcxx/src/filesystem/directory_iterator.cpp
@@ -6,10 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
-#include "filesystem"
-#include "stack"
+#include <__assert>
+#include <__config>
#include <errno.h>
+#include <filesystem>
+#include <stack>
#include "filesystem_common.h"
@@ -24,8 +25,8 @@ public:
__dir_stream& operator=(const __dir_stream&) = delete;
__dir_stream(__dir_stream&& __ds) noexcept : __stream_(__ds.__stream_),
- __root_(move(__ds.__root_)),
- __entry_(move(__ds.__entry_)) {
+ __root_(std::move(__ds.__root_)),
+ __entry_(std::move(__ds.__entry_)) {
__ds.__stream_ = INVALID_HANDLE_VALUE;
}
@@ -103,8 +104,8 @@ public:
__dir_stream& operator=(const __dir_stream&) = delete;
__dir_stream(__dir_stream&& other) noexcept : __stream_(other.__stream_),
- __root_(move(other.__root_)),
- __entry_(move(other.__entry_)) {
+ __root_(std::move(other.__root_)),
+ __entry_(std::move(other.__entry_)) {
other.__stream_ = nullptr;
}
@@ -186,7 +187,7 @@ directory_iterator& directory_iterator::__increment(error_code* ec) {
error_code m_ec;
if (!__imp_->advance(m_ec)) {
- path root = move(__imp_->__root_);
+ path root = std::move(__imp_->__root_);
__imp_.reset();
if (m_ec)
err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str());
@@ -220,7 +221,7 @@ recursive_directory_iterator::recursive_directory_iterator(
__imp_ = make_shared<__shared_imp>();
__imp_->__options_ = opt;
- __imp_->__stack_.push(move(new_s));
+ __imp_->__stack_.push(std::move(new_s));
}
void recursive_directory_iterator::__pop(error_code* ec) {
@@ -274,7 +275,7 @@ void recursive_directory_iterator::__advance(error_code* ec) {
}
if (m_ec) {
- path root = move(stack.top().__root_);
+ path root = std::move(stack.top().__root_);
__imp_.reset();
err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str());
} else {
@@ -308,7 +309,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {
if (!skip_rec) {
__dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec);
if (new_it.good()) {
- __imp_->__stack_.push(move(new_it));
+ __imp_->__stack_.push(std::move(new_it));
return true;
}
}
@@ -319,7 +320,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {
if (ec)
ec->clear();
} else {
- path at_ent = move(curr_it.__entry_.__p_);
+ path at_ent = std::move(curr_it.__entry_.__p_);
__imp_.reset();
err.report(m_ec, "attempting recursion into " PATH_CSTR_FMT,
at_ent.c_str());
lib/libcxx/src/filesystem/filesystem_common.h
@@ -9,31 +9,30 @@
#ifndef FILESYSTEM_COMMON_H
#define FILESYSTEM_COMMON_H
-#include "__config"
-#include "array"
-#include "chrono"
-#include "climits"
-#include "cstdarg"
-#include "cstdlib"
-#include "ctime"
-#include "filesystem"
-#include "ratio"
-#include "system_error"
+#include <__assert>
+#include <__config>
+#include <array>
+#include <chrono>
+#include <climits>
+#include <cstdarg>
+#include <ctime>
+#include <filesystem>
+#include <ratio>
+#include <system_error>
+#include <utility>
#if defined(_LIBCPP_WIN32API)
# define WIN32_LEAN_AND_MEAN
# define NOMINMAX
# include <windows.h>
-#endif
-
-#if !defined(_LIBCPP_WIN32API)
+#else
# include <dirent.h> // for DIR & friends
# include <fcntl.h> /* values for fchmodat */
# include <sys/stat.h>
# include <sys/statvfs.h>
# include <sys/time.h> // for ::utimes as used in __last_write_time
# include <unistd.h>
-#endif
+#endif // defined(_LIBCPP_WIN32API)
#include "../include/apple_availability.h"
@@ -45,17 +44,16 @@
#endif
#endif
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wunused-function")
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-function")
#if defined(_LIBCPP_WIN32API)
-#define PS(x) (L##x)
-#define PATH_CSTR_FMT "\"%ls\""
+# define PATHSTR(x) (L##x)
+# define PATH_CSTR_FMT "\"%ls\""
#else
-#define PS(x) (x)
-#define PATH_CSTR_FMT "\"%s\""
+# define PATHSTR(x) (x)
+# define PATH_CSTR_FMT "\"%s\""
#endif
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -113,7 +111,7 @@ format_string(const char* msg, ...) {
}
error_code capture_errno() {
- _LIBCPP_ASSERT(errno, "Expected errno to be non-zero");
+ _LIBCPP_ASSERT(errno != 0, "Expected errno to be non-zero");
return error_code(errno, generic_category());
}
@@ -178,7 +176,7 @@ struct ErrorHandler {
case 2:
__throw_filesystem_error(what, *p1_, *p2_, ec);
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 0)
@@ -197,7 +195,7 @@ struct ErrorHandler {
case 2:
__throw_filesystem_error(what, *p1_, *p2_, ec);
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
@@ -610,4 +608,6 @@ static file_time_type get_write_time(const WIN32_FIND_DATAW& data) {
_LIBCPP_END_NAMESPACE_FILESYSTEM
+_LIBCPP_DIAGNOSTIC_POP
+
#endif // FILESYSTEM_COMMON_H
lib/libcxx/src/filesystem/int128_builtins.cpp
@@ -13,8 +13,8 @@
*
* ===----------------------------------------------------------------------===
*/
-#include "__config"
-#include "climits"
+#include <__config>
+#include <climits>
#if !defined(_LIBCPP_HAS_NO_INT128)
lib/libcxx/src/filesystem/operations.cpp
@@ -6,14 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#include "filesystem"
-#include "array"
-#include "iterator"
-#include "string_view"
-#include "type_traits"
-#include "vector"
-#include "cstdlib"
-#include "climits"
+#include <__assert>
+#include <__utility/unreachable.h>
+#include <array>
+#include <climits>
+#include <cstdlib>
+#include <filesystem>
+#include <iterator>
+#include <string_view>
+#include <type_traits>
+#include <vector>
#include "filesystem_common.h"
@@ -39,7 +41,7 @@
# include <copyfile.h>
# define _LIBCPP_FILESYSTEM_USE_COPYFILE
#else
-# include "fstream"
+# include <fstream>
# define _LIBCPP_FILESYSTEM_USE_FSTREAM
#endif
@@ -154,7 +156,7 @@ public:
return makeState(PS_AtEnd);
case PS_AtEnd:
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
}
@@ -202,7 +204,7 @@ public:
return makeState(PS_InRootName, Path.data(), RStart + 1);
case PS_InRootName:
case PS_BeforeBegin:
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
}
@@ -212,19 +214,19 @@ public:
switch (State) {
case PS_BeforeBegin:
case PS_AtEnd:
- return PS("");
+ return PATHSTR("");
case PS_InRootDir:
if (RawEntry[0] == '\\')
- return PS("\\");
+ return PATHSTR("\\");
else
- return PS("/");
+ return PATHSTR("/");
case PS_InTrailingSep:
- return PS("");
+ return PATHSTR("");
case PS_InRootName:
case PS_InFilenames:
return RawEntry;
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
explicit operator bool() const noexcept {
@@ -285,7 +287,7 @@ private:
case PS_AtEnd:
return getAfterBack();
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
/// \brief Return a pointer to the first character in the currently lexed
@@ -302,7 +304,7 @@ private:
case PS_AtEnd:
return &Path.back() + 1;
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
// Consume all consecutive separators.
@@ -385,8 +387,8 @@ private:
};
string_view_pair separate_filename(string_view_t const& s) {
- if (s == PS(".") || s == PS("..") || s.empty())
- return string_view_pair{s, PS("")};
+ if (s == PATHSTR(".") || s == PATHSTR("..") || s.empty())
+ return string_view_pair{s, PATHSTR("")};
auto pos = s.find_last_of('.');
if (pos == string_view_t::npos || pos == 0)
return string_view_pair{s, string_view_t{}};
@@ -681,7 +683,7 @@ void filesystem_error::__create_what(int __num_paths) {
return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "] [" PATH_CSTR_FMT "]",
derived_what, path1().c_str(), path2().c_str());
}
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}();
}
@@ -1188,7 +1190,7 @@ bool __fs_is_empty(const path& p, error_code* ec) {
} else if (is_regular_file(st))
return static_cast<uintmax_t>(pst.st_size) == 0;
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
static file_time_type __extract_last_write_time(const path& p, const StatT& st,
@@ -1614,7 +1616,7 @@ path& path::replace_extension(path const& replacement) {
}
if (!replacement.empty()) {
if (replacement.native()[0] != '.') {
- __pn_ += PS(".");
+ __pn_ += PATHSTR(".");
}
__pn_.append(replacement.__pn_);
}
@@ -1736,14 +1738,14 @@ enum PathPartKind : unsigned char {
static PathPartKind ClassifyPathPart(string_view_t Part) {
if (Part.empty())
return PK_TrailingSep;
- if (Part == PS("."))
+ if (Part == PATHSTR("."))
return PK_Dot;
- if (Part == PS(".."))
+ if (Part == PATHSTR(".."))
return PK_DotDot;
- if (Part == PS("/"))
+ if (Part == PATHSTR("/"))
return PK_RootSep;
#if defined(_LIBCPP_WIN32API)
- if (Part == PS("\\"))
+ if (Part == PATHSTR("\\"))
return PK_RootSep;
#endif
return PK_Filename;
@@ -1793,7 +1795,7 @@ path path::lexically_normal() const {
NewPathSize -= Parts.back().first.size();
Parts.pop_back();
} else if (LastKind != PK_RootSep)
- AddPart(PK_DotDot, PS(".."));
+ AddPart(PK_DotDot, PATHSTR(".."));
MaybeNeedTrailingSep = LastKind == PK_Filename;
break;
}
@@ -1803,12 +1805,12 @@ path path::lexically_normal() const {
break;
}
case PK_None:
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
}
// [fs.path.generic]p6.8: If the path is empty, add a dot.
if (Parts.empty())
- return PS(".");
+ return PATHSTR(".");
// [fs.path.generic]p6.7: If the last filename is dot-dot, remove any
// trailing directory-separator.
@@ -1820,7 +1822,7 @@ path path::lexically_normal() const {
Result /= PK.first;
if (NeedTrailingSep)
- Result /= PS("");
+ Result /= PATHSTR("");
Result.make_preferred();
return Result;
@@ -1830,9 +1832,9 @@ static int DetermineLexicalElementCount(PathParser PP) {
int Count = 0;
for (; PP; ++PP) {
auto Elem = *PP;
- if (Elem == PS(".."))
+ if (Elem == PATHSTR(".."))
--Count;
- else if (Elem != PS(".") && Elem != PS(""))
+ else if (Elem != PATHSTR(".") && Elem != PATHSTR(""))
++Count;
}
return Count;
@@ -1879,15 +1881,15 @@ path path::lexically_relative(const path& base) const {
return {};
// if n == 0 and (a == end() || a->empty()), returns path("."); otherwise
- if (ElemCount == 0 && (PP.atEnd() || *PP == PS("")))
- return PS(".");
+ if (ElemCount == 0 && (PP.atEnd() || *PP == PATHSTR("")))
+ return PATHSTR(".");
- // return a path constructed with 'n' dot-dot elements, followed by the the
+ // return a path constructed with 'n' dot-dot elements, followed by the
// elements of '*this' after the mismatch.
path Result;
// FIXME: Reserve enough room in Result that it won't have to re-allocate.
while (ElemCount--)
- Result /= PS("..");
+ Result /= PATHSTR("..");
for (; PP; ++PP)
Result /= *PP;
return Result;
@@ -1900,7 +1902,7 @@ static int CompareRootName(PathParser *LHS, PathParser *RHS) {
return 0;
auto GetRootName = [](PathParser *Parser) -> string_view_t {
- return Parser->inRootName() ? **Parser : PS("");
+ return Parser->inRootName() ? **Parser : PATHSTR("");
};
int res = GetRootName(LHS).compare(GetRootName(RHS));
ConsumeRootName(LHS);
lib/libcxx/src/filesystem/posix_compat.h
@@ -23,7 +23,8 @@
#ifndef POSIX_COMPAT_H
#define POSIX_COMPAT_H
-#include "filesystem"
+#include <__assert>
+#include <filesystem>
#include "filesystem_common.h"
lib/libcxx/src/include/ryu/common.h
@@ -42,6 +42,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
+#include <__assert>
#include "__config"
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/include/ryu/d2fixed.h
@@ -42,8 +42,8 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
-#include "cstdint"
+#include <__config>
+#include <cstdint>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/include/ryu/d2fixed_full_table.h
@@ -42,7 +42,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
+#include <__config>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/include/ryu/d2s.h
@@ -42,7 +42,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
+#include <__config>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/include/ryu/d2s_full_table.h
@@ -42,7 +42,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
+#include <__config>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/include/ryu/d2s_intrinsics.h
@@ -42,7 +42,10 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
+#include <__assert>
+#include <__config>
+
+#include "include/ryu/ryu.h"
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/include/ryu/digit_table.h
@@ -39,30 +39,19 @@
#ifndef _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
#define _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
-// Avoid formatting to keep the changes with the original code minimal.
-// clang-format off
-
-#include "__config"
+#include <__charconv/tables.h>
+#include <__config>
_LIBCPP_BEGIN_NAMESPACE_STD
// A table of all two-digit numbers. This is used to speed up decimal digit
// generation by copying pairs of digits into the final output.
-inline constexpr char __DIGIT_TABLE[200] = {
- '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9',
- '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9',
- '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9',
- '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9',
- '4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9',
- '5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9',
- '6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9',
- '7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9',
- '8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9',
- '9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9'
-};
+//
+// In order to minimize the diff in the Ryu code between MSVC STL and libc++
+// the code uses the name __DIGIT_TABLE. In order to avoid code duplication it
+// reuses the table already available in libc++.
+inline constexpr auto& __DIGIT_TABLE = __itoa::__table<>::__digits_base_10;
_LIBCPP_END_NAMESPACE_STD
-// clang-format on
-
#endif // _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
lib/libcxx/src/include/ryu/f2s.h
@@ -42,7 +42,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
+#include <__config>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/include/ryu/ryu.h
@@ -44,21 +44,22 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__charconv/chars_format.h"
-#include "__charconv/to_chars_result.h"
-#include "__config"
-#include "__debug"
-#include "__errc"
-#include "cstdint"
-#include "cstring"
-#include "type_traits"
+#include <__charconv/chars_format.h>
+#include <__charconv/to_chars_result.h>
+#include <__config>
+#include <__debug>
+#include <__errc>
+#include <cstdint>
+#include <cstring>
+#include <type_traits>
+
#include "include/ryu/f2s.h"
#include "include/ryu/d2s.h"
#include "include/ryu/d2fixed.h"
-#if defined(_M_X64) && defined(_LIBCPP_COMPILER_MSVC)
-#include <intrin0.h> // for _umul128() and __shiftright128()
-#endif // defined(_M_X64) && defined(_LIBCPP_COMPILER_MSVC)
+#if defined(_MSC_VER)
+#include <intrin.h> // for _umul128(), __shiftright128(), _BitScanForward{,64}
+#endif // defined(_MSC_VER)
#if defined(_WIN64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__aarch64__)
#define _LIBCPP_64_BIT
@@ -68,7 +69,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// https://github.com/ulfjack/ryu/tree/59661c3/ryu
-#if !defined(_LIBCPP_COMPILER_MSVC)
+#if !defined(_MSC_VER)
_LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward64(unsigned long* __index, unsigned long long __mask) {
if (__mask == 0) {
return false;
@@ -84,7 +85,7 @@ _LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward(unsigned long* __inde
*__index = __builtin_ctz(__mask);
return true;
}
-#endif // _LIBCPP_COMPILER_MSVC
+#endif // !_MSC_VER
template <class _Floating>
[[nodiscard]] to_chars_result _Floating_to_chars_ryu(
lib/libcxx/src/include/atomic_support.h
@@ -9,8 +9,8 @@
#ifndef ATOMIC_SUPPORT_H
#define ATOMIC_SUPPORT_H
-#include "__config"
-#include "memory" // for __libcpp_relaxed_load
+#include <__config>
+#include <memory> // for __libcpp_relaxed_load
#if defined(__clang__) && __has_builtin(__atomic_load_n) \
&& __has_builtin(__atomic_store_n) \
lib/libcxx/src/include/config_elast.h
@@ -29,6 +29,8 @@
// No _LIBCPP_ELAST needed on Fuchsia
#elif defined(__wasi__)
// No _LIBCPP_ELAST needed on WASI
+#elif defined(__EMSCRIPTEN__)
+// No _LIBCPP_ELAST needed on Emscripten
#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)
#define _LIBCPP_ELAST 4095
#elif defined(__APPLE__)
lib/libcxx/src/include/sso_allocator.h
@@ -41,6 +41,11 @@ public:
typedef _Tp* pointer;
typedef _Tp value_type;
+ template <class U>
+ struct rebind {
+ using other = __sso_allocator<U, _Np>;
+ };
+
_LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
_LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()
lib/libcxx/src/include/to_chars_floating_point.h
@@ -17,16 +17,19 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__algorithm/find.h"
-#include "__algorithm/find_if.h"
-#include "__algorithm/lower_bound.h"
-#include "__algorithm/min.h"
-#include "__config"
-#include "__iterator/access.h"
-#include "__iterator/size.h"
-#include "bit"
-#include "cfloat"
-#include "climits"
+#include <__algorithm/find.h>
+#include <__algorithm/find_if.h>
+#include <__algorithm/lower_bound.h>
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__config>
+#include <__functional/operations.h>
+#include <__iterator/access.h>
+#include <__iterator/size.h>
+#include <bit>
+#include <cfloat>
+#include <climits>
+
#include "include/ryu/ryu.h"
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/ryu/d2fixed.cpp
@@ -39,10 +39,11 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
-#include "charconv"
-#include "cstring"
-#include "system_error"
+#include <__assert>
+#include <__config>
+#include <charconv>
+#include <cstring>
+#include <system_error>
#include "include/ryu/common.h"
#include "include/ryu/d2fixed.h"
lib/libcxx/src/ryu/d2s.cpp
@@ -39,8 +39,9 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
-#include "charconv"
+#include <__assert>
+#include <__config>
+#include <charconv>
#include "include/ryu/common.h"
#include "include/ryu/d2fixed.h"
lib/libcxx/src/ryu/f2s.cpp
@@ -39,8 +39,9 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
-#include "__config"
-#include "charconv"
+#include <__assert>
+#include <__config>
+#include <charconv>
#include "include/ryu/common.h"
#include "include/ryu/d2fixed.h"
lib/libcxx/src/support/ibm/xlocale_zos.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include <__assert>
#include <__support/ibm/xlocale.h>
#include <sstream>
#include <vector>
@@ -31,7 +32,7 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
}
}
}
-
+
// Create new locale.
locale_t newloc = new locale_struct();
@@ -74,18 +75,18 @@ locale_t uselocale(locale_t newloc) {
if (newloc) {
// Set locales and check for errors.
- bool is_error =
- (newloc->category_mask & LC_COLLATE_MASK &&
+ bool is_error =
+ (newloc->category_mask & LC_COLLATE_MASK &&
setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||
- (newloc->category_mask & LC_CTYPE_MASK &&
+ (newloc->category_mask & LC_CTYPE_MASK &&
setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||
- (newloc->category_mask & LC_MONETARY_MASK &&
+ (newloc->category_mask & LC_MONETARY_MASK &&
setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||
- (newloc->category_mask & LC_NUMERIC_MASK &&
+ (newloc->category_mask & LC_NUMERIC_MASK &&
setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||
- (newloc->category_mask & LC_TIME_MASK &&
+ (newloc->category_mask & LC_TIME_MASK &&
setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||
- (newloc->category_mask & LC_MESSAGES_MASK &&
+ (newloc->category_mask & LC_MESSAGES_MASK &&
setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);
if (is_error) {
lib/libcxx/src/support/runtime/exception_fallback.ipp
@@ -11,9 +11,8 @@
namespace std {
-_LIBCPP_SAFE_STATIC static std::terminate_handler __terminate_handler;
-_LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler;
-
+static constinit std::terminate_handler __terminate_handler = nullptr;
+static constinit std::unexpected_handler __unexpected_handler = nullptr;
// libcxxrt provides implementations of these functions itself.
unexpected_handler
@@ -26,7 +25,6 @@ unexpected_handler
get_unexpected() noexcept
{
return __libcpp_atomic_load(&__unexpected_handler);
-
}
_LIBCPP_NORETURN
lib/libcxx/src/support/runtime/new_handler_fallback.ipp
@@ -9,7 +9,7 @@
namespace std {
-_LIBCPP_SAFE_STATIC static std::new_handler __new_handler;
+static constinit std::new_handler __new_handler = nullptr;
new_handler
set_new_handler(new_handler handler) noexcept
lib/libcxx/src/support/win32/locale_win32.cpp
@@ -97,10 +97,10 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
ret, n, format, loc, ap);
#else
__libcpp_locale_guard __current(loc);
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
int result = vsnprintf( ret, n, format, ap );
-#pragma clang diagnostic pop
+ _LIBCPP_DIAGNOSTIC_POP
#endif
va_end(ap);
return result;
lib/libcxx/src/support/win32/support.cpp
@@ -23,10 +23,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
// Query the count required.
va_list ap_copy;
va_copy(ap_copy, ap);
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
int count = vsnprintf( NULL, 0, format, ap_copy );
-#pragma clang diagnostic pop
+ _LIBCPP_DIAGNOSTIC_POP
va_end(ap_copy);
if (count < 0)
return count;
@@ -36,10 +36,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
return -1;
// If we haven't used exactly what was required, something is wrong.
// Maybe bug in vsnprintf. Report the error and return.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
if (vsnprintf(p, buffer_size, format, ap) != count) {
-#pragma clang diagnostic pop
+ _LIBCPP_DIAGNOSTIC_POP
free(p);
return -1;
}
lib/libcxx/src/algorithm.cpp
@@ -6,10 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "algorithm"
+#include <algorithm>
_LIBCPP_BEGIN_NAMESPACE_STD
+// TODO(varconst): this currently doesn't benefit `ranges::sort` because it uses `ranges::less` instead of `__less`.
+
template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
lib/libcxx/src/any.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "any"
+#include <any>
namespace std {
const char* bad_any_cast::what() const noexcept {
lib/libcxx/src/barrier.cpp
@@ -90,7 +90,7 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier)
delete __barrier;
}
-#endif //!defined(_LIBCPP_HAS_NO_TREE_BARRIER)
+#endif // !defined(_LIBCPP_HAS_NO_TREE_BARRIER)
_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/bind.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "functional"
+#include <functional>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/charconv.cpp
@@ -6,144 +6,34 @@
//
//===----------------------------------------------------------------------===//
-#include "charconv"
+#include <charconv>
#include <string.h>
-#include "include/ryu/digit_table.h"
#include "include/to_chars_floating_point.h"
_LIBCPP_BEGIN_NAMESPACE_STD
-namespace __itoa
-{
-
-template <typename T>
-inline _LIBCPP_INLINE_VISIBILITY char*
-append1(char* buffer, T i) noexcept
-{
- *buffer = '0' + static_cast<char>(i);
- return buffer + 1;
-}
-
-template <typename T>
-inline _LIBCPP_INLINE_VISIBILITY char*
-append2(char* buffer, T i) noexcept
-{
- memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2);
- return buffer + 2;
-}
-
-template <typename T>
-inline _LIBCPP_INLINE_VISIBILITY char*
-append3(char* buffer, T i) noexcept
-{
- return append2(append1(buffer, (i) / 100), (i) % 100);
-}
+#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
-template <typename T>
-inline _LIBCPP_INLINE_VISIBILITY char*
-append4(char* buffer, T i) noexcept
-{
- return append2(append2(buffer, (i) / 100), (i) % 100);
-}
-
-template <typename T>
-inline _LIBCPP_INLINE_VISIBILITY char*
-append2_no_zeros(char* buffer, T v) noexcept
-{
- if (v < 10)
- return append1(buffer, v);
- else
- return append2(buffer, v);
-}
-
-template <typename T>
-inline _LIBCPP_INLINE_VISIBILITY char*
-append4_no_zeros(char* buffer, T v) noexcept
-{
- if (v < 100)
- return append2_no_zeros(buffer, v);
- else if (v < 1000)
- return append3(buffer, v);
- else
- return append4(buffer, v);
-}
-
-template <typename T>
-inline _LIBCPP_INLINE_VISIBILITY char*
-append8_no_zeros(char* buffer, T v) noexcept
+namespace __itoa
{
- if (v < 10000)
- {
- buffer = append4_no_zeros(buffer, v);
- }
- else
- {
- buffer = append4_no_zeros(buffer, v / 10000);
- buffer = append4(buffer, v % 10000);
- }
- return buffer;
-}
-char*
+_LIBCPP_FUNC_VIS char*
__u32toa(uint32_t value, char* buffer) noexcept
{
- if (value < 100000000)
- {
- buffer = append8_no_zeros(buffer, value);
- }
- else
- {
- // value = aabbbbcccc in decimal
- const uint32_t a = value / 100000000; // 1 to 42
- value %= 100000000;
-
- buffer = append2_no_zeros(buffer, a);
- buffer = append4(buffer, value / 10000);
- buffer = append4(buffer, value % 10000);
- }
-
- return buffer;
+ return __base_10_u32(buffer, value);
}
-char*
+_LIBCPP_FUNC_VIS char*
__u64toa(uint64_t value, char* buffer) noexcept
{
- if (value < 100000000)
- {
- uint32_t v = static_cast<uint32_t>(value);
- buffer = append8_no_zeros(buffer, v);
- }
- else if (value < 10000000000000000)
- {
- const uint32_t v0 = static_cast<uint32_t>(value / 100000000);
- const uint32_t v1 = static_cast<uint32_t>(value % 100000000);
-
- buffer = append8_no_zeros(buffer, v0);
- buffer = append4(buffer, v1 / 10000);
- buffer = append4(buffer, v1 % 10000);
- }
- else
- {
- const uint32_t a =
- static_cast<uint32_t>(value / 10000000000000000); // 1 to 1844
- value %= 10000000000000000;
-
- buffer = append4_no_zeros(buffer, a);
-
- const uint32_t v0 = static_cast<uint32_t>(value / 100000000);
- const uint32_t v1 = static_cast<uint32_t>(value % 100000000);
- buffer = append4(buffer, v0 / 10000);
- buffer = append4(buffer, v0 % 10000);
- buffer = append4(buffer, v1 / 10000);
- buffer = append4(buffer, v1 % 10000);
- }
-
- return buffer;
+ return __base_10_u64(buffer, value);
}
} // namespace __itoa
+#endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
+
// The original version of floating-point to_chars was written by Microsoft and
// contributed with the following license.
lib/libcxx/src/chrono.cpp
@@ -12,9 +12,9 @@
#define _LARGE_TIME_API
#endif
-#include "chrono"
-#include "cerrno" // errno
-#include "system_error" // __throw_system_error
+#include <cerrno> // errno
+#include <chrono>
+#include <system_error> // __throw_system_error
#if defined(__MVS__)
#include <__support/ibm/gettod_zos.h> // gettimeofdayMonotonic
lib/libcxx/src/condition_variable.cpp
@@ -6,19 +6,21 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
+#include <__config>
#ifndef _LIBCPP_HAS_NO_THREADS
-#include "condition_variable"
-#include "thread"
-#include "system_error"
-#include "__undef_macros"
+#include <condition_variable>
+#include <thread>
+#include <system_error>
#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
-#pragma comment(lib, "pthread")
+# pragma comment(lib, "pthread")
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
// ~condition_variable is defined elsewhere.
@@ -90,4 +92,6 @@ notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // !_LIBCPP_HAS_NO_THREADS
lib/libcxx/src/condition_variable_destructor.cpp
@@ -11,8 +11,8 @@
// On some platforms ~condition_variable has been made trivial and the
// definition is only provided for ABI compatibility.
-#include "__config"
-#include "__threading_support"
+#include <__config>
+#include <__threading_support>
#if !defined(_LIBCPP_HAS_NO_THREADS)
# if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION)
lib/libcxx/src/debug.cpp
@@ -6,43 +6,24 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
-#include "__debug"
-#include "functional"
-#include "algorithm"
-#include "string"
-#include "cstdio"
-#include "__hash_table"
+#include <__assert>
+#include <__config>
+#include <__debug>
+#include <__hash_table>
+#include <algorithm>
+#include <cstdio>
+#include <functional>
+#include <string>
+
#ifndef _LIBCPP_HAS_NO_THREADS
-#include "mutex"
-#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
-#pragma comment(lib, "pthread")
-#endif
+# include <mutex>
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-std::string __libcpp_debug_info::what() const {
- string msg = __file_;
- msg += ":" + to_string(__line_) + ": _LIBCPP_ASSERT '";
- msg += __pred_;
- msg += "' failed. ";
- msg += __msg_;
- return msg;
-}
-_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
- std::fprintf(stderr, "%s\n", info.what().c_str());
- std::abort();
-}
-
-_LIBCPP_SAFE_STATIC __libcpp_debug_function_type
- __libcpp_debug_function = __libcpp_abort_debug_function;
-
-bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
- __libcpp_debug_function = __func;
- return true;
-}
-
_LIBCPP_FUNC_VIS
__libcpp_db*
__get_db()
lib/libcxx/src/exception.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "exception"
-#include "new"
-#include "typeinfo"
+#include <exception>
+#include <new>
+#include <typeinfo>
#if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
#include <cxxabi.h>
lib/libcxx/src/format.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "format"
+#include <format>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/functional.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "functional"
+#include <functional>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/future.cpp
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
+#include <__config>
#ifndef _LIBCPP_HAS_NO_THREADS
-#include "future"
-#include "string"
+#include <future>
+#include <string>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -29,13 +29,9 @@ __future_error_category::name() const noexcept
return "future";
}
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wswitch"
-#elif defined(__GNUC__) || defined(__GNUG__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wswitch"
-#endif
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wswitch")
+_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wswitch")
string
__future_error_category::message(int ev) const
@@ -58,11 +54,7 @@ __future_error_category::message(int ev) const
return string("unspecified future_errc value\n");
}
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#elif defined(__GNUC__) || defined(__GNUG__)
-#pragma GCC diagnostic pop
-#endif
+_LIBCPP_DIAGNOSTIC_POP
const error_category&
future_category() noexcept
lib/libcxx/src/hash.cpp
@@ -6,14 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "__hash_table"
-#include "algorithm"
-#include "stdexcept"
-#include "type_traits"
-
-#ifdef __clang__
-#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
-#endif
+#include <__hash_table>
+#include <algorithm>
+#include <stdexcept>
+#include <type_traits>
+
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare")
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/ios.cpp
@@ -6,20 +6,20 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
-
-#include "ios"
-
+#include <__config>
+#include <__locale>
+#include <algorithm>
+#include <ios>
+#include <limits>
+#include <memory>
+#include <new>
#include <stdlib.h>
+#include <string>
-#include "__locale"
-#include "algorithm"
#include "include/config_elast.h"
-#include "limits"
-#include "memory"
-#include "new"
-#include "string"
-#include "__undef_macros"
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -439,3 +439,5 @@ ios_base::sync_with_stdio(bool sync)
}
_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
lib/libcxx/src/ios.instantiations.cpp
@@ -6,14 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
-#include "fstream"
-#include "ios"
-#include "istream"
-#include "ostream"
-#include "sstream"
-#include "streambuf"
-
+#include <__config>
+#include <fstream>
+#include <ios>
+#include <istream>
+#include <ostream>
+#include <sstream>
+#include <streambuf>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/iostream.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "__std_stream"
-#include "__locale"
-#include "string"
-#include "new"
+#include <__locale>
+#include <__std_stream>
+#include <new>
+#include <string>
#define _str(s) #s
#define str(s) _str(s)
lib/libcxx/src/legacy_debug_handler.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+
+// This file defines the legacy default debug handler and related mechanisms
+// to set it. This is for backwards ABI compatibility with code that has been
+// using this debug handler previously.
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
+ _LIBCPP_EXPORTED_FROM_ABI string what() const;
+
+ const char* __file_;
+ int __line_;
+ const char* __pred_;
+ const char* __msg_;
+};
+
+std::string __libcpp_debug_info::what() const {
+ string msg = __file_;
+ msg += ":" + std::to_string(__line_) + ": _LIBCPP_ASSERT '";
+ msg += __pred_;
+ msg += "' failed. ";
+ msg += __msg_;
+ return msg;
+}
+
+_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
+ std::fprintf(stderr, "%s\n", info.what().c_str());
+ std::abort();
+}
+
+typedef void (*__libcpp_debug_function_type)(__libcpp_debug_info const&);
+
+_LIBCPP_EXPORTED_FROM_ABI
+constinit __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function;
+
+_LIBCPP_EXPORTED_FROM_ABI
+bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
+ __libcpp_debug_function = __func;
+ return true;
+}
+
+_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/legacy_pointer_safety.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
+#include <__config>
#include <memory>
// Support for garbage collection was removed in C++23 by https://wg21.link/P2186R2. Libc++ implements
lib/libcxx/src/locale.cpp
@@ -12,20 +12,21 @@
#define _LCONV_C99
#endif
-#include "algorithm"
-#include "clocale"
-#include "codecvt"
-#include "cstdio"
-#include "cstdlib"
-#include "cstring"
-#include "locale"
-#include "string"
-#include "type_traits"
-#include "typeinfo"
-#include "vector"
+#include <__utility/unreachable.h>
+#include <algorithm>
+#include <clocale>
+#include <codecvt>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <locale>
+#include <string>
+#include <type_traits>
+#include <typeinfo>
+#include <vector>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-# include "cwctype"
+# include <cwctype>
#endif
#if defined(_AIX)
@@ -44,13 +45,13 @@
#include "include/atomic_support.h"
#include "include/sso_allocator.h"
-#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.
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wsign-conversion"
-#endif
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wsign-conversion")
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -127,11 +128,6 @@ _LIBCPP_NORETURN static void __throw_runtime_error(const string &msg)
}
-#if defined(_AIX)
-// Set priority to INT_MIN + 256 + 150
-# pragma priority ( -2147483242 )
-#endif
-
const locale::category locale::none;
const locale::category locale::collate;
const locale::category locale::ctype;
@@ -1528,7 +1524,7 @@ char
ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
{
int r = __libcpp_wctob_l(c, __l);
- return r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
+ return (r != EOF) ? static_cast<char>(r) : dfault;
}
const wchar_t*
@@ -1537,7 +1533,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
for (; low != high; ++low, ++dest)
{
int r = __libcpp_wctob_l(*low, __l);
- *dest = r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
+ *dest = (r != EOF) ? static_cast<char>(r) : dfault;
}
return low;
}
@@ -1835,6 +1831,7 @@ codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept
// 040000 - 0FFFFF D8C0 - DBBF, DC00 - DFFF F1 - F3, 80 - BF, 80 - BF, 80 - BF 786432
// 100000 - 10FFFF DBC0 - DBFF, DC00 - DFFF F4 - F4, 80 - 8F, 80 - BF, 80 - BF 65536
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
static
codecvt_base::result
utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
@@ -3208,6 +3205,8 @@ utf16le_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
return static_cast<int>(frm_nxt - frm);
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
// template <> class codecvt<char16_t, char, mbstate_t>
locale::id codecvt<char16_t, char, mbstate_t>::id;
@@ -3615,6 +3614,7 @@ __codecvt_utf8<wchar_t>::do_length(state_type&,
#endif
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf8<wchar_t>::do_max_length() const noexcept
{
@@ -3697,6 +3697,7 @@ __codecvt_utf8<char16_t>::do_length(state_type&,
return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf8<char16_t>::do_max_length() const noexcept
{
@@ -3704,6 +3705,7 @@ __codecvt_utf8<char16_t>::do_max_length() const noexcept
return 6;
return 3;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf8<char32_t>
@@ -3772,6 +3774,7 @@ __codecvt_utf8<char32_t>::do_length(state_type&,
return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf8<char32_t>::do_max_length() const noexcept
{
@@ -3779,6 +3782,7 @@ __codecvt_utf8<char32_t>::do_max_length() const noexcept
return 7;
return 4;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf16<wchar_t, false>
@@ -4057,6 +4061,7 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&,
return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf16<char16_t, false>::do_max_length() const noexcept
{
@@ -4064,6 +4069,7 @@ __codecvt_utf16<char16_t, false>::do_max_length() const noexcept
return 4;
return 2;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf16<char16_t, true>
@@ -4132,6 +4138,7 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&,
return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf16<char16_t, true>::do_max_length() const noexcept
{
@@ -4139,6 +4146,7 @@ __codecvt_utf16<char16_t, true>::do_max_length() const noexcept
return 4;
return 2;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf16<char32_t, false>
@@ -4207,6 +4215,7 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&,
return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf16<char32_t, false>::do_max_length() const noexcept
{
@@ -4214,6 +4223,7 @@ __codecvt_utf16<char32_t, false>::do_max_length() const noexcept
return 6;
return 4;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf16<char32_t, true>
@@ -4282,6 +4292,7 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&,
return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf16<char32_t, true>::do_max_length() const noexcept
{
@@ -4289,6 +4300,7 @@ __codecvt_utf16<char32_t, true>::do_max_length() const noexcept
return 6;
return 4;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf8_utf16<wchar_t>
@@ -4446,6 +4458,7 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&,
return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
{
@@ -4453,6 +4466,7 @@ __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
return 7;
return 4;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf8_utf16<char32_t>
@@ -4521,6 +4535,7 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&,
return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
}
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
int
__codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
{
@@ -4528,6 +4543,7 @@ __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
return 7;
return 4;
}
+_LIBCPP_SUPPRESS_DEPRECATED_POP
// __narrow_to_utf8<16>
@@ -4623,7 +4639,7 @@ static bool checked_string_to_char_convert(char& dest,
return false;
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
@@ -5200,12 +5216,8 @@ __time_get::~__time_get()
{
freelocale(__loc_);
}
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wmissing-field-initializers"
-#endif
-#if defined(__GNUG__)
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
-#endif
+
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
template <>
string
@@ -5351,9 +5363,7 @@ __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)
return result;
}
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wmissing-braces"
-#endif
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-braces")
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
@@ -6599,3 +6609,5 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t,
#endif
_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
lib/libcxx/src/memory.cpp
@@ -6,14 +6,21 @@
//
//===----------------------------------------------------------------------===//
-#include "memory"
+#include <__config>
+#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
+# define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
+#endif
+
+#include <memory>
+
#ifndef _LIBCPP_HAS_NO_THREADS
-# include "mutex"
-# include "thread"
-# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
-# pragma comment(lib, "pthread")
-# endif
+# include <mutex>
+# include <thread>
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
#endif
+
#include "include/atomic_support.h"
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -36,7 +43,7 @@ __shared_weak_count::~__shared_weak_count()
{
}
-#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
+#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
void
__shared_count::__add_shared() noexcept
{
@@ -72,8 +79,7 @@ __shared_weak_count::__release_shared() noexcept
if (__shared_count::__release_shared())
__release_weak();
}
-
-#endif // _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
+#endif // _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
void
__shared_weak_count::__release_weak() noexcept
@@ -132,9 +138,13 @@ __shared_weak_count::__get_deleter(const type_info&) const noexcept
#if !defined(_LIBCPP_HAS_NO_THREADS)
-_LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
-_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut_back[__sp_mut_count] =
+static constexpr std::size_t __sp_mut_count = 32;
+static constinit __libcpp_mutex_t mut_back[__sp_mut_count] =
{
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
@@ -150,16 +160,7 @@ void
__sp_mut::lock() noexcept
{
auto m = static_cast<__libcpp_mutex_t*>(__lx);
- unsigned count = 0;
- while (!__libcpp_mutex_trylock(m))
- {
- if (++count > 16)
- {
- __libcpp_mutex_lock(m);
- break;
- }
- this_thread::yield();
- }
+ __libcpp_mutex_lock(m);
}
void
@@ -171,12 +172,15 @@ __sp_mut::unlock() noexcept
__sp_mut&
__get_sp_mut(const void* p)
{
- static __sp_mut muts[__sp_mut_count]
- {
+ static constinit __sp_mut muts[__sp_mut_count] = {
&mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3],
&mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7],
&mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11],
- &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15]
+ &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15],
+ &mut_back[16], &mut_back[17], &mut_back[18], &mut_back[19],
+ &mut_back[20], &mut_back[21], &mut_back[22], &mut_back[23],
+ &mut_back[24], &mut_back[25], &mut_back[26], &mut_back[27],
+ &mut_back[28], &mut_back[29], &mut_back[30], &mut_back[31]
};
return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
}
lib/libcxx/src/mutex.cpp
@@ -6,19 +6,24 @@
//
//===----------------------------------------------------------------------===//
-#include "mutex"
-#include "limits"
-#include "system_error"
+#include <__assert>
+#include <limits>
+#include <mutex>
+#include <system_error>
+
#include "include/atomic_support.h"
-#include "__undef_macros"
#ifndef _LIBCPP_HAS_NO_THREADS
-#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
-#pragma comment(lib, "pthread")
-#endif
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
+
#ifndef _LIBCPP_HAS_NO_THREADS
const defer_lock_t defer_lock{};
@@ -196,8 +201,8 @@ recursive_timed_mutex::unlock() noexcept
// keep in sync with: 7741191.
#ifndef _LIBCPP_HAS_NO_THREADS
-_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
-_LIBCPP_SAFE_STATIC static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
+static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
+static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
#endif
void __call_once(volatile once_flag::_State_type& flag, void* arg,
@@ -258,3 +263,5 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg,
}
_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
lib/libcxx/src/mutex_destructor.cpp
@@ -16,13 +16,13 @@
// we re-declare the entire class in this file instead of using
// _LIBCPP_BUILDING_LIBRARY to change the definition in the headers.
-#include "__config"
-#include "__threading_support"
+#include <__config>
+#include <__threading_support>
#if !defined(_LIBCPP_HAS_NO_THREADS)
-#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)
-#define NEEDS_MUTEX_DESTRUCTOR
-#endif
+# if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)
+# define NEEDS_MUTEX_DESTRUCTOR
+# endif
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/new.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include <new>
#include <stdlib.h>
-#include "new"
#include "include/atomic_support.h"
#if defined(_LIBCPP_ABI_MICROSOFT)
lib/libcxx/src/optional.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "optional"
-#include "__availability"
+#include <__availability>
+#include <optional>
namespace std
{
lib/libcxx/src/random.cpp
@@ -13,9 +13,9 @@
# define _CRT_RAND_S
#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
-#include "limits"
-#include "random"
-#include "system_error"
+#include <limits>
+#include <random>
+#include <system_error>
#if defined(__sun__)
# define rename solaris_headers_are_broken
lib/libcxx/src/random_shuffle.cpp
@@ -6,19 +6,20 @@
//
//===----------------------------------------------------------------------===//
-#include "algorithm"
-#include "random"
+#include <algorithm>
+#include <random>
+
#ifndef _LIBCPP_HAS_NO_THREADS
-# include "mutex"
-# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
-# pragma comment(lib, "pthread")
-# endif
+# include <mutex>
+# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
+# pragma comment(lib, "pthread")
+# endif
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_HAS_NO_THREADS
-_LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
+static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
#endif
unsigned __rs_default::__c_ = 0;
lib/libcxx/src/regex.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "regex"
-#include "algorithm"
-#include "iterator"
+#include <algorithm>
+#include <iterator>
+#include <regex>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/stdexcept.cpp
@@ -6,11 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "stdexcept"
-#include "new"
-#include "string"
-#include "system_error"
-
+#include <new>
+#include <stdexcept>
+#include <string>
+#include <system_error>
#ifdef _LIBCPP_ABI_VCRUNTIME
#include "support/runtime/stdexcept_vcruntime.ipp"
lib/libcxx/src/string.cpp
@@ -6,17 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include "string"
-#include "charconv"
-#include "cstdlib"
-#include "cerrno"
-#include "limits"
-#include "stdexcept"
+#include <__assert>
+#include <cerrno>
+#include <charconv>
+#include <cstdlib>
+#include <limits>
+#include <stdexcept>
#include <stdio.h>
-#include "__debug"
+#include <string>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-# include "cwchar"
+# include <cwchar>
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -56,42 +56,33 @@ void __basic_string_common<true>::__throw_out_of_range() const {
#endif
#undef _LIBCPP_EXTERN_TEMPLATE_DEFINE
-template string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&);
+template string operator+<char, char_traits<char>, allocator<char>>(char const*, string const&);
namespace
{
template<typename T>
-inline
-void throw_helper( const string& msg )
-{
+inline void throw_helper(const string& msg) {
#ifndef _LIBCPP_NO_EXCEPTIONS
- throw T( msg );
+ throw T(msg);
#else
fprintf(stderr, "%s\n", msg.c_str());
_VSTD::abort();
#endif
}
-inline
-void throw_from_string_out_of_range( const string& func )
-{
+inline void throw_from_string_out_of_range(const string& func) {
throw_helper<out_of_range>(func + ": out of range");
}
-inline
-void throw_from_string_invalid_arg( const string& func )
-{
+inline void throw_from_string_invalid_arg(const string& func) {
throw_helper<invalid_argument>(func + ": no conversion");
}
// as_integer
template<typename V, typename S, typename F>
-inline
-V
-as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)
-{
+inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) {
typename S::value_type* ptr = nullptr;
const typename S::value_type* const p = str.c_str();
typename remove_reference<decltype(errno)>::type errno_save = errno;
@@ -108,109 +99,77 @@ as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)
}
template<typename V, typename S>
-inline
-V
-as_integer(const string& func, const S& s, size_t* idx, int base);
+inline V as_integer(const string& func, const S& s, size_t* idx, int base);
// string
template<>
-inline
-int
-as_integer(const string& func, const string& s, size_t* idx, int base )
-{
+inline int as_integer(const string& func, const string& s, size_t* idx, int base) {
// Use long as no Standard string to integer exists.
- long r = as_integer_helper<long>( func, s, idx, base, strtol );
+ long r = as_integer_helper<long>(func, s, idx, base, strtol);
if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
throw_from_string_out_of_range(func);
return static_cast<int>(r);
}
template<>
-inline
-long
-as_integer(const string& func, const string& s, size_t* idx, int base )
-{
- return as_integer_helper<long>( func, s, idx, base, strtol );
+inline long as_integer(const string& func, const string& s, size_t* idx, int base) {
+ return as_integer_helper<long>(func, s, idx, base, strtol);
}
template<>
-inline
-unsigned long
-as_integer( const string& func, const string& s, size_t* idx, int base )
-{
- return as_integer_helper<unsigned long>( func, s, idx, base, strtoul );
+inline unsigned long as_integer(const string& func, const string& s, size_t* idx, int base) {
+ return as_integer_helper<unsigned long>(func, s, idx, base, strtoul);
}
template<>
-inline
-long long
-as_integer( const string& func, const string& s, size_t* idx, int base )
-{
- return as_integer_helper<long long>( func, s, idx, base, strtoll );
+inline long long as_integer(const string& func, const string& s, size_t* idx, int base) {
+ return as_integer_helper<long long>(func, s, idx, base, strtoll);
}
template<>
-inline
-unsigned long long
-as_integer( const string& func, const string& s, size_t* idx, int base )
-{
- return as_integer_helper<unsigned long long>( func, s, idx, base, strtoull );
+inline unsigned long long as_integer(const string& func, const string& s, size_t* idx, int base) {
+ return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
// wstring
template<>
-inline
-int
-as_integer( const string& func, const wstring& s, size_t* idx, int base )
-{
+inline int as_integer(const string& func, const wstring& s, size_t* idx, int base) {
// Use long as no Stantard string to integer exists.
- long r = as_integer_helper<long>( func, s, idx, base, wcstol );
+ long r = as_integer_helper<long>(func, s, idx, base, wcstol);
if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
throw_from_string_out_of_range(func);
return static_cast<int>(r);
}
template<>
-inline
-long
-as_integer( const string& func, const wstring& s, size_t* idx, int base )
-{
- return as_integer_helper<long>( func, s, idx, base, wcstol );
+inline long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
+ return as_integer_helper<long>(func, s, idx, base, wcstol);
}
template<>
inline
unsigned long
-as_integer( const string& func, const wstring& s, size_t* idx, int base )
+as_integer(const string& func, const wstring& s, size_t* idx, int base)
{
- return as_integer_helper<unsigned long>( func, s, idx, base, wcstoul );
+ return as_integer_helper<unsigned long>(func, s, idx, base, wcstoul);
}
template<>
-inline
-long long
-as_integer( const string& func, const wstring& s, size_t* idx, int base )
-{
- return as_integer_helper<long long>( func, s, idx, base, wcstoll );
+inline long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
+ return as_integer_helper<long long>(func, s, idx, base, wcstoll);
}
template<>
-inline
-unsigned long long
-as_integer( const string& func, const wstring& s, size_t* idx, int base )
-{
- return as_integer_helper<unsigned long long>( func, s, idx, base, wcstoull );
+inline unsigned long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
+ return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// as_float
template<typename V, typename S, typename F>
-inline
-V
-as_float_helper(const string& func, const S& str, size_t* idx, F f )
-{
+inline V as_float_helper(const string& func, const S& str, size_t* idx, F f) {
typename S::value_type* ptr = nullptr;
const typename S::value_type* const p = str.c_str();
typename remove_reference<decltype(errno)>::type errno_save = errno;
@@ -227,172 +186,107 @@ as_float_helper(const string& func, const S& str, size_t* idx, F f )
}
template<typename V, typename S>
-inline
-V as_float( const string& func, const S& s, size_t* idx = nullptr );
+inline V as_float(const string& func, const S& s, size_t* idx = nullptr);
template<>
-inline
-float
-as_float( const string& func, const string& s, size_t* idx )
-{
- return as_float_helper<float>( func, s, idx, strtof );
+inline float as_float(const string& func, const string& s, size_t* idx) {
+ return as_float_helper<float>(func, s, idx, strtof);
}
template<>
-inline
-double
-as_float(const string& func, const string& s, size_t* idx )
-{
- return as_float_helper<double>( func, s, idx, strtod );
+inline double as_float(const string& func, const string& s, size_t* idx) {
+ return as_float_helper<double>(func, s, idx, strtod);
}
template<>
-inline
-long double
-as_float( const string& func, const string& s, size_t* idx )
-{
- return as_float_helper<long double>( func, s, idx, strtold );
+inline long double as_float(const string& func, const string& s, size_t* idx) {
+ return as_float_helper<long double>(func, s, idx, strtold);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template<>
-inline
-float
-as_float( const string& func, const wstring& s, size_t* idx )
-{
- return as_float_helper<float>( func, s, idx, wcstof );
+inline float as_float(const string& func, const wstring& s, size_t* idx) {
+ return as_float_helper<float>(func, s, idx, wcstof);
}
template<>
-inline
-double
-as_float( const string& func, const wstring& s, size_t* idx )
-{
- return as_float_helper<double>( func, s, idx, wcstod );
+inline double as_float(const string& func, const wstring& s, size_t* idx) {
+ return as_float_helper<double>(func, s, idx, wcstod);
}
template<>
-inline
-long double
-as_float( const string& func, const wstring& s, size_t* idx )
-{
- return as_float_helper<long double>( func, s, idx, wcstold );
+inline long double as_float(const string& func, const wstring& s, size_t* idx) {
+ return as_float_helper<long double>(func, s, idx, wcstold);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
} // unnamed namespace
-int
-stoi(const string& str, size_t* idx, int base)
-{
- return as_integer<int>( "stoi", str, idx, base );
+int stoi(const string& str, size_t* idx, int base) {
+ return as_integer<int>("stoi", str, idx, base);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-int
-stoi(const wstring& str, size_t* idx, int base)
-{
- return as_integer<int>( "stoi", str, idx, base );
+long stol(const string& str, size_t* idx, int base) {
+ return as_integer<long>("stol", str, idx, base);
}
-#endif
-long
-stol(const string& str, size_t* idx, int base)
-{
- return as_integer<long>( "stol", str, idx, base );
+unsigned long stoul(const string& str, size_t* idx, int base) {
+ return as_integer<unsigned long>("stoul", str, idx, base);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-long
-stol(const wstring& str, size_t* idx, int base)
-{
- return as_integer<long>( "stol", str, idx, base );
+long long stoll(const string& str, size_t* idx, int base) {
+ return as_integer<long long>("stoll", str, idx, base);
}
-#endif
-unsigned long
-stoul(const string& str, size_t* idx, int base)
-{
- return as_integer<unsigned long>( "stoul", str, idx, base );
+unsigned long long stoull(const string& str, size_t* idx, int base) {
+ return as_integer<unsigned long long>("stoull", str, idx, base);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-unsigned long
-stoul(const wstring& str, size_t* idx, int base)
-{
- return as_integer<unsigned long>( "stoul", str, idx, base );
+float stof(const string& str, size_t* idx) {
+ return as_float<float>("stof", str, idx);
}
-#endif
-long long
-stoll(const string& str, size_t* idx, int base)
-{
- return as_integer<long long>( "stoll", str, idx, base );
+double stod(const string& str, size_t* idx) {
+ return as_float<double>("stod", str, idx);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-long long
-stoll(const wstring& str, size_t* idx, int base)
-{
- return as_integer<long long>( "stoll", str, idx, base );
+long double stold(const string& str, size_t* idx) {
+ return as_float<long double>("stold", str, idx);
}
-#endif
-unsigned long long
-stoull(const string& str, size_t* idx, int base)
-{
- return as_integer<unsigned long long>( "stoull", str, idx, base );
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+int stoi(const wstring& str, size_t* idx, int base) {
+ return as_integer<int>("stoi", str, idx, base);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-unsigned long long
-stoull(const wstring& str, size_t* idx, int base)
-{
- return as_integer<unsigned long long>( "stoull", str, idx, base );
+long stol(const wstring& str, size_t* idx, int base) {
+ return as_integer<long>("stol", str, idx, base);
}
-#endif
-float
-stof(const string& str, size_t* idx)
-{
- return as_float<float>( "stof", str, idx );
+unsigned long stoul(const wstring& str, size_t* idx, int base) {
+ return as_integer<unsigned long>("stoul", str, idx, base);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-float
-stof(const wstring& str, size_t* idx)
-{
- return as_float<float>( "stof", str, idx );
+long long stoll(const wstring& str, size_t* idx, int base) {
+ return as_integer<long long>("stoll", str, idx, base);
}
-#endif
-double
-stod(const string& str, size_t* idx)
-{
- return as_float<double>( "stod", str, idx );
+unsigned long long stoull(const wstring& str, size_t* idx, int base) {
+ return as_integer<unsigned long long>("stoull", str, idx, base);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-double
-stod(const wstring& str, size_t* idx)
-{
- return as_float<double>( "stod", str, idx );
+float stof(const wstring& str, size_t* idx) {
+ return as_float<float>("stof", str, idx);
}
-#endif
-long double
-stold(const string& str, size_t* idx)
-{
- return as_float<long double>( "stold", str, idx );
+double stod(const wstring& str, size_t* idx) {
+ return as_float<double>("stod", str, idx);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-long double
-stold(const wstring& str, size_t* idx)
-{
- return as_float<long double>( "stold", str, idx );
+long double stold(const wstring& str, size_t* idx) {
+ return as_float<long double>("stold", str, idx);
}
-#endif
+#endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS
// to_string
@@ -402,21 +296,15 @@ namespace
// as_string
template<typename S, typename P, typename V >
-inline
-S
-as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a)
-{
+inline S as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a) {
typedef typename S::size_type size_type;
size_type available = s.size();
- while (true)
- {
+ while (true) {
int status = sprintf_like(&s[0], available + 1, fmt, a);
- if ( status >= 0 )
- {
+ if (status >= 0) {
size_type used = static_cast<size_type>(status);
- if ( used <= available )
- {
- s.resize( used );
+ if (used <= available) {
+ s.resize(used);
break;
}
available = used; // Assume this is advice of how much space we need.
@@ -432,11 +320,8 @@ template <class S>
struct initial_string;
template <>
-struct initial_string<string>
-{
- string
- operator()() const
- {
+struct initial_string<string> {
+ string operator()() const {
string s;
s.resize(s.capacity());
return s;
@@ -445,11 +330,8 @@ struct initial_string<string>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-struct initial_string<wstring>
-{
- wstring
- operator()() const
- {
+struct initial_string<wstring> {
+ wstring operator()() const {
wstring s(20, wchar_t());
s.resize(s.capacity());
return s;
@@ -458,10 +340,7 @@ struct initial_string<wstring>
typedef int (*wide_printf)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...);
-inline
-wide_printf
-get_swprintf()
-{
+inline wide_printf get_swprintf() {
#ifndef _LIBCPP_MSVCRT
return swprintf;
#else
@@ -471,8 +350,7 @@ get_swprintf()
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <typename S, typename V>
-S i_to_string(V v)
-{
+S i_to_string(V v) {
// numeric_limits::digits10 returns value less on 1 than desired for unsigned numbers.
// For example, for 1-byte unsigned value digits10 is 2 (999 can not be represented),
// so we need +1 here.
lib/libcxx/src/strstream.cpp
@@ -6,13 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#include "strstream"
-#include "algorithm"
-#include "climits"
-#include "cstring"
-#include "cstdlib"
-#include "__debug"
-#include "__undef_macros"
+#include <__assert>
+#include <__utility/unreachable.h>
+#include <algorithm>
+#include <climits>
+#include <cstdlib>
+#include <cstring>
+#include <strstream>
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -268,7 +271,7 @@ strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmod
newoff = seekhigh - eback();
break;
default:
- _LIBCPP_UNREACHABLE();
+ __libcpp_unreachable();
}
newoff += __off;
if (0 <= newoff && newoff <= seekhigh - eback())
@@ -333,3 +336,5 @@ strstream::~strstream()
}
_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
lib/libcxx/src/system_error.cpp
@@ -6,18 +6,21 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
+#include <__config>
+#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
+# define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS
+#endif
-#include "system_error"
+#include <__assert>
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <string.h>
+#include <system_error>
#include "include/config_elast.h"
-#include "cerrno"
-#include "cstring"
-#include "cstdio"
-#include "cstdlib"
-#include "string"
-#include "string.h"
-#include "__debug"
#if defined(__ANDROID__)
#include <android/api-level.h>
@@ -27,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// class error_category
-#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
+#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS)
error_category::error_category() noexcept
{
}
lib/libcxx/src/thread.cpp
@@ -6,14 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#include "__config"
+#include <__config>
+
#ifndef _LIBCPP_HAS_NO_THREADS
-#include "thread"
-#include "exception"
-#include "vector"
-#include "future"
-#include "limits"
+#include <exception>
+#include <future>
+#include <limits>
+#include <thread>
+#include <vector>
#if __has_include(<unistd.h>)
# include <unistd.h> // for sysconf
@@ -114,8 +115,13 @@ sleep_for(const chrono::nanoseconds& ns)
__thread_specific_ptr<__thread_struct>&
__thread_local_data()
{
- static __thread_specific_ptr<__thread_struct> __p;
- return __p;
+ // Even though __thread_specific_ptr's destructor doesn't actually destroy
+ // anything (see comments there), we can't call it at all because threads may
+ // outlive the static variable and calling its destructor means accessing an
+ // object outside of its lifetime, which is UB.
+ alignas(__thread_specific_ptr<__thread_struct>) static char __b[sizeof(__thread_specific_ptr<__thread_struct>)];
+ static __thread_specific_ptr<__thread_struct>* __p = new (__b) __thread_specific_ptr<__thread_struct>();
+ return *__p;
}
// __thread_struct_imp
lib/libcxx/src/typeinfo.cpp
@@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "typeinfo"
+#include <typeinfo>
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_VCRUNTIME)
+
#include <string.h>
int std::type_info::__compare(const type_info &__rhs) const noexcept {
lib/libcxx/src/utility.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "utility"
+#include <utility>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/valarray.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "valarray"
+#include <valarray>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/variant.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "variant"
+#include <variant>
namespace std {
lib/libcxx/src/vector.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "vector"
+#include <vector>
_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/verbose_abort.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <__config>
+#include <__verbose_abort>
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+
+#ifdef __BIONIC__
+# include <android/api-level.h>
+# if __ANDROID_API__ >= 21
+# include <syslog.h>
+extern "C" void android_set_abort_message(const char* msg);
+# else
+# include <assert.h>
+# endif // __ANDROID_API__ >= 21
+#endif // __BIONIC__
+
+#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
+# include <CrashReporterClient.h>
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_WEAK
+void __libcpp_verbose_abort(char const* format, ...) {
+ // Write message to stderr. We do this before formatting into a
+ // buffer so that we still get some information out if that fails.
+ {
+ va_list list;
+ va_start(list, format);
+ std::vfprintf(stderr, format, list);
+ va_end(list);
+ }
+
+ // Format the arguments into an allocated buffer for CrashReport & friends.
+ // We leak the buffer on purpose, since we're about to abort() anyway.
+ char* buffer; (void)buffer;
+ va_list list;
+ va_start(list, format);
+
+#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
+ // Note that we should technically synchronize accesses here (by e.g. taking a lock),
+ // however concretely we're only setting a pointer, so the likelihood of a race here
+ // is low.
+ vasprintf(&buffer, format, list);
+ CRSetCrashLogMessage(buffer);
+#elif defined(__BIONIC__)
+ vasprintf(&buffer, format, list);
+
+# if __ANDROID_API__ >= 21
+ // Show error in tombstone.
+ android_set_abort_message(buffer);
+
+ // Show error in logcat.
+ openlog("libc++", 0, 0);
+ syslog(LOG_CRIT, "%s", buffer);
+ closelog();
+# else
+ // The good error reporting wasn't available in Android until L. Since we're
+ // about to abort anyway, just call __assert2, which will log _somewhere_
+ // (tombstone and/or logcat) in older releases.
+ __assert2(__FILE__, __LINE__, __func__, buffer);
+# endif // __ANDROID_API__ >= 21
+#endif
+ va_end(list);
+
+ std::abort();
+}
+
+_LIBCPP_END_NAMESPACE_STD
src/libcxx.zig
@@ -54,6 +54,7 @@ const libcxx_files = [_][]const u8{
"src/ios.cpp",
"src/ios.instantiations.cpp",
"src/iostream.cpp",
+ "src/legacy_debug_handler.cpp",
"src/legacy_pointer_safety.cpp",
"src/locale.cpp",
"src/memory.cpp",
@@ -85,6 +86,7 @@ const libcxx_files = [_][]const u8{
"src/valarray.cpp",
"src/variant.cpp",
"src/vector.cpp",
+ "src/verbose_abort.cpp",
};
pub fn buildLibCXX(comp: *Compilation) !void {