[libc++][C++03] Remove code that is not used in C++03 (#134045)

This patch removes code which is guarded by `_LIBCPP_STD_VER` and
`_LIBCPP_CXX03_LANG`.

This is part of
https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.
This commit is contained in:
Nikolas Klauser
2025-05-06 09:53:56 +02:00
committed by GitHub
parent fe1d1159be
commit 3dc1f759e6
308 changed files with 164 additions and 15502 deletions

View File

@@ -66,65 +66,6 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
return std::equal(__first1, __last1, __first2, __equal_to());
}
#if _LIBCPP_STD_VER >= 14
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(
_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) {
while (__first1 != __last1 && __first2 != __last2) {
if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
return false;
++__first1;
++__first2;
}
return __first1 == __last1 && __first2 == __last2;
}
template <class _Tp,
class _Up,
class _Pred,
class _Proj1,
class _Proj2,
__enable_if_t<__desugars_to_v<__equal_tag, _Pred, _Tp, _Up> && __is_identity<_Proj1>::value &&
__is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
int> = 0>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
__equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) {
return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
}
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
equal(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2,
_BinaryPredicate __pred) {
if constexpr (__has_random_access_iterator_category<_InputIterator1>::value &&
__has_random_access_iterator_category<_InputIterator2>::value) {
if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
return false;
}
__identity __proj;
return std::__equal_impl(
std::__unwrap_iter(__first1),
std::__unwrap_iter(__last1),
std::__unwrap_iter(__first2),
std::__unwrap_iter(__last2),
__pred,
__proj,
__proj);
}
template <class _InputIterator1, class _InputIterator2>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
return std::equal(__first1, __last1, __first2, __last2, __equal_to());
}
#endif // _LIBCPP_STD_VER >= 14
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -33,21 +33,6 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) {
return __f;
}
// __movable_box is available in C++20, but is actually a copyable-box, so optimization is only correct in C++23
#if _LIBCPP_STD_VER >= 23
template <class _SegmentedIterator, class _Function>
requires __is_segmented_iterator<_SegmentedIterator>::value
_LIBCPP_HIDE_FROM_ABI constexpr _Function
for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function __func) {
ranges::__movable_box<_Function> __wrapped_func(in_place, std::move(__func));
std::__for_each_segment(__first, __last, [&](auto __lfirst, auto __llast) {
__wrapped_func =
ranges::__movable_box<_Function>(in_place, std::for_each(__lfirst, __llast, std::move(*__wrapped_func)));
});
return std::move(*__wrapped_func);
}
#endif // _LIBCPP_STD_VER >= 23
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -33,18 +33,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class = void>
struct _ConstTimeDistance : false_type {};
#if _LIBCPP_STD_VER >= 20
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2>
struct _ConstTimeDistance<_Iter1,
_Sent1,
_Iter2,
_Sent2,
__enable_if_t< sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2> >>
: true_type {};
#else
template <class _Iter1, class _Iter2>
struct _ConstTimeDistance<
_Iter1,
@@ -55,8 +43,6 @@ struct _ConstTimeDistance<
is_same<typename iterator_traits<_Iter2>::iterator_category, random_access_iterator_tag>::value > >
: true_type {};
#endif // _LIBCPP_STD_VER >= 20
// Internal functions
// For each element in [f1, l1) see if there are the same number of equal elements in [f2, l2)
@@ -261,45 +247,6 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt
return std::is_permutation(__first1, __last1, __first2, __equal_to());
}
#if _LIBCPP_STD_VER >= 14
// 2+2 iterators
template <class _ForwardIterator1, class _ForwardIterator2>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
return std::__is_permutation<_ClassicAlgPolicy>(
std::move(__first1),
std::move(__last1),
std::move(__first2),
std::move(__last2),
__equal_to(),
__identity(),
__identity());
}
// 2+2 iterators, predicate
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
_ForwardIterator1 __first1,
_ForwardIterator1 __last1,
_ForwardIterator2 __first2,
_ForwardIterator2 __last2,
_BinaryPredicate __pred) {
static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
"The predicate has to be callable");
return std::__is_permutation<_ClassicAlgPolicy>(
std::move(__first1),
std::move(__last1),
std::move(__first2),
std::move(__last2),
__pred,
__identity(),
__identity());
}
#endif // _LIBCPP_STD_VER >= 14
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -37,31 +37,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy>
struct _IterOps;
#if _LIBCPP_STD_VER >= 20
struct _RangeAlgPolicy {};
template <>
struct _IterOps<_RangeAlgPolicy> {
template <class _Iter>
using __value_type = iter_value_t<_Iter>;
template <class _Iter>
using __iterator_category = ranges::__iterator_concept<_Iter>;
template <class _Iter>
using __difference_type = iter_difference_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 prev = ranges::prev;
static constexpr auto __advance_to = ranges::advance;
};
#endif
struct _ClassicAlgPolicy {};
template <>

View File

@@ -73,33 +73,4 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Pred& __make_projected(_Pred& __pred, _
_LIBCPP_END_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
_LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
template <class _Comp, class _Proj1, class _Proj2>
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
if constexpr (__is_identity<decay_t<_Proj1>>::value && __is_identity<decay_t<_Proj2>>::value &&
!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) -> bool {
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 >= 20
#endif // _LIBCPP___CXX03___ALGORITHM_MAKE_PROJECTED_H

View File

@@ -35,21 +35,6 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
return std::max(__a, __b, __less<>());
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Compare>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
max(initializer_list<_Tp> __t, _Compare __comp) {
return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
}
template <class _Tp>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) {
return *std::max_element(__t.begin(), __t.end(), __less<>());
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -35,21 +35,6 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
return std::min(__a, __b, __less<>());
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Compare>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
min(initializer_list<_Tp> __t, _Compare __comp) {
return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
}
template <class _Tp>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) {
return *std::min_element(__t.begin(), __t.end(), __less<>());
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -34,25 +34,6 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __
return std::minmax(__a, __b, __less<>());
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Compare>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 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>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __t) {
return std::minmax(__t, __less<>());
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ALGORITHM_MINMAX_H

View File

@@ -164,52 +164,6 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
return std::mismatch(__first1, __last1, __first2, __equal_to());
}
#if _LIBCPP_STD_VER >= 14
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch(
_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)))
break;
++__first1;
++__first2;
}
return {std::move(__first1), std::move(__first2)};
}
template <class _Tp, class _Pred, class _Proj1, class _Proj2>
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>
__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
auto __len = std::min(__last1 - __first1, __last2 - __first2);
return std::__mismatch(__first1, __first1 + __len, __first2, __pred, __proj1, __proj2);
}
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2,
_BinaryPredicate __pred) {
__identity __proj;
auto __res = std::__mismatch(
std::__unwrap_iter(__first1),
std::__unwrap_iter(__last1),
std::__unwrap_iter(__first2),
std::__unwrap_iter(__last2),
__pred,
__proj,
__proj);
return {std::__rewrap_iter(__first1, __res.first), std::__rewrap_iter(__first2, __res.second)};
}
template <class _InputIterator1, class _InputIterator2>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
}
#endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -177,15 +177,6 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2
return std::search(__first1, __last1, __first2, __last2, __equal_to());
}
#if _LIBCPP_STD_VER >= 17
template <class _ForwardIterator, class _Searcher>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
return __s(__f, __l).first;
}
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ALGORITHM_SEARCH_H

View File

@@ -62,7 +62,6 @@ private:
}
};
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) || defined(_LIBCPP_BUILDING_LIBRARY)
class _LIBCPP_EXPORTED_FROM_ABI __rs_default;
_LIBCPP_EXPORTED_FROM_ABI __rs_default __rs_get();
@@ -111,14 +110,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) {
template <class _RandomAccessIterator, class _RandomNumberGenerator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
random_shuffle(_RandomAccessIterator __first,
_RandomAccessIterator __last,
# ifndef _LIBCPP_CXX03_LANG
_RandomNumberGenerator&& __rand)
# else
_RandomNumberGenerator& __rand)
# endif
{
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _RandomNumberGenerator&& __rand) {
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
difference_type __d = __last - __first;
if (__d > 1) {
@@ -129,7 +121,6 @@ random_shuffle(_RandomAccessIterator __first,
}
}
}
#endif
template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator>
_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator

View File

@@ -27,11 +27,7 @@ _LIBCPP_PUSH_MACROS
#include <__cxx03/__undef_macros>
// TODO: Find out how altivec changes things and allow vectorizations there too.
#if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_CLANG_VER) && !defined(__ALTIVEC__)
# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1
#else
# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0
#endif
#define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0
#if _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS && !defined(__OPTIMIZE_SIZE__)
# define _LIBCPP_VECTORIZE_ALGORITHMS 1

View File

@@ -135,12 +135,6 @@ 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 >= 20
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 =
@@ -966,22 +960,6 @@ _LIBCPP_HIDE_FROM_ABI void __sort_dispatch(_Type* __first, _Type* __last, less<_
std::__sort<__less<_Type>&, _Type*>(__first, __last, __comp);
}
#if _LIBCPP_STD_VER >= 14
template <class _AlgPolicy, class _Type, __enable_if_t<__sort_is_specialized_in_library<_Type>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI void __sort_dispatch(_Type* __first, _Type* __last, less<>&) {
__less<_Type> __comp;
std::__sort<__less<_Type>&, _Type*>(__first, __last, __comp);
}
#endif
#if _LIBCPP_STD_VER >= 20
template <class _AlgPolicy, class _Type, __enable_if_t<__sort_is_specialized_in_library<_Type>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI void __sort_dispatch(_Type* __first, _Type* __last, ranges::less&) {
__less<_Type> __comp;
std::__sort<__less<_Type>&, _Type*>(__first, __last, __comp);
}
#endif
template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
__sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {

View File

@@ -21,54 +21,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
template <class _Comp>
struct __debug_three_way_comp {
_Comp& __comp_;
_LIBCPP_HIDE_FROM_ABI constexpr __debug_three_way_comp(_Comp& __c) : __comp_(__c) {}
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(const _Tp& __x, const _Up& __y) {
auto __r = __comp_(__x, __y);
if constexpr (__comparison_category<decltype(__comp_(__x, __y))>)
__do_compare_assert(__y, __x, __r);
return __r;
}
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __x, _Up& __y) {
auto __r = __comp_(__x, __y);
if constexpr (__comparison_category<decltype(__comp_(__x, __y))>)
__do_compare_assert(__y, __x, __r);
return __r;
}
template <class _LHS, class _RHS, class _Order>
_LIBCPP_HIDE_FROM_ABI constexpr void __do_compare_assert(_LHS& __l, _RHS& __r, _Order __o) {
_Order __expected = __o;
if (__o == _Order::less)
__expected = _Order::greater;
if (__o == _Order::greater)
__expected = _Order::less;
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
__comp_(__l, __r) == __expected, "Comparator does not induce a strict weak ordering");
(void)__l;
(void)__r;
}
};
// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference.
# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
template <class _Comp>
using __three_way_comp_ref_type = __debug_three_way_comp<_Comp>;
# else
template <class _Comp>
using __three_way_comp_ref_type = _Comp&;
# endif
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ALGORITHM_THREE_WAY_COMP_REF_TYPE_H

View File

@@ -17,42 +17,4 @@
# pragma GCC system_header
#endif
#if _LIBCPP_STD_VER >= 20
_LIBCPP_PUSH_MACROS
# include <__cxx03/__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
// Range versions of random algorithms (e.g. `std::shuffle`) are less constrained than their classic counterparts.
// Range algorithms only require the given generator to satisfy the `std::uniform_random_bit_generator` concept.
// Classic algorithms require 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 be able to reuse classic implementations, 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 __remove_cvref_t<_Gen>::min(); }
_LIBCPP_HIDE_FROM_ABI static constexpr auto max() { return __remove_cvref_t<_Gen>::max(); }
_LIBCPP_HIDE_FROM_ABI constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen_(__g) {}
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const { return __gen_(); }
};
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
#endif // _LIBCPP_STD_VER >= 20
#endif // _LIBCPP___CXX03___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H

View File

@@ -65,14 +65,6 @@ __unwrap_iter(_Iter __i) _NOEXCEPT {
return _Impl::__unwrap(__i);
}
// Allow input_iterators to be passed to __unwrap_iter (but not __rewrap_iter)
#if _LIBCPP_STD_VER >= 20
template <class _Iter, __enable_if_t<!is_copy_constructible<_Iter>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI constexpr _Iter __unwrap_iter(_Iter __i) noexcept {
return __i;
}
#endif
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));

View File

@@ -29,56 +29,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// __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 >= 20
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(std::move(__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>
_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 >= 20
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)));
@@ -88,7 +38,6 @@ template <class _Iter, class _Unwrapped>
_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 >= 20
_LIBCPP_END_NAMESPACE_STD

View File

@@ -80,31 +80,6 @@ using atomic_ptrdiff_t = atomic<ptrdiff_t>;
using atomic_intmax_t = atomic<intmax_t>;
using atomic_uintmax_t = atomic<uintmax_t>;
// C++20 atomic_{signed,unsigned}_lock_free: prefer the contention type most highly, then the largest lock-free type
#if _LIBCPP_STD_VER >= 20
# if ATOMIC_LLONG_LOCK_FREE == 2
using __largest_lock_free_type = long long;
# elif ATOMIC_INT_LOCK_FREE == 2
using __largest_lock_free_type = int;
# elif ATOMIC_SHORT_LOCK_FREE == 2
using __largest_lock_free_type = short;
# elif ATOMIC_CHAR_LOCK_FREE == 2
using __largest_lock_free_type = char;
# else
# define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen on unusual platforms)
# endif
# ifndef _LIBCPP_NO_LOCK_FREE_TYPES
using __contention_t_or_largest =
__conditional_t<__libcpp_is_always_lock_free<__cxx_contention_t>::__value,
__cxx_contention_t,
__largest_lock_free_type>;
using atomic_signed_lock_free = atomic<__contention_t_or_largest>;
using atomic_unsigned_lock_free = atomic<make_unsigned_t<__contention_t_or_largest>>;
# endif // !_LIBCPP_NO_LOCK_FREE_TYPES
#endif // C++20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ATOMIC_ALIASES_H

View File

@@ -38,11 +38,7 @@ struct atomic : public __atomic_base<_Tp> {
using value_type = _Tp;
using difference_type = value_type;
#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI atomic() = default;
#else
_LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
@@ -121,136 +117,6 @@ struct atomic<_Tp*> : public __atomic_base<_Tp*> {
atomic& operator=(const atomic&) volatile = delete;
};
#if _LIBCPP_STD_VER >= 20
template <class _Tp>
requires is_floating_point_v<_Tp>
struct atomic<_Tp> : __atomic_base<_Tp> {
private:
_LIBCPP_HIDE_FROM_ABI static constexpr bool __is_fp80_long_double() {
// Only x87-fp80 long double has 64-bit mantissa
return __LDBL_MANT_DIG__ == 64 && std::is_same_v<_Tp, long double>;
}
_LIBCPP_HIDE_FROM_ABI static constexpr bool __has_rmw_builtin() {
# ifndef _LIBCPP_COMPILER_CLANG_BASED
return false;
# else
// The builtin __cxx_atomic_fetch_add errors during compilation for
// long double on platforms with fp80 format.
// For more details, see
// lib/Sema/SemaChecking.cpp function IsAllowedValueType
// LLVM Parser does not allow atomicrmw with x86_fp80 type.
// if (ValType->isSpecificBuiltinType(BuiltinType::LongDouble) &&
// &Context.getTargetInfo().getLongDoubleFormat() ==
// &llvm::APFloat::x87DoubleExtended())
// For more info
// https://github.com/llvm/llvm-project/issues/68602
// https://reviews.llvm.org/D53965
return !__is_fp80_long_double();
# endif
}
template <class _This, class _Operation, class _BuiltinOp>
_LIBCPP_HIDE_FROM_ABI static _Tp
__rmw_op(_This&& __self, _Tp __operand, memory_order __m, _Operation __operation, _BuiltinOp __builtin_op) {
if constexpr (__has_rmw_builtin()) {
return __builtin_op(std::addressof(std::forward<_This>(__self).__a_), __operand, __m);
} else {
_Tp __old = __self.load(memory_order_relaxed);
_Tp __new = __operation(__old, __operand);
while (!__self.compare_exchange_weak(__old, __new, __m, memory_order_relaxed)) {
# ifdef _LIBCPP_COMPILER_CLANG_BASED
if constexpr (__is_fp80_long_double()) {
// https://github.com/llvm/llvm-project/issues/47978
// clang bug: __old is not updated on failure for atomic<long double>::compare_exchange_weak
// Note __old = __self.load(memory_order_relaxed) will not work
std::__cxx_atomic_load_inplace(std::addressof(__self.__a_), &__old, memory_order_relaxed);
}
# endif
__new = __operation(__old, __operand);
}
return __old;
}
}
template <class _This>
_LIBCPP_HIDE_FROM_ABI static _Tp __fetch_add(_This&& __self, _Tp __operand, memory_order __m) {
auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) {
return std::__cxx_atomic_fetch_add(__a, __builtin_operand, __order);
};
return __rmw_op(std::forward<_This>(__self), __operand, __m, std::plus<>{}, __builtin_op);
}
template <class _This>
_LIBCPP_HIDE_FROM_ABI static _Tp __fetch_sub(_This&& __self, _Tp __operand, memory_order __m) {
auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) {
return std::__cxx_atomic_fetch_sub(__a, __builtin_operand, __order);
};
return __rmw_op(std::forward<_This>(__self), __operand, __m, std::minus<>{}, __builtin_op);
}
public:
using __base = __atomic_base<_Tp>;
using value_type = _Tp;
using difference_type = value_type;
_LIBCPP_HIDE_FROM_ABI constexpr atomic() noexcept = default;
_LIBCPP_HIDE_FROM_ABI constexpr atomic(_Tp __d) noexcept : __base(__d) {}
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
_LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __d) volatile noexcept
requires __base::is_always_lock_free
{
__base::store(__d);
return __d;
}
_LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __d) noexcept {
__base::store(__d);
return __d;
}
_LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile noexcept
requires __base::is_always_lock_free
{
return __fetch_add(*this, __op, __m);
}
_LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) noexcept {
return __fetch_add(*this, __op, __m);
}
_LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile noexcept
requires __base::is_always_lock_free
{
return __fetch_sub(*this, __op, __m);
}
_LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) noexcept {
return __fetch_sub(*this, __op, __m);
}
_LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) volatile noexcept
requires __base::is_always_lock_free
{
return fetch_add(__op) + __op;
}
_LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) noexcept { return fetch_add(__op) + __op; }
_LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) volatile noexcept
requires __base::is_always_lock_free
{
return fetch_sub(__op) - __op;
}
_LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) noexcept { return fetch_sub(__op) - __op; }
};
#endif // _LIBCPP_STD_VER >= 20
// atomic_is_lock_free
template <class _Tp>

View File

@@ -32,10 +32,6 @@ struct __atomic_base // false
{
mutable __cxx_atomic_impl<_Tp> __a_;
#if _LIBCPP_STD_VER >= 17
static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value;
#endif
_LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT {
return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>));
}
@@ -118,11 +114,7 @@ struct __atomic_base // false
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); }
#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {}
#else
_LIBCPP_HIDE_FROM_ABI __atomic_base() _NOEXCEPT = default;
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}

View File

@@ -68,12 +68,7 @@ struct atomic_flag {
_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT {
std::__atomic_notify_all(*this);
}
#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {}
#else
atomic_flag() _NOEXCEPT = default;
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION

View File

@@ -18,8 +18,4 @@
#define ATOMIC_FLAG_INIT {false}
#define ATOMIC_VAR_INIT(__v) {__v}
#if _LIBCPP_STD_VER >= 20 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# pragma clang deprecated(ATOMIC_VAR_INIT)
#endif
#endif // _LIBCPP___CXX03___ATOMIC_ATOMIC_INIT_H

View File

@@ -44,13 +44,7 @@ _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value,
template <typename _Tp>
struct __cxx_atomic_base_impl {
_LIBCPP_HIDE_FROM_ABI
# ifndef _LIBCPP_CXX03_LANG
__cxx_atomic_base_impl() _NOEXCEPT = default;
# else
__cxx_atomic_base_impl() _NOEXCEPT : __a_value() {
}
# endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}
_LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT : __a_value(value) {}
_Tp __a_value;
};
@@ -263,13 +257,7 @@ __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_o
template <typename _Tp>
struct __cxx_atomic_base_impl {
_LIBCPP_HIDE_FROM_ABI
# ifndef _LIBCPP_CXX03_LANG
__cxx_atomic_base_impl() _NOEXCEPT = default;
# else
__cxx_atomic_base_impl() _NOEXCEPT : __a_value() {
}
# endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}
_LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {}
_LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;
};

View File

@@ -26,29 +26,6 @@ enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_rele
using __memory_order_underlying_t = underlying_type<__legacy_memory_order>::type;
#if _LIBCPP_STD_VER >= 20
enum class memory_order : __memory_order_underlying_t {
relaxed = __mo_relaxed,
consume = __mo_consume,
acquire = __mo_acquire,
release = __mo_release,
acq_rel = __mo_acq_rel,
seq_cst = __mo_seq_cst
};
static_assert(is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value,
"unexpected underlying type for std::memory_order");
inline constexpr auto memory_order_relaxed = memory_order::relaxed;
inline constexpr auto memory_order_consume = memory_order::consume;
inline constexpr auto memory_order_acquire = memory_order::acquire;
inline constexpr auto memory_order_release = memory_order::release;
inline constexpr auto memory_order_acq_rel = memory_order::acq_rel;
inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
#else
enum memory_order {
memory_order_relaxed = __mo_relaxed,
memory_order_consume = __mo_consume,
@@ -58,8 +35,6 @@ enum memory_order {
memory_order_seq_cst = __mo_seq_cst,
};
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ATOMIC_MEMORY_ORDER_H

View File

@@ -91,20 +91,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _
#endif // __has_builtin(__builtin_clzg)
}
#if _LIBCPP_STD_VER >= 20
template <__libcpp_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
return std::__countl_zero(__t);
}
template <__libcpp_unsigned_integer _Tp>
[[nodiscard]] _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;
}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -62,20 +62,6 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __coun
#endif // __has_builtin(__builtin_ctzg)
}
#if _LIBCPP_STD_VER >= 20
template <__libcpp_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
return std::__countr_zero(__t);
}
template <__libcpp_unsigned_integer _Tp>
[[nodiscard]] _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;
}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -37,32 +37,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned lo
return __builtin_popcountll(__x);
}
#if _LIBCPP_STD_VER >= 20
template <__libcpp_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
# if __has_builtin(__builtin_popcountg)
return __builtin_popcountg(__t);
# else // __has_builtin(__builtin_popcountg)
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;
}
# endif // __has_builtin(__builtin_popcountg)
}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -52,20 +52,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s)
return (__x << -__r) | (__x >> (__N + __r));
}
#if _LIBCPP_STD_VER >= 20
template <__libcpp_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept {
return std::__rotl(__t, __cnt);
}
template <__libcpp_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, int __cnt) noexcept {
return std::__rotr(__t, __cnt);
}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___BIT_ROTATE_H

View File

@@ -75,16 +75,6 @@ public:
return *this;
}
#if _LIBCPP_STD_VER >= 23
_LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept {
if (__x)
*__seg_ |= __mask_;
else
*__seg_ &= ~__mask_;
return *this;
}
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT {
return operator=(static_cast<bool>(__x));
}
@@ -801,13 +791,7 @@ private:
unsigned __ctz_;
public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator() _NOEXCEPT
#if _LIBCPP_STD_VER >= 14
: __seg_(nullptr),
__ctz_(0)
#endif
{
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator() _NOEXCEPT {}
// When _IsConst=false, this is the copy constructor.
// It is non-trivial. Making it trivial would break ABI.
@@ -913,7 +897,6 @@ public:
return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;
}
#if _LIBCPP_STD_VER <= 17
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool
operator!=(const __bit_iterator& __x, const __bit_iterator& __y) {
return !(__x == __y);
@@ -938,18 +921,6 @@ public:
operator>=(const __bit_iterator& __x, const __bit_iterator& __y) {
return !(__x < __y);
}
#else // _LIBCPP_STD_VER <= 17
_LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering
operator<=>(const __bit_iterator& __x, const __bit_iterator& __y) {
if (__x.__seg_ < __y.__seg_)
return strong_ordering::less;
if (__x.__seg_ == __y.__seg_)
return __x.__ctz_ <=> __y.__ctz_;
return strong_ordering::greater;
}
#endif // _LIBCPP_STD_VER <= 17
private:
_LIBCPP_HIDE_FROM_ABI

View File

@@ -108,11 +108,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const d
template <class _Rep>
struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
#if _LIBCPP_STD_VER >= 17
template <class _Rep>
inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;
#endif
template <class _Rep>
struct _LIBCPP_TEMPLATE_VIS duration_values {
public:
@@ -121,37 +116,6 @@ public:
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT { return numeric_limits<_Rep>::lowest(); }
};
#if _LIBCPP_STD_VER >= 17
template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<_Rep, _Period>& __d) {
_ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
if (__t > __d)
__t = __t - _ToDuration{1};
return __t;
}
template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_Rep, _Period>& __d) {
_ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
if (__t < __d)
__t = __t + _ToDuration{1};
return __t;
}
template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<_Rep, _Period>& __d) {
_ToDuration __lower = chrono::floor<_ToDuration>(__d);
_ToDuration __upper = __lower + _ToDuration{1};
auto __lower_diff = __d - __lower;
auto __upper_diff = __upper - __d;
if (__lower_diff < __upper_diff)
return __lower;
if (__lower_diff > __upper_diff)
return __upper;
return __lower.count() & 1 ? __upper : __lower;
}
#endif
// duration
template <class _Rep, class _Period>
@@ -195,11 +159,7 @@ private:
rep __rep_;
public:
#ifndef _LIBCPP_CXX03_LANG
constexpr duration() = default;
#else
_LIBCPP_HIDE_FROM_ABI duration() {}
#endif
template <class _Rep2,
__enable_if_t<is_convertible<const _Rep2&, rep>::value &&
@@ -285,12 +245,7 @@ typedef duration<long long, milli> milliseconds;
typedef duration<long long > seconds;
typedef duration< long, ratio< 60> > minutes;
typedef duration< long, ratio<3600> > hours;
#if _LIBCPP_STD_VER >= 20
typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days;
typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks;
typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years;
typedef duration< int, ratio_divide<years::period, ratio<12>>> months;
#endif
// Duration ==
template <class _LhsDuration, class _RhsDuration>
@@ -314,8 +269,6 @@ operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period
return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
}
#if _LIBCPP_STD_VER <= 17
// Duration !=
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
@@ -324,8 +277,6 @@ operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period
return !(__lhs == __rhs);
}
#endif // _LIBCPP_STD_VER <= 17
// Duration <
template <class _LhsDuration, class _RhsDuration>
@@ -373,18 +324,6 @@ operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period
return !(__lhs < __rhs);
}
#if _LIBCPP_STD_VER >= 20
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
requires three_way_comparable<common_type_t<_Rep1, _Rep2>>
_LIBCPP_HIDE_FROM_ABI constexpr auto
operator<=>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
using _Ct = common_type_t<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>;
return _Ct(__lhs).count() <=> _Ct(__rhs).count();
}
#endif // _LIBCPP_STD_VER >= 20
// Duration +
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
@@ -475,73 +414,11 @@ operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2
} // namespace chrono
#if _LIBCPP_STD_VER >= 14
// Suffixes for duration literals [time.duration.literals]
inline namespace literals {
inline namespace chrono_literals {
_LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h) {
return chrono::hours(static_cast<chrono::hours::rep>(__h));
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<3600, 1>> operator""h(long double __h) {
return chrono::duration<long double, ratio<3600, 1>>(__h);
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes operator""min(unsigned long long __m) {
return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<60, 1>> operator""min(long double __m) {
return chrono::duration<long double, ratio<60, 1>>(__m);
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds operator""s(unsigned long long __s) {
return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double> operator""s(long double __s) {
return chrono::duration<long double>(__s);
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::milliseconds operator""ms(unsigned long long __ms) {
return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, milli> operator""ms(long double __ms) {
return chrono::duration<long double, milli>(__ms);
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::microseconds operator""us(unsigned long long __us) {
return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, micro> operator""us(long double __us) {
return chrono::duration<long double, micro>(__us);
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) {
return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
}
_LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns) {
return chrono::duration<long double, nano>(__ns);
}
} // namespace chrono_literals
} // namespace literals
namespace chrono { // hoist the literals into namespace std::chrono
using namespace literals::chrono_literals;
} // namespace chrono
#endif // _LIBCPP_STD_VER >= 14
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
# include <__cxx03/type_traits>
#endif

View File

@@ -36,15 +36,6 @@ public:
static time_point from_time_t(time_t __t) _NOEXCEPT;
};
#if _LIBCPP_STD_VER >= 20
template <class _Duration>
using sys_time = time_point<system_clock, _Duration>;
using sys_seconds = sys_time<seconds>;
using sys_days = sys_time<days>;
#endif
} // namespace chrono
_LIBCPP_END_NAMESPACE_STD

View File

@@ -88,28 +88,6 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) {
return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
}
#if _LIBCPP_STD_VER >= 17
template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) {
return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())};
}
template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) {
return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())};
}
template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) {
return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())};
}
template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) {
return __d >= __d.zero() ? +__d : -__d;
}
#endif // _LIBCPP_STD_VER >= 17
// time_point ==
template <class _Clock, class _Duration1, class _Duration2>
@@ -118,8 +96,6 @@ operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
return __lhs.time_since_epoch() == __rhs.time_since_epoch();
}
#if _LIBCPP_STD_VER <= 17
// time_point !=
template <class _Clock, class _Duration1, class _Duration2>
@@ -128,8 +104,6 @@ operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
return !(__lhs == __rhs);
}
#endif // _LIBCPP_STD_VER <= 17
// time_point <
template <class _Clock, class _Duration1, class _Duration2>
@@ -162,16 +136,6 @@ operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
return !(__lhs < __rhs);
}
#if _LIBCPP_STD_VER >= 20
template <class _Clock, class _Duration1, three_way_comparable_with<_Duration1> _Duration2>
_LIBCPP_HIDE_FROM_ABI constexpr auto
operator<=>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
return __lhs.time_since_epoch() <=> __rhs.time_since_epoch();
}
#endif // _LIBCPP_STD_VER >= 20
// time_point operator+(time_point x, duration y);
template <class _Clock, class _Duration1, class _Rep2, class _Period2>

View File

@@ -157,11 +157,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
# define _LIBCPP_TOSTRING2(x) #x
# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
// NOLINTNEXTLINE(libcpp-cpp-version-check)
# if __cplusplus < 201103L
# define _LIBCPP_CXX03_LANG
# endif
# ifndef __has_constexpr_builtin
# define __has_constexpr_builtin(x) 0
# endif
@@ -307,18 +302,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
# define _LIBCPP_USING_DEV_RANDOM
# endif
# ifndef _LIBCPP_CXX03_LANG
# 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_(...) noexcept(__VA_ARGS__)
# define _LIBCPP_CONSTEXPR constexpr
# else
# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
# define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -334,8 +317,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
typedef __char16_t char16_t;
typedef __char32_t char32_t;
# endif
# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
// Objective-C++ features (opt-in)
@@ -613,7 +594,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_HAS_NO_INT128
# endif
# ifdef _LIBCPP_CXX03_LANG
# define _LIBCPP_DECLARE_STRONG_ENUM(x) \
struct _LIBCPP_EXPORTED_FROM_ABI x { \
enum __lx
@@ -626,11 +606,6 @@ typedef __char32_t char32_t;
};
// clang-format on
# else // _LIBCPP_CXX03_LANG
# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class x
# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
# endif // _LIBCPP_CXX03_LANG
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
# define _LIBCPP_LOCALE__L_EXTENSIONS 1
# endif
@@ -675,73 +650,29 @@ typedef __char32_t char32_t;
# define _LIBCPP_WCTYPE_IS_MASK
# endif
# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
# define _LIBCPP_HAS_NO_CHAR8_T
# endif
# define _LIBCPP_HAS_NO_CHAR8_T
// 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__))
# define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
# elif _LIBCPP_STD_VER >= 14
# define _LIBCPP_DEPRECATED [[deprecated]]
# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
# else
# define _LIBCPP_DEPRECATED
# define _LIBCPP_DEPRECATED_(m)
# endif
# define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
# define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
# else
# define _LIBCPP_DEPRECATED
# define _LIBCPP_DEPRECATED_(m)
# endif
# if _LIBCPP_STD_VER < 20
# define _LIBCPP_DEPRECATED_ATOMIC_SYNC \
_LIBCPP_DEPRECATED_("The C++20 synchronization library has been deprecated prior to C++20. Please update to " \
"using -std=c++20 if you need to use these facilities.")
# else
# define _LIBCPP_DEPRECATED_ATOMIC_SYNC /* nothing */
# endif
# define _LIBCPP_DEPRECATED_ATOMIC_SYNC /* nothing */
# if !defined(_LIBCPP_CXX03_LANG)
# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
# else
# define _LIBCPP_DEPRECATED_IN_CXX11
# endif
# define _LIBCPP_DEPRECATED_IN_CXX11
# if _LIBCPP_STD_VER >= 14
# 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 >= 20
# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
# else
# define _LIBCPP_DEPRECATED_IN_CXX20
# endif
# if _LIBCPP_STD_VER >= 23
# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
# else
# define _LIBCPP_DEPRECATED_IN_CXX23
# endif
# if _LIBCPP_STD_VER >= 26
# define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
# else
# define _LIBCPP_DEPRECATED_IN_CXX26
# endif
# define _LIBCPP_DEPRECATED_IN_CXX14
# define _LIBCPP_DEPRECATED_IN_CXX17
# define _LIBCPP_DEPRECATED_IN_CXX20
# define _LIBCPP_DEPRECATED_IN_CXX23
# define _LIBCPP_DEPRECATED_IN_CXX26
# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
@@ -760,41 +691,12 @@ typedef __char32_t char32_t;
# define _LIBCPP_SUPPRESS_DEPRECATED_POP
# endif
# if _LIBCPP_STD_VER <= 11
# define _LIBCPP_EXPLICIT_SINCE_CXX14
# else
# define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit
# endif
# if _LIBCPP_STD_VER >= 23
# define _LIBCPP_EXPLICIT_SINCE_CXX23 explicit
# else
# define _LIBCPP_EXPLICIT_SINCE_CXX23
# endif
# if _LIBCPP_STD_VER >= 14
# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
# else
# define _LIBCPP_CONSTEXPR_SINCE_CXX14
# endif
# if _LIBCPP_STD_VER >= 17
# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
# else
# define _LIBCPP_CONSTEXPR_SINCE_CXX17
# endif
# if _LIBCPP_STD_VER >= 20
# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
# else
# define _LIBCPP_CONSTEXPR_SINCE_CXX20
# endif
# if _LIBCPP_STD_VER >= 23
# define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
# else
# define _LIBCPP_CONSTEXPR_SINCE_CXX23
# endif
# define _LIBCPP_EXPLICIT_SINCE_CXX14
# define _LIBCPP_EXPLICIT_SINCE_CXX23
# define _LIBCPP_CONSTEXPR_SINCE_CXX14
# define _LIBCPP_CONSTEXPR_SINCE_CXX17
# define _LIBCPP_CONSTEXPR_SINCE_CXX20
# define _LIBCPP_CONSTEXPR_SINCE_CXX23
# ifndef _LIBCPP_WEAK
# define _LIBCPP_WEAK __attribute__((__weak__))
@@ -933,9 +835,7 @@ typedef __char32_t char32_t;
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
# endif
# if _LIBCPP_STD_VER >= 20
# define _LIBCPP_CONSTINIT constinit
# elif __has_attribute(__require_constant_initialization__)
# if __has_attribute(__require_constant_initialization__)
# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
# else
# define _LIBCPP_CONSTINIT
@@ -1037,19 +937,7 @@ typedef __char32_t char32_t;
// macro is used to mark them as such, which suppresses the
// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
// with these classes.
# if _LIBCPP_STD_VER >= 17
# ifdef _LIBCPP_COMPILER_CLANG_BASED
# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
template <class... _Tag> \
[[maybe_unused]] _ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...>
# else
# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(ClassName) \
template <class... _Tag> \
ClassName(typename _Tag::__allow_ctad...)->ClassName<_Tag...>
# endif
# else
# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
# endif
# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
// TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use
// compiler intrinsics in the Objective-C++ mode.

View File

@@ -16,25 +16,6 @@
# pragma GCC system_header
#endif
// NOLINTBEGIN(libcpp-cpp-version-check)
#ifdef __cplusplus
# 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
# elif __cplusplus <= 202302L
# define _LIBCPP_STD_VER 23
# else
// Expected release year of the next C++ standard
# define _LIBCPP_STD_VER 26
# endif
#endif // __cplusplus
// NOLINTEND(libcpp-cpp-version-check)
#if !defined(__cpp_rtti) || __cpp_rtti < 199711L
# define _LIBCPP_HAS_NO_RTTI
#endif

View File

@@ -25,9 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Iterator, class _Sentinel>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 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
# error Support for unspecified stability is only for C++11 and higher
if (!__libcpp_is_constant_evaluated())
std::__shuffle<_AlgPolicy>(__first, __last, __libcpp_debug_randomizer());

View File

@@ -17,13 +17,10 @@
#endif
namespace std { // purposefully not using versioning namespace
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) || \
defined(_LIBCPP_BUILDING_LIBRARY)
using unexpected_handler = void (*)();
_LIBCPP_EXPORTED_FROM_ABI unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT;
_LIBCPP_EXPORTED_FROM_ABI unexpected_handler get_unexpected() _NOEXCEPT;
_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void unexpected();
#endif
using terminate_handler = void (*)();
_LIBCPP_EXPORTED_FROM_ABI terminate_handler set_terminate(terminate_handler) _NOEXCEPT;

View File

@@ -18,8 +18,6 @@
_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 _LIBCPP_DEPRECATED_IN_CXX11 binary_function {
typedef _Arg1 first_argument_type;
@@ -27,27 +25,18 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function {
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

View File

@@ -19,8 +19,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
template <class _Predicate>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
: public __binary_function<typename _Predicate::first_argument_type,
@@ -44,8 +42,6 @@ not2(const _Predicate& __pred) {
return binary_negate<_Predicate>(__pred);
}
#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_BINARY_NEGATE_H

View File

@@ -30,22 +30,12 @@ template <class _Tp>
struct is_bind_expression
: _If< _IsSame<_Tp, __remove_cvref_t<_Tp> >::value, false_type, is_bind_expression<__remove_cvref_t<_Tp> > > {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
inline constexpr bool is_bind_expression_v = is_bind_expression<_Tp>::value;
#endif
template <class _Tp>
struct is_placeholder
: _If< _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
integral_constant<int, 0>,
is_placeholder<__remove_cvref_t<_Tp> > > {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
inline constexpr int is_placeholder_v = is_placeholder<_Tp>::value;
#endif
namespace placeholders {
template <int _Np>
@@ -75,222 +65,6 @@ _LIBCPP_EXPORTED_FROM_ABI extern const __ph<10> _10;
template <int _Np>
struct is_placeholder<placeholders::__ph<_Np> > : public integral_constant<int, _Np> {};
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Uj>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_wrapper<_Tp> __t, _Uj&) {
return __t.get();
}
template <class _Ti, class... _Uj, size_t... _Indx>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type
__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) {
return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...);
}
template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type
__mu(_Ti& __ti, tuple<_Uj...>& __uj) {
typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
return std::__mu_expand(__ti, __uj, __indices());
}
template <bool _IsPh, class _Ti, class _Uj>
struct __mu_return2 {};
template <class _Ti, class _Uj>
struct __mu_return2<true, _Ti, _Uj> {
typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
};
template <class _Ti, class _Uj, __enable_if_t<0 < is_placeholder<_Ti>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
__mu(_Ti&, _Uj& __uj) {
const size_t __indx = is_placeholder<_Ti>::value - 1;
return std::forward<typename tuple_element<__indx, _Uj>::type>(std::get<__indx>(__uj));
}
template <class _Ti,
class _Uj,
__enable_if_t<!is_bind_expression<_Ti>::value && is_placeholder<_Ti>::value == 0 &&
!__is_reference_wrapper<_Ti>::value,
int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ti& __mu(_Ti& __ti, _Uj&) {
return __ti;
}
template <class _Ti, bool _IsReferenceWrapper, bool _IsBindEx, bool _IsPh, class _TupleUj>
struct __mu_return_impl;
template <bool _Invokable, class _Ti, class... _Uj>
struct __mu_return_invokable // false
{
typedef __nat type;
};
template <class _Ti, class... _Uj>
struct __mu_return_invokable<true, _Ti, _Uj...> {
typedef typename __invoke_of<_Ti&, _Uj...>::type type;
};
template <class _Ti, class... _Uj>
struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
: public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> {};
template <class _Ti, class _TupleUj>
struct __mu_return_impl<_Ti, false, false, true, _TupleUj> {
typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _TupleUj>::type&& type;
};
template <class _Ti, class _TupleUj>
struct __mu_return_impl<_Ti, true, false, false, _TupleUj> {
typedef typename _Ti::type& type;
};
template <class _Ti, class _TupleUj>
struct __mu_return_impl<_Ti, false, false, false, _TupleUj> {
typedef _Ti& type;
};
template <class _Ti, class _TupleUj>
struct __mu_return
: public __mu_return_impl<
_Ti,
__is_reference_wrapper<_Ti>::value,
is_bind_expression<_Ti>::value,
0 < is_placeholder<_Ti>::value && is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
_TupleUj> {};
template <class _Fp, class _BoundArgs, class _TupleUj>
struct __is_valid_bind_return {
static const bool value = false;
};
template <class _Fp, class... _BoundArgs, class _TupleUj>
struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> {
static const bool value = __invokable<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
};
template <class _Fp, class... _BoundArgs, class _TupleUj>
struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> {
static const bool value = __invokable<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
};
template <class _Fp, class _BoundArgs, class _TupleUj, bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
struct __bind_return;
template <class _Fp, class... _BoundArgs, class _TupleUj>
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {
typedef typename __invoke_of< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >::type type;
};
template <class _Fp, class... _BoundArgs, class _TupleUj>
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {
typedef typename __invoke_of< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >::type type;
};
template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fp, _BoundArgs, _Args>::type
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _Args&& __args) {
return std::__invoke(__f, std::__mu(std::get<_Indx>(__bound_args), __args)...);
}
template <class _Fp, class... _BoundArgs>
class __bind : public __weak_result_type<__decay_t<_Fp> > {
protected:
using _Fd = __decay_t<_Fp>;
typedef tuple<__decay_t<_BoundArgs>...> _Td;
private:
_Fd __f_;
_Td __bound_args_;
typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
public:
template <
class _Gp,
class... _BA,
__enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bind(_Gp&& __f, _BA&&... __bound_args)
: __f_(std::forward<_Gp>(__f)), __bound_args_(std::forward<_BA>(__bound_args)...) {}
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
operator()(_Args&&... __args) {
return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
}
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
operator()(_Args&&... __args) const {
return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
}
};
template <class _Fp, class... _BoundArgs>
struct is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
template <class _Rp, class _Fp, class... _BoundArgs>
class __bind_r : public __bind<_Fp, _BoundArgs...> {
typedef __bind<_Fp, _BoundArgs...> base;
typedef typename base::_Fd _Fd;
typedef typename base::_Td _Td;
public:
typedef _Rp result_type;
template <
class _Gp,
class... _BA,
__enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind_r>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bind_r(_Gp&& __f, _BA&&... __bound_args)
: base(std::forward<_Gp>(__f), std::forward<_BA>(__bound_args)...) {}
template <
class... _Args,
__enable_if_t<is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, result_type>::value ||
is_void<_Rp>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) {
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
return _Invoker::__call(static_cast<base&>(*this), std::forward<_Args>(__args)...);
}
template <class... _Args,
__enable_if_t<is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
result_type>::value ||
is_void<_Rp>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) const {
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
return _Invoker::__call(static_cast<base const&>(*this), std::forward<_Args>(__args)...);
}
};
template <class _Rp, class _Fp, class... _BoundArgs>
struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
template <class _Fp, class... _BoundArgs>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind<_Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args) {
typedef __bind<_Fp, _BoundArgs...> type;
return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...);
}
template <class _Rp, class _Fp, class... _BoundArgs>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind_r<_Rp, _Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args) {
typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...);
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_BIND_H

View File

@@ -19,8 +19,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
template <class _Operation>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st
: public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> {
@@ -47,8 +45,6 @@ bind1st(const _Operation& __op, const _Tp& __x) {
return binder1st<_Operation>(__op, __x);
}
#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_BINDER1ST_H

View File

@@ -19,8 +19,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
template <class _Operation>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
: public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> {
@@ -47,8 +45,6 @@ bind2nd(const _Operation& __op, const _Tp& __x) {
return binder2nd<_Operation>(__op, __x);
}
#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_BINDER2ND_H

View File

@@ -504,39 +504,6 @@ struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> {
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> {};
#if _LIBCPP_STD_VER >= 17
template <>
struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t> : public __unary_function<nullptr_t, size_t> {
_LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; }
};
#endif
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Hash>
using __check_hash_requirements _LIBCPP_NODEBUG =
integral_constant<bool,
is_copy_constructible<_Hash>::value && is_move_constructible<_Hash>::value &&
__invokable_r<size_t, _Hash, _Key const&>::value >;
template <class _Key, class _Hash = hash<_Key> >
using __has_enabled_hash _LIBCPP_NODEBUG =
integral_constant<bool, __check_hash_requirements<_Key, _Hash>::value && is_default_constructible<_Hash>::value >;
# if _LIBCPP_STD_VER >= 17
template <class _Type, class>
using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type;
template <class _Type, class... _Keys>
using __enable_hash_helper _LIBCPP_NODEBUG =
__enable_hash_helper_imp<_Type, __enable_if_t<__all<__has_enabled_hash<_Keys>::value...>::value> >;
# else
template <class _Type, class...>
using __enable_hash_helper _LIBCPP_NODEBUG = _Type;
# endif
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_HASH_H

View File

@@ -40,26 +40,6 @@ struct __is_identity<reference_wrapper<__identity> > : true_type {};
template <>
struct __is_identity<reference_wrapper<const __identity> > : true_type {};
#if _LIBCPP_STD_VER >= 20
struct identity {
template <class _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept {
return std::forward<_Tp>(__t);
}
using is_transparent = void;
};
template <>
struct __is_identity<identity> : true_type {};
template <>
struct __is_identity<reference_wrapper<identity> > : true_type {};
template <>
struct __is_identity<reference_wrapper<const identity> > : true_type {};
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_IDENTITY_H

View File

@@ -20,8 +20,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
template <class _Sp, class _Tp>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t : public __unary_function<_Tp*, _Sp> {
_Sp (_Tp::*__p_)();
@@ -139,8 +137,6 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) {
return const_mem_fun1_ref_t<_Sp, _Tp, _Ap>(__f);
}
#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_MEM_FUN_REF_H

View File

@@ -24,11 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// Arithmetic operations
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS plus : __binary_function<_Tp, _Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
@@ -45,24 +41,7 @@ inline const bool __desugars_to_v<__plus_tag, plus<_Tp>, _Tp, _Tp> = true;
template <class _Tp, class _Up>
inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true;
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS plus<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) + std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) + std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS minus : __binary_function<_Tp, _Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
@@ -71,24 +50,7 @@ struct _LIBCPP_TEMPLATE_VIS minus : __binary_function<_Tp, _Tp, _Tp> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS minus<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) - std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) - std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS multiplies : __binary_function<_Tp, _Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
@@ -97,24 +59,7 @@ struct _LIBCPP_TEMPLATE_VIS multiplies : __binary_function<_Tp, _Tp, _Tp> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS multiplies<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) * std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) * std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS divides : __binary_function<_Tp, _Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
@@ -123,24 +68,7 @@ struct _LIBCPP_TEMPLATE_VIS divides : __binary_function<_Tp, _Tp, _Tp> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS divides<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) / std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) / std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS modulus : __binary_function<_Tp, _Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
@@ -149,50 +77,16 @@ struct _LIBCPP_TEMPLATE_VIS modulus : __binary_function<_Tp, _Tp, _Tp> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS modulus<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) % std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) % std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS negate : __unary_function<_Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return -__x; }
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS negate<void> {
template <class _Tp>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
noexcept(noexcept(-std::forward<_Tp>(__x))) //
-> decltype(-std::forward<_Tp>(__x)) {
return -std::forward<_Tp>(__x);
}
typedef void is_transparent;
};
#endif
// Bitwise operations
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS bit_and : __binary_function<_Tp, _Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
@@ -201,43 +95,7 @@ struct _LIBCPP_TEMPLATE_VIS bit_and : __binary_function<_Tp, _Tp, _Tp> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS bit_and<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) &
std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) & std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) & std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
struct _LIBCPP_TEMPLATE_VIS bit_not : __unary_function<_Tp, _Tp> {
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
template <>
struct _LIBCPP_TEMPLATE_VIS bit_not<void> {
template <class _Tp>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
noexcept(noexcept(~std::forward<_Tp>(__x))) //
-> decltype(~std::forward<_Tp>(__x)) {
return ~std::forward<_Tp>(__x);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS bit_or : __binary_function<_Tp, _Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
@@ -246,24 +104,7 @@ struct _LIBCPP_TEMPLATE_VIS bit_or : __binary_function<_Tp, _Tp, _Tp> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS bit_or<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) | std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) | std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS bit_xor : __binary_function<_Tp, _Tp, _Tp> {
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
@@ -272,26 +113,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor : __binary_function<_Tp, _Tp, _Tp> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS bit_xor<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) ^ std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) ^ std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
// Comparison operations
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS equal_to : __binary_function<_Tp, _Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
@@ -300,19 +124,6 @@ struct _LIBCPP_TEMPLATE_VIS equal_to : __binary_function<_Tp, _Tp, bool> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS equal_to<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) == std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) == std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
// The non-transparent std::equal_to specialization is only equivalent to a raw equality
// comparison when we don't perform an implicit conversion when calling it.
template <class _Tp>
@@ -322,11 +133,7 @@ inline const bool __desugars_to_v<__equal_tag, equal_to<_Tp>, _Tp, _Tp> = true;
template <class _Tp, class _Up>
inline const bool __desugars_to_v<__equal_tag, equal_to<void>, _Tp, _Up> = true;
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS not_equal_to : __binary_function<_Tp, _Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
@@ -335,24 +142,7 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to : __binary_function<_Tp, _Tp, bool> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) != std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) != std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
@@ -364,27 +154,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
template <class _Tp>
inline const bool __desugars_to_v<__less_tag, less<_Tp>, _Tp, _Tp> = true;
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS less<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) < std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) < std::forward<_T2>(__u);
}
typedef void is_transparent;
};
template <class _Tp>
inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Tp> = true;
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS less_equal : __binary_function<_Tp, _Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
@@ -393,24 +163,7 @@ struct _LIBCPP_TEMPLATE_VIS less_equal : __binary_function<_Tp, _Tp, bool> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS less_equal<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) <= std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) <= std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS greater_equal : __binary_function<_Tp, _Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
@@ -419,24 +172,7 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal : __binary_function<_Tp, _Tp, bool> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS greater_equal<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) >=
std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) >= std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) >= std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS greater : __binary_function<_Tp, _Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
@@ -445,26 +181,9 @@ struct _LIBCPP_TEMPLATE_VIS greater : __binary_function<_Tp, _Tp, bool> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS greater<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) > std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) > std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
// Logical operations
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_and : __binary_function<_Tp, _Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
@@ -473,48 +192,14 @@ struct _LIBCPP_TEMPLATE_VIS logical_and : __binary_function<_Tp, _Tp, bool> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS logical_and<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) && std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) && std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_not : __unary_function<_Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x) const { return !__x; }
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS logical_not<void> {
template <class _Tp>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
noexcept(noexcept(!std::forward<_Tp>(__x))) //
-> decltype(!std::forward<_Tp>(__x)) {
return !std::forward<_Tp>(__x);
}
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_or : __binary_function<_Tp, _Tp, bool> {
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
@@ -523,19 +208,6 @@ struct _LIBCPP_TEMPLATE_VIS logical_or : __binary_function<_Tp, _Tp, bool> {
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS logical_or<void> {
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) //
-> decltype(std::forward<_T1>(__t) || std::forward<_T2>(__u)) {
return std::forward<_T1>(__t) || std::forward<_T2>(__u);
}
typedef void is_transparent;
};
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_OPERATIONS_H

View File

@@ -19,8 +19,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
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> {
@@ -37,8 +35,6 @@ ptr_fun(_Result (*__f)(_Arg1, _Arg2)) {
return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__f);
}
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H

View File

@@ -19,8 +19,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
template <class _Arg, class _Result>
class _LIBCPP_TEMPLATE_VIS
_LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> {
@@ -37,8 +35,6 @@ ptr_fun(_Result (*__f)(_Arg)) {
return pointer_to_unary_function<_Arg, _Result>(__f);
}
#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H

View File

@@ -56,70 +56,11 @@ public:
// invoke
template <class... _ArgTypes>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<type&, _ArgTypes...>::type
operator()(_ArgTypes&&... __args) const
#if _LIBCPP_STD_VER >= 17
// Since is_nothrow_invocable requires C++17 LWG3764 is not backported
// to earlier versions.
noexcept(is_nothrow_invocable_v<_Tp&, _ArgTypes...>)
#endif
{
operator()(_ArgTypes&&... __args) const {
return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
}
#if _LIBCPP_STD_VER >= 26
// [refwrap.comparisons], comparisons
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y)
requires requires {
{ __x.get() == __y.get() } -> __boolean_testable;
}
{
return __x.get() == __y.get();
}
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y)
requires requires {
{ __x.get() == __y } -> __boolean_testable;
}
{
return __x.get() == __y;
}
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y)
requires(!is_const_v<_Tp>) && requires {
{ __x.get() == __y.get() } -> __boolean_testable;
}
{
return __x.get() == __y.get();
}
_LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper __y)
requires requires { std::__synth_three_way(__x.get(), __y.get()); }
{
return std::__synth_three_way(__x.get(), __y.get());
}
_LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, const _Tp& __y)
requires requires { std::__synth_three_way(__x.get(), __y); }
{
return std::__synth_three_way(__x.get(), __y);
}
_LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper<const _Tp> __y)
requires(!is_const_v<_Tp>) && requires { std::__synth_three_way(__x.get(), __y.get()); }
{
return std::__synth_three_way(__x.get(), __y.get());
}
#endif // _LIBCPP_STD_VER >= 26
};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
#endif
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<_Tp> ref(_Tp& __t) _NOEXCEPT {
return reference_wrapper<_Tp>(__t);

View File

@@ -17,34 +17,23 @@
_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 _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

View File

@@ -19,8 +19,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
template <class _Predicate>
class _LIBCPP_TEMPLATE_VIS
_LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public __unary_function<typename _Predicate::argument_type, bool> {
@@ -41,8 +39,6 @@ not1(const _Predicate& __pred) {
return unary_negate<_Predicate>(__pred);
}
#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_UNARY_NEGATE_H

View File

@@ -88,9 +88,7 @@ template <class _Tp, bool = __has_result_type<_Tp>::value>
struct __weak_result_type_imp // bool is true
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp> {
#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>
@@ -104,23 +102,17 @@ struct __weak_result_type : public __weak_result_type_imp<_Tp> {};
template <class _Rp>
struct __weak_result_type<_Rp()> {
#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 (&)()> {
#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 (*)()> {
#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
@@ -174,51 +166,37 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> : public __binary_fu
template <class _Rp, class _A1, class _A2, class _A3, class... _A4>
struct __weak_result_type<_Rp(_A1, _A2, _A3, _A4...)> {
#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...)> {
#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...)> {
#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...)> {
#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> {
#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> {
#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> {
#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>

View File

@@ -27,14 +27,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&)
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>&) _NOEXCEPT;
#ifndef _LIBCPP_CXX03_LANG
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT;
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT;
#endif
template <class>
struct __is_std_array : false_type {};

View File

@@ -21,22 +21,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS complex;
#if _LIBCPP_STD_VER >= 26
template <size_t _Ip, class _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(complex<_Tp>&) noexcept;
template <size_t _Ip, class _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(complex<_Tp>&&) noexcept;
template <size_t _Ip, class _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const complex<_Tp>&) noexcept;
template <size_t _Ip, class _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const complex<_Tp>&&) noexcept;
#endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FWD_COMPLEX_H

View File

@@ -30,16 +30,6 @@ template <size_t _Ip, class _T1, class _T2>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>&) _NOEXCEPT;
#ifndef _LIBCPP_CXX03_LANG
template <size_t _Ip, class _T1, class _T2>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(pair<_T1, _T2>&&) _NOEXCEPT;
template <size_t _Ip, class _T1, class _T2>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(const pair<_T1, _T2>&&) _NOEXCEPT;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FWD_PAIR_H

View File

@@ -54,28 +54,6 @@ using u8string = basic_string<char8_t>;
using u16string = basic_string<char16_t>;
using u32string = basic_string<char32_t>;
#if _LIBCPP_STD_VER >= 17
namespace pmr {
template <class _CharT, class _Traits = char_traits<_CharT>>
using basic_string _LIBCPP_AVAILABILITY_PMR = std::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
using string _LIBCPP_AVAILABILITY_PMR = basic_string<char>;
# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
using wstring _LIBCPP_AVAILABILITY_PMR = basic_string<wchar_t>;
# endif
# ifndef _LIBCPP_HAS_NO_CHAR8_T
using u8string _LIBCPP_AVAILABILITY_PMR = basic_string<char8_t>;
# endif
using u16string _LIBCPP_AVAILABILITY_PMR = basic_string<char16_t>;
using u32string _LIBCPP_AVAILABILITY_PMR = basic_string<char32_t>;
} // namespace pmr
#endif // _LIBCPP_STD_VER >= 17
// clang-format off
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_PREFERRED_NAME(string)
@@ -87,17 +65,6 @@ class _LIBCPP_PREFERRED_NAME(string)
#endif
_LIBCPP_PREFERRED_NAME(u16string)
_LIBCPP_PREFERRED_NAME(u32string)
#if _LIBCPP_STD_VER >= 17
_LIBCPP_PREFERRED_NAME(pmr::string)
# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
_LIBCPP_PREFERRED_NAME(pmr::wstring)
# endif
# ifndef _LIBCPP_HAS_NO_CHAR8_T
_LIBCPP_PREFERRED_NAME(pmr::u8string)
# endif
_LIBCPP_PREFERRED_NAME(pmr::u16string)
_LIBCPP_PREFERRED_NAME(pmr::u32string)
#endif
basic_string;
// clang-format on

View File

@@ -21,32 +21,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <size_t, class>
struct _LIBCPP_TEMPLATE_VIS tuple_element;
#ifndef _LIBCPP_CXX03_LANG
template <class...>
class _LIBCPP_TEMPLATE_VIS tuple;
template <class>
struct _LIBCPP_TEMPLATE_VIS tuple_size;
template <size_t _Ip, class... _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(tuple<_Tp...>&) _NOEXCEPT;
template <size_t _Ip, class... _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(const tuple<_Tp...>&) _NOEXCEPT;
template <size_t _Ip, class... _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(tuple<_Tp...>&&) _NOEXCEPT;
template <size_t _Ip, class... _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(const tuple<_Tp...>&&) _NOEXCEPT;
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FWD_TUPLE_H

View File

@@ -108,23 +108,12 @@ struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __has
// We allow starting the lifetime of nodes without initializing the value held by the node,
// since that is handled by the hash table itself in order to be allocator-aware.
#ifndef _LIBCPP_CXX03_LANG
private:
union {
_Tp __value_;
};
public:
_LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
#else
private:
_ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)];
public:
_LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }
#endif
_LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash) : _Base(__next), __hash_(__hash) {}
_LIBCPP_HIDE_FROM_ABI ~__hash_node() {}
@@ -618,35 +607,14 @@ public:
friend class __hash_map_node_destructor;
};
#if _LIBCPP_STD_VER >= 17
template <class _NodeType, class _Alloc>
struct __generic_container_node_destructor;
template <class _Tp, class _VoidPtr, class _Alloc>
struct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc> : __hash_node_destructor<_Alloc> {
using __hash_node_destructor<_Alloc>::__hash_node_destructor;
};
#endif
template <class _Key, class _Hash, class _Equal>
struct __enforce_unordered_container_requirements {
#ifndef _LIBCPP_CXX03_LANG
static_assert(__check_hash_requirements<_Key, _Hash>::value,
"the specified hash does not meet the Hash requirements");
static_assert(is_copy_constructible<_Equal>::value, "the specified comparator is required to be copy constructible");
#endif
typedef int type;
};
template <class _Key, class _Hash, class _Equal>
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,
"the specified comparator type does not provide a viable const call operator")
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
"the specified hash functor does not provide a viable const call operator")
#endif
typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type
__diagnose_unordered_container_requirements(int);
typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type
__diagnose_unordered_container_requirements(int);
// This dummy overload is used so that the compiler won't emit a spurious
// "no matching function for call to __diagnose_unordered_xxx" diagnostic
@@ -848,27 +816,6 @@ public:
return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
}
#if _LIBCPP_STD_VER >= 17
template <class _NodeHandle, class _InsertReturnType>
_LIBCPP_HIDE_FROM_ABI _InsertReturnType __node_handle_insert_unique(_NodeHandle&& __nh);
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_unique(const_iterator __hint, _NodeHandle&& __nh);
template <class _Table>
_LIBCPP_HIDE_FROM_ABI void __node_handle_merge_unique(_Table& __source);
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(_NodeHandle&& __nh);
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh);
template <class _Table>
_LIBCPP_HIDE_FROM_ABI void __node_handle_merge_multi(_Table& __source);
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(key_type const& __key);
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(const_iterator __it);
#endif
_LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash<true>(__n); }
_LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash<false>(__n); }
@@ -925,14 +872,10 @@ public:
_LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_multi(const _Key& __k) const;
_LIBCPP_HIDE_FROM_ABI void swap(__hash_table& __u)
#if _LIBCPP_STD_VER <= 11
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> &&
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
__is_nothrow_swappable_v<__pointer_allocator>) &&
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));
#else
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>);
#endif
_LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return max_size(); }
_LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const;
@@ -1097,10 +1040,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const
template <class _Tp, class _Hash, class _Equal, class _Alloc>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() {
#if defined(_LIBCPP_CXX03_LANG)
static_assert(is_copy_constructible<key_equal>::value, "Predicate must be copy-constructible.");
static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible.");
#endif
__deallocate_node(__p1_.first().__next_);
}
@@ -1579,104 +1520,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(const_iterator __
return __r;
}
#if _LIBCPP_STD_VER >= 17
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _NodeHandle, class _InsertReturnType>
_LIBCPP_HIDE_FROM_ABI _InsertReturnType
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(_NodeHandle&& __nh) {
if (__nh.empty())
return _InsertReturnType{end(), false, _NodeHandle()};
pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
if (__result.second)
__nh.__release_ptr();
return _InsertReturnType{__result.first, __result.second, std::move(__nh)};
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(const_iterator, _NodeHandle&& __nh) {
if (__nh.empty())
return end();
pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
if (__result.second)
__nh.__release_ptr();
return __result.first;
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI _NodeHandle
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(key_type const& __key) {
iterator __i = find(__key);
if (__i == end())
return _NodeHandle();
return __node_handle_extract<_NodeHandle>(__i);
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI _NodeHandle __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(const_iterator __p) {
allocator_type __alloc(__node_alloc());
return _NodeHandle(remove(__p).release(), __alloc);
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _Table>
_LIBCPP_HIDE_FROM_ABI void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_unique(_Table& __source) {
static_assert(is_same<__node, typename _Table::__node>::value, "");
for (typename _Table::iterator __it = __source.begin(); __it != __source.end();) {
__node_pointer __src_ptr = __it.__node_->__upcast();
size_t __hash = hash_function()(__src_ptr->__get_value());
__next_pointer __existing_node = __node_insert_unique_prepare(__hash, __src_ptr->__get_value());
auto __prev_iter = __it++;
if (__existing_node == nullptr) {
(void)__source.remove(__prev_iter).release();
__src_ptr->__hash_ = __hash;
__node_insert_unique_perform(__src_ptr);
}
}
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(_NodeHandle&& __nh) {
if (__nh.empty())
return end();
iterator __result = __node_insert_multi(__nh.__ptr_);
__nh.__release_ptr();
return __result;
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _NodeHandle>
_LIBCPP_HIDE_FROM_ABI typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh) {
if (__nh.empty())
return end();
iterator __result = __node_insert_multi(__hint, __nh.__ptr_);
__nh.__release_ptr();
return __result;
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _Table>
_LIBCPP_HIDE_FROM_ABI void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(_Table& __source) {
static_assert(is_same<typename _Table::__node, __node>::value, "");
for (typename _Table::iterator __it = __source.begin(); __it != __source.end();) {
__node_pointer __src_ptr = __it.__node_->__upcast();
size_t __src_hash = hash_function()(__src_ptr->__get_value());
__next_pointer __pn = __node_insert_multi_prepare(__src_hash, __src_ptr->__get_value());
(void)__source.remove(__it++).release();
__src_ptr->__hash_ = __src_hash;
__node_insert_multi_perform(__src_ptr, __pn);
}
}
#endif // _LIBCPP_STD_VER >= 17
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <bool _UniqueKeys>
void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK {
@@ -1981,15 +1824,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(const _Key& __k) c
template <class _Tp, class _Hash, class _Equal, class _Alloc>
void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
#if _LIBCPP_STD_VER <= 11
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> &&
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
__is_nothrow_swappable_v<__pointer_allocator>) &&
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))
#else
_NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>)
#endif
{
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)) {
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
__node_traits::propagate_on_container_swap::value || this->__node_alloc() == __u.__node_alloc(),
"unordered container::swap: Either propagate_on_container_swap "

View File

@@ -29,45 +29,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* end(_Tp (&__array)[_Np]) _NOEXCEPT
return __array + _Np;
}
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Cp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto begin(_Cp& __c) -> decltype(__c.begin()) {
return __c.begin();
}
template <class _Cp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto begin(const _Cp& __c) -> decltype(__c.begin()) {
return __c.begin();
}
template <class _Cp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(_Cp& __c) -> decltype(__c.end()) {
return __c.end();
}
template <class _Cp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(const _Cp& __c) -> decltype(__c.end()) {
return __c.end();
}
# if _LIBCPP_STD_VER >= 14
template <class _Cp>
_LIBCPP_HIDE_FROM_ABI constexpr auto
cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c))) -> decltype(std::begin(__c)) {
return std::begin(__c);
}
template <class _Cp>
_LIBCPP_HIDE_FROM_ABI constexpr auto cend(const _Cp& __c) noexcept(noexcept(std::end(__c))) -> decltype(std::end(__c)) {
return std::end(__c);
}
# endif
#else // defined(_LIBCPP_CXX03_LANG)
template <class _Cp>
_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator begin(_Cp& __c) {
return __c.begin();
@@ -88,8 +49,6 @@ _LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator end(const _Cp& __c) {
return __c.end();
}
#endif // !defined(_LIBCPP_CXX03_LANG)
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ITERATOR_ACCESS_H

View File

@@ -67,133 +67,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i
std::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
}
#if _LIBCPP_STD_VER >= 20
// [range.iter.op.advance]
namespace ranges {
namespace __advance {
struct __fn {
private:
template <class _Ip>
_LIBCPP_HIDE_FROM_ABI static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) {
while (__n > 0) {
--__n;
++__i;
}
}
template <class _Ip>
_LIBCPP_HIDE_FROM_ABI static constexpr void __advance_backward(_Ip& __i, iter_difference_t<_Ip> __n) {
while (__n < 0) {
++__n;
--__i;
}
}
public:
// Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative.
template <input_or_output_iterator _Ip>
_LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const {
// Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.
_LIBCPP_ASSERT_PEDANTIC(
__n >= 0 || bidirectional_iterator<_Ip>, "If `n < 0`, then `bidirectional_iterator<I>` must be true.");
// If `I` models `random_access_iterator`, equivalent to `i += n`.
if constexpr (random_access_iterator<_Ip>) {
__i += __n;
return;
} else if constexpr (bidirectional_iterator<_Ip>) {
// Otherwise, if `n` is non-negative, increments `i` by `n`.
__advance_forward(__i, __n);
// Otherwise, decrements `i` by `-n`.
__advance_backward(__i, __n);
return;
} else {
// Otherwise, if `n` is non-negative, increments `i` by `n`.
__advance_forward(__i, __n);
return;
}
}
// 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_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 = std::move(__bound_sentinel);
}
// 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_sentinel - __i);
}
// Otherwise, while `bool(i != bound_sentinel)` is true, increments `i`.
else {
while (__i != __bound_sentinel) {
++__i;
}
}
}
// Preconditions:
// * 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_sentinel) const {
// Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.
_LIBCPP_ASSERT_PEDANTIC((__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_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_sentinel - __i; __magnitude_geq(__n, __m)) {
(*this)(__i, __bound_sentinel);
return __n - __m;
}
// Otherwise, equivalent to `ranges::advance(i, n)`.
(*this)(__i, __n);
return 0;
} else {
// Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at
// most `n` times.
while (__n > 0 && __i != __bound_sentinel) {
++__i;
--__n;
}
// 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 (__n < 0 && __i != __bound_sentinel) {
--__i;
++__n;
}
}
return __n;
}
__libcpp_unreachable();
}
};
} // namespace __advance
inline namespace __cpo {
inline constexpr auto advance = __advance::__fn{};
} // namespace __cpo
} // namespace ranges
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -28,11 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Container>
class _LIBCPP_TEMPLATE_VIS back_insert_iterator
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<output_iterator_tag, void, void, void, void>
#endif
{
class _LIBCPP_TEMPLATE_VIS back_insert_iterator : public iterator<output_iterator_tag, void, void, void, void> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -41,11 +37,7 @@ protected:
public:
typedef output_iterator_tag iterator_category;
typedef void value_type;
#if _LIBCPP_STD_VER >= 20
typedef ptrdiff_t difference_type;
#else
typedef void difference_type;
#endif
typedef void pointer;
typedef void reference;
typedef _Container container_type;
@@ -57,13 +49,6 @@ public:
container->push_back(__value);
return *this;
}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator&
operator=(typename _Container::value_type&& __value) {
container->push_back(std::move(__value));
return *this;
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator*() { return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator++() { return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator operator++(int) { return *this; }

View File

@@ -52,9 +52,6 @@ struct __bounded_iter {
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 >= 20
using iterator_concept = contiguous_iterator_tag;
#endif
// Create a singular iterator.
//
@@ -202,12 +199,10 @@ public:
return __x.__current_ == __y.__current_;
}
#if _LIBCPP_STD_VER <= 17
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
return __x.__current_ != __y.__current_;
}
#endif
// TODO(mordante) disable these overloads in the LLVM 20 release.
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
@@ -227,23 +222,6 @@ public:
return __x.__current_ >= __y.__current_;
}
#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering
operator<=>(__bounded_iter const& __x, __bounded_iter const& __y) noexcept {
if constexpr (three_way_comparable<_Iterator, strong_ordering>) {
return __x.__current_ <=> __y.__current_;
} else {
if (__x.__current_ < __y.__current_)
return strong_ordering::less;
if (__x.__current_ == __y.__current_)
return strong_ordering::equal;
return strong_ordering::greater;
}
}
#endif // _LIBCPP_STD_VER >= 20
private:
template <class>
friend struct pointer_traits;
@@ -258,10 +236,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter<_It> __make_bounded_iter(
return __bounded_iter<_It>(std::move(__it), std::move(__begin), std::move(__end));
}
#if _LIBCPP_STD_VER <= 17
template <class _Iterator>
struct __libcpp_is_contiguous_iterator<__bounded_iter<_Iterator> > : true_type {};
#endif
template <class _Iterator>
struct pointer_traits<__bounded_iter<_Iterator> > {

View File

@@ -30,161 +30,12 @@
_LIBCPP_PUSH_MACROS
#include <__cxx03/__undef_macros>
#if _LIBCPP_STD_VER >= 20
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
concept __cpp17_move_constructible = is_move_constructible_v<_Tp>;
template <class _Tp>
concept __cpp17_copy_constructible = __cpp17_move_constructible<_Tp> && is_copy_constructible_v<_Tp>;
template <class _Tp>
concept __cpp17_move_assignable = requires(_Tp __lhs, _Tp __rhs) {
{ __lhs = std::move(__rhs) } -> same_as<_Tp&>;
};
template <class _Tp>
concept __cpp17_copy_assignable = __cpp17_move_assignable<_Tp> && requires(_Tp __lhs, _Tp __rhs) {
{ __lhs = __rhs } -> same_as<_Tp&>;
{ __lhs = std::as_const(__rhs) } -> same_as<_Tp&>;
};
template <class _Tp>
concept __cpp17_destructible = requires(_Tp __v) { __v.~_Tp(); };
template <class _Tp>
concept __cpp17_equality_comparable = requires(_Tp __lhs, _Tp __rhs) {
{ __lhs == __rhs } -> __boolean_testable;
{ std::as_const(__lhs) == __rhs } -> __boolean_testable;
{ __lhs == std::as_const(__rhs) } -> __boolean_testable;
{ std::as_const(__lhs) == std::as_const(__rhs) } -> __boolean_testable;
};
template <class _Tp>
concept __cpp17_default_constructible = is_default_constructible_v<_Tp>;
template <class _Iter>
concept __cpp17_iterator =
__cpp17_copy_constructible<_Iter> && __cpp17_copy_assignable<_Iter> && __cpp17_destructible<_Iter> &&
(is_signed_v<__iter_diff_t<_Iter>> || is_void_v<__iter_diff_t<_Iter>>) && requires(_Iter __iter) {
{ *__iter };
{ ++__iter } -> same_as<_Iter&>;
};
template <class _Iter>
concept __cpp17_input_iterator =
__cpp17_iterator<_Iter> && __cpp17_equality_comparable<_Iter> && requires(_Iter __lhs, _Iter __rhs) {
{ __lhs != __rhs } -> __boolean_testable;
{ std::as_const(__lhs) != __rhs } -> __boolean_testable;
{ __lhs != std::as_const(__rhs) } -> __boolean_testable;
{ std::as_const(__lhs) != std::as_const(__rhs) } -> __boolean_testable;
{ *__lhs } -> same_as<__iter_reference<_Iter>>;
{ *std::as_const(__lhs) } -> same_as<__iter_reference<_Iter>>;
{ ++__lhs } -> same_as<_Iter&>;
{ (void)__lhs++ };
{ *__lhs++ };
};
template <class _Iter, class _WriteTo>
concept __cpp17_output_iterator = __cpp17_iterator<_Iter> && requires(_Iter __iter, _WriteTo __write) {
{ *__iter = std::forward<_WriteTo>(__write) };
{ ++__iter } -> same_as<_Iter&>;
{ __iter++ } -> convertible_to<const _Iter&>;
{ *__iter++ = std::forward<_WriteTo>(__write) };
};
template <class _Iter>
concept __cpp17_forward_iterator =
__cpp17_input_iterator<_Iter> && __cpp17_default_constructible<_Iter> && requires(_Iter __iter) {
{ __iter++ } -> convertible_to<const _Iter&>;
{ *__iter++ } -> same_as<__iter_reference<_Iter>>;
};
template <class _Iter>
concept __cpp17_bidirectional_iterator = __cpp17_forward_iterator<_Iter> && requires(_Iter __iter) {
{ --__iter } -> same_as<_Iter&>;
{ __iter-- } -> convertible_to<const _Iter&>;
{ *__iter-- } -> same_as<__iter_reference<_Iter>>;
};
template <class _Iter>
concept __cpp17_random_access_iterator =
__cpp17_bidirectional_iterator<_Iter> && requires(_Iter __iter, __iter_diff_t<_Iter> __n) {
{ __iter += __n } -> same_as<_Iter&>;
{ __iter + __n } -> same_as<_Iter>;
{ __n + __iter } -> same_as<_Iter>;
{ std::as_const(__iter) + __n } -> same_as<_Iter>;
{ __n + std::as_const(__iter) } -> same_as<_Iter>;
{ __iter -= __n } -> same_as<_Iter&>;
{ __iter - __n } -> same_as<_Iter>;
{ std::as_const(__iter) - __n } -> same_as<_Iter>;
{ __iter - __iter } -> same_as<__iter_diff_t<_Iter>>;
{ std::as_const(__iter) - __iter } -> same_as<__iter_diff_t<_Iter>>;
{ __iter - std::as_const(__iter) } -> same_as<__iter_diff_t<_Iter>>;
{ std::as_const(__iter) - std::as_const(__iter) } -> same_as<__iter_diff_t<_Iter>>;
{ __iter[__n] } -> convertible_to<__iter_reference<_Iter>>;
{ std::as_const(__iter)[__n] } -> convertible_to<__iter_reference<_Iter>>;
{ __iter < __iter } -> __boolean_testable;
{ std::as_const(__iter) < __iter } -> __boolean_testable;
{ __iter < std::as_const(__iter) } -> __boolean_testable;
{ std::as_const(__iter) < std::as_const(__iter) } -> __boolean_testable;
{ __iter > __iter } -> __boolean_testable;
{ std::as_const(__iter) > __iter } -> __boolean_testable;
{ __iter > std::as_const(__iter) } -> __boolean_testable;
{ std::as_const(__iter) > std::as_const(__iter) } -> __boolean_testable;
{ __iter >= __iter } -> __boolean_testable;
{ std::as_const(__iter) >= __iter } -> __boolean_testable;
{ __iter >= std::as_const(__iter) } -> __boolean_testable;
{ std::as_const(__iter) >= std::as_const(__iter) } -> __boolean_testable;
{ __iter <= __iter } -> __boolean_testable;
{ std::as_const(__iter) <= __iter } -> __boolean_testable;
{ __iter <= std::as_const(__iter) } -> __boolean_testable;
{ std::as_const(__iter) <= std::as_const(__iter) } -> __boolean_testable;
};
_LIBCPP_END_NAMESPACE_STD
# ifndef _LIBCPP_DISABLE_ITERATOR_CHECKS
# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) \
static_assert(::std::__cpp17_input_iterator<iter_t>, message)
# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) \
static_assert(::std::__cpp17_output_iterator<iter_t, write_t>, message)
# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) \
static_assert(::std::__cpp17_forward_iterator<iter_t>, message)
# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) \
static_assert(::std::__cpp17_bidirectional_iterator<iter_t>, message)
# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) \
static_assert(::std::__cpp17_random_access_iterator<iter_t>, message)
# else
# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) static_assert(true)
# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) static_assert(true)
# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) static_assert(true)
# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) static_assert(true)
# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) static_assert(true)
# endif
#else // _LIBCPP_STD_VER >= 20
# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) static_assert(true)
# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) static_assert(true)
# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) static_assert(true)
# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) static_assert(true)
# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) static_assert(true)
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_POP_MACROS
#endif // _LIBCPP___CXX03___ITERATOR_CPP17_ITERATOR_CONCEPTS_H

View File

@@ -42,53 +42,6 @@ distance(_InputIter __first, _InputIter __last) {
return std::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
}
#if _LIBCPP_STD_VER >= 20
// [range.iter.op.distance]
namespace ranges {
namespace __distance {
struct __fn {
template <class _Ip, sentinel_for<_Ip> _Sp>
requires(!sized_sentinel_for<_Sp, _Ip>)
_LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {
iter_difference_t<_Ip> __n = 0;
while (__first != __last) {
++__first;
++__n;
}
return __n;
}
template <class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp>
_LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const {
if constexpr (sized_sentinel_for<_Sp, __remove_cvref_t<_Ip>>) {
return __last - __first;
} else {
return __last - decay_t<_Ip>(__first);
}
}
template <range _Rp>
_LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const {
if constexpr (sized_range<_Rp>) {
return static_cast<range_difference_t<_Rp>>(ranges::size(__r));
} else {
return operator()(ranges::begin(__r), ranges::end(__r));
}
}
};
} // namespace __distance
inline namespace __cpo {
inline constexpr auto distance = __distance::__fn{};
} // namespace __cpo
} // namespace ranges
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ITERATOR_DISTANCE_H

View File

@@ -28,11 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Container>
class _LIBCPP_TEMPLATE_VIS front_insert_iterator
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<output_iterator_tag, void, void, void, void>
#endif
{
class _LIBCPP_TEMPLATE_VIS front_insert_iterator : public iterator<output_iterator_tag, void, void, void, void> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -41,11 +37,7 @@ protected:
public:
typedef output_iterator_tag iterator_category;
typedef void value_type;
#if _LIBCPP_STD_VER >= 20
typedef ptrdiff_t difference_type;
#else
typedef void difference_type;
#endif
typedef void pointer;
typedef void reference;
typedef _Container container_type;
@@ -57,13 +49,6 @@ public:
container->push_front(__value);
return *this;
}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator&
operator=(typename _Container::value_type&& __value) {
container->push_front(std::move(__value));
return *this;
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator*() { return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator++() { return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator operator++(int) { return *this; }

View File

@@ -26,21 +26,12 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
template <class _Container>
using __insert_iterator_iter_t = ranges::iterator_t<_Container>;
#else
template <class _Container>
using __insert_iterator_iter_t = typename _Container::iterator;
#endif
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Container>
class _LIBCPP_TEMPLATE_VIS insert_iterator
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<output_iterator_tag, void, void, void, void>
#endif
{
class _LIBCPP_TEMPLATE_VIS insert_iterator : public iterator<output_iterator_tag, void, void, void, void> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
@@ -50,11 +41,7 @@ protected:
public:
typedef output_iterator_tag iterator_category;
typedef void value_type;
#if _LIBCPP_STD_VER >= 20
typedef ptrdiff_t difference_type;
#else
typedef void difference_type;
#endif
typedef void pointer;
typedef void reference;
typedef _Container container_type;
@@ -68,14 +55,6 @@ public:
++iter;
return *this;
}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator&
operator=(typename _Container::value_type&& __value) {
iter = container->insert(iter, std::move(__value));
++iter;
return *this;
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator*() { return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++() { return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++(int) { return *this; }

View File

@@ -27,10 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
class _LIBCPP_TEMPLATE_VIS istream_iterator
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
#endif
{
: public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
@@ -49,9 +46,6 @@ private:
public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {}
#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr istream_iterator(default_sentinel_t) : istream_iterator() {}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI istream_iterator(istream_type& __s) : __in_stream_(std::addressof(__s)) {
if (!(*__in_stream_ >> __value_))
__in_stream_ = nullptr;
@@ -73,12 +67,6 @@ public:
template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
#if _LIBCPP_STD_VER >= 20
friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istream_iterator& __i, default_sentinel_t) {
return __i.__in_stream_ == nullptr;
}
#endif // _LIBCPP_STD_VER >= 20
};
template <class _Tp, class _CharT, class _Traits, class _Distance>
@@ -87,13 +75,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const istream_iterator<_Tp, _CharT,
return __x.__in_stream_ == __y.__in_stream_;
}
#if _LIBCPP_STD_VER <= 17
template <class _Tp, class _CharT, class _Traits, class _Distance>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) {
return !(__x == __y);
}
#endif // _LIBCPP_STD_VER <= 17
_LIBCPP_END_NAMESPACE_STD

View File

@@ -25,10 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS istreambuf_iterator
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT>
#endif
{
: public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
@@ -64,9 +61,6 @@ private:
public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {}
#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr istreambuf_iterator(default_sentinel_t) noexcept : istreambuf_iterator() {}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI istreambuf_iterator(istream_type& __s) _NOEXCEPT : __sbuf_(__s.rdbuf()) {}
_LIBCPP_HIDE_FROM_ABI istreambuf_iterator(streambuf_type* __s) _NOEXCEPT : __sbuf_(__s) {}
_LIBCPP_HIDE_FROM_ABI istreambuf_iterator(const __proxy& __p) _NOEXCEPT : __sbuf_(__p.__sbuf_) {}
@@ -81,12 +75,6 @@ public:
_LIBCPP_HIDE_FROM_ABI bool equal(const istreambuf_iterator& __b) const {
return __test_for_eof() == __b.__test_for_eof();
}
#if _LIBCPP_STD_VER >= 20
friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istreambuf_iterator& __i, default_sentinel_t) {
return __i.__test_for_eof();
}
#endif // _LIBCPP_STD_VER >= 20
};
template <class _CharT, class _Traits>
@@ -95,13 +83,11 @@ operator==(const istreambuf_iterator<_CharT, _Traits>& __a, const istreambuf_ite
return __a.equal(__b);
}
#if _LIBCPP_STD_VER <= 17
template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI 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

View File

@@ -32,25 +32,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
template <class _Tp>
using __with_reference = _Tp&;
template <class _Tp>
concept __can_reference = requires { typename __with_reference<_Tp>; };
template <class _Tp>
concept __dereferenceable = requires(_Tp& __t) {
{ *__t } -> __can_reference; // not required to be equality-preserving
};
// [iterator.traits]
template <__dereferenceable _Tp>
using iter_reference_t = decltype(*std::declval<_Tp&>());
#endif // _LIBCPP_STD_VER >= 20
template <class _Iter>
struct _LIBCPP_TEMPLATE_VIS iterator_traits;
@@ -59,9 +40,6 @@ struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {};
struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {};
struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {};
struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {};
#if _LIBCPP_STD_VER >= 20
struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag : public random_access_iterator_tag {};
#endif
template <class _Iter>
struct __iter_traits_cache {
@@ -137,226 +115,6 @@ public:
static const bool value = decltype(__test<_Tp>(nullptr))::value;
};
#if _LIBCPP_STD_VER >= 20
// 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 } -> __can_reference;
{ ++__i } -> same_as<_Ip&>;
{ *__i++ } -> __can_reference;
} && copyable<_Ip>;
template <class _Ip>
concept __cpp17_input_iterator = __cpp17_iterator<_Ip> && equality_comparable<_Ip> && requires(_Ip __i) {
typename incrementable_traits<_Ip>::difference_type;
typename indirectly_readable_traits<_Ip>::value_type;
typename common_reference_t<iter_reference_t<_Ip>&&, typename indirectly_readable_traits<_Ip>::value_type&>;
typename common_reference_t<decltype(*__i++)&&, typename indirectly_readable_traits<_Ip>::value_type&>;
requires signed_integral<typename incrementable_traits<_Ip>::difference_type>;
};
template <class _Ip>
concept __cpp17_forward_iterator =
__cpp17_input_iterator<_Ip> && constructible_from<_Ip> && is_reference_v<iter_reference_t<_Ip>> &&
same_as<remove_cvref_t<iter_reference_t<_Ip>>, typename indirectly_readable_traits<_Ip>::value_type> &&
requires(_Ip __i) {
{ __i++ } -> convertible_to<_Ip const&>;
{ *__i++ } -> same_as<iter_reference_t<_Ip>>;
};
template <class _Ip>
concept __cpp17_bidirectional_iterator = __cpp17_forward_iterator<_Ip> && requires(_Ip __i) {
{ --__i } -> same_as<_Ip&>;
{ __i-- } -> convertible_to<_Ip const&>;
{ *__i-- } -> same_as<iter_reference_t<_Ip>>;
};
template <class _Ip>
concept __cpp17_random_access_iterator =
__cpp17_bidirectional_iterator<_Ip> && totally_ordered<_Ip> &&
requires(_Ip __i, typename incrementable_traits<_Ip>::difference_type __n) {
{ __i += __n } -> same_as<_Ip&>;
{ __i -= __n } -> same_as<_Ip&>;
{ __i + __n } -> same_as<_Ip>;
{ __n + __i } -> same_as<_Ip>;
{ __i - __n } -> same_as<_Ip>;
{ __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
template <class _Ip>
concept __has_member_reference = requires { typename _Ip::reference; };
template <class _Ip>
concept __has_member_pointer = requires { typename _Ip::pointer; };
template <class _Ip>
concept __has_member_iterator_category = requires { typename _Ip::iterator_category; };
template <class _Ip>
concept __specifies_members = requires {
typename _Ip::value_type;
typename _Ip::difference_type;
requires __has_member_reference<_Ip>;
requires __has_member_iterator_category<_Ip>;
};
template <class>
struct __iterator_traits_member_pointer_or_void {
using type = void;
};
template <__has_member_pointer _Tp>
struct __iterator_traits_member_pointer_or_void<_Tp> {
using type = typename _Tp::pointer;
};
template <class _Tp>
concept __cpp17_iterator_missing_members = !__specifies_members<_Tp> && __iterator_traits_detail::__cpp17_iterator<_Tp>;
template <class _Tp>
concept __cpp17_input_iterator_missing_members =
__cpp17_iterator_missing_members<_Tp> && __iterator_traits_detail::__cpp17_input_iterator<_Tp>;
// Otherwise, `pointer` names `void`.
template <class>
struct __iterator_traits_member_pointer_or_arrow_or_void {
using type = void;
};
// [iterator.traits]/3.2.1
// If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type.
template <__has_member_pointer _Ip>
struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
using type = typename _Ip::pointer;
};
// Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that
// type.
template <class _Ip>
requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)
struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
using type = decltype(std::declval<_Ip&>().operator->());
};
// Otherwise, `reference` names `iter-reference-t<I>`.
template <class _Ip>
struct __iterator_traits_member_reference {
using type = iter_reference_t<_Ip>;
};
// [iterator.traits]/3.2.2
// If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type.
template <__has_member_reference _Ip>
struct __iterator_traits_member_reference<_Ip> {
using type = typename _Ip::reference;
};
// [iterator.traits]/3.2.3.4
// input_iterator_tag
template <class _Ip>
struct __deduce_iterator_category {
using type = input_iterator_tag;
};
// [iterator.traits]/3.2.3.1
// `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise
template <__iterator_traits_detail::__cpp17_random_access_iterator _Ip>
struct __deduce_iterator_category<_Ip> {
using type = random_access_iterator_tag;
};
// [iterator.traits]/3.2.3.2
// `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise
template <__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip>
struct __deduce_iterator_category<_Ip> {
using type = bidirectional_iterator_tag;
};
// [iterator.traits]/3.2.3.3
// `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise
template <__iterator_traits_detail::__cpp17_forward_iterator _Ip>
struct __deduce_iterator_category<_Ip> {
using type = forward_iterator_tag;
};
template <class _Ip>
struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {};
// [iterator.traits]/3.2.3
// If the qualified-id `I::iterator-category` is valid and denotes a type, `iterator-category` names
// that type.
template <__has_member_iterator_category _Ip>
struct __iterator_traits_iterator_category<_Ip> {
using type = typename _Ip::iterator_category;
};
// otherwise, it names void.
template <class>
struct __iterator_traits_difference_type {
using type = void;
};
// If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then
// `difference_type` names that type;
template <class _Ip>
requires requires { typename incrementable_traits<_Ip>::difference_type; }
struct __iterator_traits_difference_type<_Ip> {
using type = typename incrementable_traits<_Ip>::difference_type;
};
// [iterator.traits]/3.4
// Otherwise, `iterator_traits<I>` has no members by any of the above names.
template <class>
struct __iterator_traits {};
// [iterator.traits]/3.1
// If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and
// `iterator-category`, then `iterator-traits<I>` has the following publicly accessible members:
template <__specifies_members _Ip>
struct __iterator_traits<_Ip> {
using iterator_category = typename _Ip::iterator_category;
using value_type = typename _Ip::value_type;
using difference_type = typename _Ip::difference_type;
using pointer = typename __iterator_traits_member_pointer_or_void<_Ip>::type;
using reference = typename _Ip::reference;
};
// [iterator.traits]/3.2
// Otherwise, if `I` satisfies the exposition-only concept `cpp17-input-iterator`,
// `iterator-traits<I>` has the following publicly accessible members:
template <__cpp17_input_iterator_missing_members _Ip>
struct __iterator_traits<_Ip> {
using iterator_category = typename __iterator_traits_iterator_category<_Ip>::type;
using value_type = typename indirectly_readable_traits<_Ip>::value_type;
using difference_type = typename incrementable_traits<_Ip>::difference_type;
using pointer = typename __iterator_traits_member_pointer_or_arrow_or_void<_Ip>::type;
using reference = typename __iterator_traits_member_reference<_Ip>::type;
};
// Otherwise, if `I` satisfies the exposition-only concept `cpp17-iterator`, then
// `iterator_traits<I>` has the following publicly accessible members:
template <__cpp17_iterator_missing_members _Ip>
struct __iterator_traits<_Ip> {
using iterator_category = output_iterator_tag;
using value_type = void;
using difference_type = typename __iterator_traits_difference_type<_Ip>::type;
using pointer = void;
using reference = void;
};
template <class _Ip>
struct iterator_traits : __iterator_traits<_Ip> {
using __primary_template = iterator_traits;
};
#else // _LIBCPP_STD_VER >= 20
template <class _Iter, bool>
struct __iterator_traits {};
@@ -387,21 +145,14 @@ template <class _Iter>
struct _LIBCPP_TEMPLATE_VIS iterator_traits : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {
using __primary_template = iterator_traits;
};
#endif // _LIBCPP_STD_VER >= 20
template <class _Tp>
#if _LIBCPP_STD_VER >= 20
requires is_object_v<_Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> {
typedef ptrdiff_t difference_type;
typedef __remove_cv_t<_Tp> value_type;
typedef _Tp* pointer;
typedef _Tp& reference;
typedef random_access_iterator_tag iterator_category;
#if _LIBCPP_STD_VER >= 20
typedef contiguous_iterator_tag iterator_concept;
#endif
};
template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>
@@ -436,15 +187,8 @@ using __has_random_access_iterator_category = __has_iterator_category_convertibl
// Such iterators receive special "contiguous" optimizations in
// std::copy and std::sort.
//
#if _LIBCPP_STD_VER >= 20
template <class _Tp>
struct __libcpp_is_contiguous_iterator
: _Or< __has_iterator_category_convertible_to<_Tp, contiguous_iterator_tag>,
__has_iterator_concept_convertible_to<_Tp, contiguous_iterator_tag> > {};
#else
template <class _Tp>
struct __libcpp_is_contiguous_iterator : false_type {};
#endif
// Any native pointer which is an iterator is also a contiguous iterator.
template <class _Up>
@@ -497,22 +241,6 @@ using __iter_diff_t = typename iterator_traits<_Iter>::difference_type;
template <class _Iter>
using __iter_reference = typename iterator_traits<_Iter>::reference;
#if _LIBCPP_STD_VER >= 20
// [readable.traits]
// Let `RI` be `remove_cvref_t<I>`. The type `iter_value_t<I>` denotes
// `indirectly_readable_traits<RI>::value_type` if `iterator_traits<RI>` names a specialization
// generated from the primary template, and `iterator_traits<RI>::value_type` otherwise.
// This has to be in this file and not readable_traits.h to break the include cycle between the two.
template <class _Ip>
using iter_value_t =
typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value,
indirectly_readable_traits<remove_cvref_t<_Ip> >,
iterator_traits<remove_cvref_t<_Ip> > >::value_type;
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ITERATOR_ITERATOR_TRAITS_H

View File

@@ -32,57 +32,9 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
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 {
{ std::declval<const _Iter&>() == std::declval<_Sent>() } -> convertible_to<bool>;
};
#endif // _LIBCPP_STD_VER >= 20
template <class _Iter>
class _LIBCPP_TEMPLATE_VIS move_iterator
#if _LIBCPP_STD_VER >= 20
: public __move_iter_category_base<_Iter>
#endif
{
#if _LIBCPP_STD_VER >= 20
private:
_LIBCPP_HIDE_FROM_ABI static constexpr auto __get_iter_concept() {
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 {
return input_iterator_tag{};
}
}
#endif // _LIBCPP_STD_VER >= 20
class _LIBCPP_TEMPLATE_VIS move_iterator {
public:
#if _LIBCPP_STD_VER >= 20
using iterator_type = _Iter;
using iterator_concept = decltype(__get_iter_concept());
// 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< __has_random_access_iterator_category<_Iter>::value,
random_access_iterator_tag,
@@ -95,7 +47,6 @@ public:
typedef typename iterator_traits<iterator_type>::reference __reference;
typedef __conditional_t<is_reference<__reference>::value, __libcpp_remove_reference_t<__reference>&&, __reference>
reference;
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}
@@ -108,40 +59,6 @@ public:
return __current_;
}
#if _LIBCPP_STD_VER >= 20
_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_SINCE_CXX17 move_iterator() : __current_() {}
template <class _Up, __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value, int> = 0>
@@ -171,7 +88,6 @@ public:
++__current_;
return __tmp;
}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator& operator--() {
--__current_;
@@ -197,39 +113,6 @@ public:
return *this;
}
#if _LIBCPP_STD_VER >= 20
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 >= 20
private:
template <class _It2>
friend class move_iterator;
@@ -244,13 +127,11 @@ operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) {
return __x.base() == __y.base();
}
#if _LIBCPP_STD_VER <= 17
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 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_SINCE_CXX17 bool
@@ -276,52 +157,17 @@ operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) {
return __x.base() >= __y.base();
}
#if _LIBCPP_STD_VER >= 20
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 >= 20
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto
operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -> decltype(__x.base() - __y.base()) {
return __x.base() - __y.base();
}
#else
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI typename move_iterator<_Iter1>::difference_type
operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) {
return __x.base() - __y.base();
}
#endif // !_LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER >= 20
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_SINCE_CXX17 move_iterator<_Iter>
operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) {
return move_iterator<_Iter>(__x.base() + __n);
}
#endif // _LIBCPP_STD_VER >= 20
#if _LIBCPP_STD_VER >= 20
template <class _Iter1, class _Iter2>
requires(!sized_sentinel_for<_Iter1, _Iter2>)
inline constexpr bool disable_sized_sentinel_for<move_iterator<_Iter1>, move_iterator<_Iter2>> = true;
#endif // _LIBCPP_STD_VER >= 20
template <class _Iter>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter> make_move_iterator(_Iter __i) {

View File

@@ -34,48 +34,6 @@ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =
return __x;
}
#if _LIBCPP_STD_VER >= 20
// [range.iter.op.next]
namespace ranges {
namespace __next {
struct __fn {
template <input_or_output_iterator _Ip>
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
++__x;
return __x;
}
template <input_or_output_iterator _Ip>
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
ranges::advance(__x, __n);
return __x;
}
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
_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_sentinel) const {
ranges::advance(__x, __n, __bound_sentinel);
return __x;
}
};
} // namespace __next
inline namespace __cpo {
inline constexpr auto next = __next::__fn{};
} // namespace __cpo
} // namespace ranges
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ITERATOR_NEXT_H

View File

@@ -26,21 +26,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
class _LIBCPP_TEMPLATE_VIS ostream_iterator
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<output_iterator_tag, void, void, void, void>
#endif
{
class _LIBCPP_TEMPLATE_VIS ostream_iterator : public iterator<output_iterator_tag, void, void, void, void> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef output_iterator_tag iterator_category;
typedef void value_type;
#if _LIBCPP_STD_VER >= 20
typedef ptrdiff_t difference_type;
#else
typedef void difference_type;
#endif
typedef void pointer;
typedef void reference;
typedef _CharT char_type;

View File

@@ -24,21 +24,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<output_iterator_tag, void, void, void, void>
#endif
{
class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator : public iterator<output_iterator_tag, void, void, void, void> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef output_iterator_tag iterator_category;
typedef void value_type;
#if _LIBCPP_STD_VER >= 20
typedef ptrdiff_t difference_type;
#else
typedef void difference_type;
#endif
typedef void pointer;
typedef void reference;
typedef _CharT char_type;

View File

@@ -33,42 +33,6 @@ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =
return __x;
}
#if _LIBCPP_STD_VER >= 20
// [range.iter.op.prev]
namespace ranges {
namespace __prev {
struct __fn {
template <bidirectional_iterator _Ip>
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
--__x;
return __x;
}
template <bidirectional_iterator _Ip>
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
ranges::advance(__x, -__n);
return __x;
}
template <bidirectional_iterator _Ip>
_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;
}
};
} // namespace __prev
inline namespace __cpo {
inline constexpr auto prev = __prev::__fn{};
} // namespace __cpo
} // namespace ranges
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___ITERATOR_PREV_H

View File

@@ -38,14 +38,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Iter>
class _LIBCPP_TEMPLATE_VIS reverse_iterator
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<typename iterator_traits<_Iter>::iterator_category,
typename iterator_traits<_Iter>::value_type,
typename iterator_traits<_Iter>::difference_type,
typename iterator_traits<_Iter>::pointer,
typename iterator_traits<_Iter>::reference>
#endif
{
typename iterator_traits<_Iter>::reference> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
private:
@@ -53,11 +50,6 @@ private:
_Iter __t_; // no longer used as of LWG #2360, not removed due to ABI break
#endif
#if _LIBCPP_STD_VER >= 20
static_assert(__has_bidirectional_iterator_category<_Iter>::value || bidirectional_iterator<_Iter>,
"reverse_iterator<It> requires It to be a bidirectional iterator.");
#endif // _LIBCPP_STD_VER >= 20
protected:
_Iter current;
@@ -68,17 +60,10 @@ public:
_If<__has_random_access_iterator_category<_Iter>::value,
random_access_iterator_tag,
typename iterator_traits<_Iter>::iterator_category>;
using pointer = typename iterator_traits<_Iter>::pointer;
#if _LIBCPP_STD_VER >= 20
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 pointer = typename iterator_traits<_Iter>::pointer;
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
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator() : __t_(), current() {}
@@ -121,19 +106,7 @@ public:
return *--__tmp;
}
#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI 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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pointer operator->() const { return std::addressof(operator*()); }
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator++() {
--current;
@@ -170,120 +143,49 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](difference_type __n) const {
return *(*this + __n);
}
#if _LIBCPP_STD_VER >= 20
_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(--std::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(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) {
auto __xtmp = __x.base();
auto __ytmp = __y.base();
ranges::iter_swap(--__xtmp, --__ytmp);
}
#endif // _LIBCPP_STD_VER >= 20
};
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 bool
operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER >= 20
requires requires {
{ __x.base() == __y.base() } -> convertible_to<bool>;
}
#endif // _LIBCPP_STD_VER >= 20
{
operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
return __x.base() == __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 bool
operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER >= 20
requires requires {
{ __x.base() > __y.base() } -> convertible_to<bool>;
}
#endif // _LIBCPP_STD_VER >= 20
{
operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
return __x.base() > __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 bool
operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER >= 20
requires requires {
{ __x.base() != __y.base() } -> convertible_to<bool>;
}
#endif // _LIBCPP_STD_VER >= 20
{
operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
return __x.base() != __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 bool
operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER >= 20
requires requires {
{ __x.base() < __y.base() } -> convertible_to<bool>;
}
#endif // _LIBCPP_STD_VER >= 20
{
operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
return __x.base() < __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 bool
operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER >= 20
requires requires {
{ __x.base() <= __y.base() } -> convertible_to<bool>;
}
#endif // _LIBCPP_STD_VER >= 20
{
operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
return __x.base() <= __y.base();
}
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 bool
operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER >= 20
requires requires {
{ __x.base() >= __y.base() } -> convertible_to<bool>;
}
#endif // _LIBCPP_STD_VER >= 20
{
operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
return __x.base() >= __y.base();
}
#if _LIBCPP_STD_VER >= 20
template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2>
_LIBCPP_HIDE_FROM_ABI constexpr compare_three_way_result_t<_Iter1, _Iter2>
operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
return __y.base() <=> __x.base();
}
#endif // _LIBCPP_STD_VER >= 20
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto
operator-(const reverse_iterator<_Iter1>& __x,
const reverse_iterator<_Iter2>& __y) -> decltype(__y.base() - __x.base()) {
return __y.base() - __x.base();
}
#else
template <class _Iter1, class _Iter2>
inline _LIBCPP_HIDE_FROM_ABI typename reverse_iterator<_Iter1>::difference_type
operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
return __y.base() - __x.base();
}
#endif
template <class _Iter>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Iter>
@@ -291,29 +193,6 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i
return reverse_iterator<_Iter>(__x.base() - __n);
}
#if _LIBCPP_STD_VER >= 20
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 >= 20
#if _LIBCPP_STD_VER >= 14
template <class _Iter>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) {
return reverse_iterator<_Iter>(__i);
}
#endif
#if _LIBCPP_STD_VER >= 20
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> {
using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>()));

View File

@@ -33,9 +33,6 @@ public:
typedef typename iterator_traits<iterator_type>::pointer pointer;
typedef typename iterator_traits<iterator_type>::reference reference;
typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
#if _LIBCPP_STD_VER >= 20
typedef contiguous_iterator_tag iterator_concept;
#endif
private:
iterator_type __i_;
@@ -131,7 +128,6 @@ operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
return __x.base() < __y.base();
}
#if _LIBCPP_STD_VER <= 17
template <class _Iter1>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
@@ -143,7 +139,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
return !(__x == __y);
}
#endif
// TODO(mordante) disable these overloads in the LLVM 20 release.
template <class _Iter1>
@@ -182,35 +177,9 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
return !(__y < __x);
}
#if _LIBCPP_STD_VER >= 20
template <class _Iter1, class _Iter2>
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept {
if constexpr (three_way_comparable_with<_Iter1, _Iter2, strong_ordering>) {
return __x.base() <=> __y.base();
} else {
if (__x.base() < __y.base())
return strong_ordering::less;
if (__x.base() == __y.base())
return strong_ordering::equal;
return strong_ordering::greater;
}
}
#endif // _LIBCPP_STD_VER >= 20
template <class _Iter1, class _Iter2>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
#ifndef _LIBCPP_CXX03_LANG
auto
operator-(const __wrap_iter<_Iter1>& __x,
const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.base() - __y.base())
#else
typename __wrap_iter<_Iter1>::difference_type
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
#endif // C++03
{
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __wrap_iter<_Iter1>::difference_type
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
return __x.base() - __y.base();
}
@@ -221,10 +190,8 @@ operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1>
return __x;
}
#if _LIBCPP_STD_VER <= 17
template <class _It>
struct __libcpp_is_contiguous_iterator<__wrap_iter<_It> > : true_type {};
#endif
template <class _It>
struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> > {

View File

@@ -84,9 +84,7 @@ public:
// locale operations:
string name() const;
bool operator==(const locale&) const;
#if _LIBCPP_STD_VER <= 17
_LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const { return !(*this == __y); }
#endif
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool
operator()(const basic_string<_CharT, _Traits, _Allocator>&, const basic_string<_CharT, _Traits, _Allocator>&) const;

View File

@@ -88,7 +88,7 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char
va_list ap_copy;
// va_copy may not be provided by the C library in C++03 mode.
#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
#if __has_builtin(__builtin_va_copy)
__builtin_va_copy(ap_copy, ap);
#else
va_copy(ap_copy, ap);

View File

@@ -50,57 +50,6 @@ inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type hypot(_A1 __x, _
return __math::hypot((__result_type)__x, (__result_type)__y);
}
#if _LIBCPP_STD_VER >= 17
// Computes the three-dimensional hypotenuse: `std::hypot(x,y,z)`.
// The naive implementation might over-/underflow which is why this implementation is more involved:
// If the square of an argument might run into issues, we scale the arguments appropriately.
// See https://github.com/llvm/llvm-project/issues/92782 for a detailed discussion and summary.
template <class _Real>
_LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) {
// Factors needed to determine if over-/underflow might happen
constexpr int __exp = std::numeric_limits<_Real>::max_exponent / 2;
const _Real __overflow_threshold = __math::ldexp(_Real(1), __exp);
const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20));
// Scale arguments depending on their size
const _Real __max_abs = std::max(__math::fabs(__x), std::max(__math::fabs(__y), __math::fabs(__z)));
_Real __scale;
if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow
__scale = __overflow_scale;
} else if (__max_abs < 1 / __overflow_threshold) { // x*x + y*y + z*z might underflow
__scale = 1 / __overflow_scale;
} else {
__scale = 1;
}
__x *= __scale;
__y *= __scale;
__z *= __scale;
// Compute hypot of scaled arguments and undo scaling
return __math::sqrt(__x * __x + __y * __y + __z * __z) / __scale;
}
inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) { return __math::__hypot(__x, __y, __z); }
inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) { return __math::__hypot(__x, __y, __z); }
inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) {
return __math::__hypot(__x, __y, __z);
}
template <class _A1,
class _A2,
class _A3,
std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 >
_LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
using __result_type = typename __promote<_A1, _A2, _A3>::type;
static_assert(!(
std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>));
return __math::__hypot(
static_cast<__result_type>(__x), static_cast<__result_type>(__y), static_cast<__result_type>(__z));
}
#endif
} // namespace __math
_LIBCPP_END_NAMESPACE_STD

View File

@@ -51,11 +51,6 @@ inline _LIBCPP_HIDE_FROM_ABI __unsafe_unretained _Tp* addressof(__unsafe_unretai
}
#endif
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Tp>
_Tp* addressof(const _Tp&&) noexcept = delete;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___MEMORY_ADDRESSOF_H

View File

@@ -30,17 +30,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
# if defined(_LIBCPP_MSVCRT_LIKE)
return ::_aligned_malloc(__size, __alignment);
# elif _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC)
// aligned_alloc() requires that __size is a multiple of __alignment,
// but for C++ [new.delete.general], only states "if the value of an
// alignment argument passed to any of these functions is not a valid
// alignment value, the behavior is undefined".
// To handle calls such as ::operator new(1, std::align_val_t(128)), we
// round __size up to the next multiple of __alignment.
size_t __rounded_size = (__size + __alignment - 1) & ~(__alignment - 1);
// Rounding up could have wrapped around to zero, so we have to add another
// max() ternary to the actual call site to avoid succeeded in that case.
return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size);
# else
void* __result = nullptr;
(void)::posix_memalign(&__result, __alignment, __size);

View File

@@ -19,15 +19,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 23
template <class _Alloc>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) {
return std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n);
}
#else
template <class _Pointer>
struct __allocation_result {
_Pointer ptr;
@@ -41,8 +32,6 @@ __allocate_at_least(_Alloc& __alloc, size_t __n) {
return {__alloc.allocate(__n), __n};
}
#endif // _LIBCPP_STD_VER >= 23
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___MEMORY_ALLOCATE_AT_LEAST_H

View File

@@ -32,7 +32,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
class allocator;
#if _LIBCPP_STD_VER <= 17
// These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17.
// Specializing allocator<void> is deprecated, but not using it.
template <>
@@ -62,8 +61,7 @@ public:
typedef allocator<_Up> other;
};
};
# endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
#endif // _LIBCPP_STD_VER <= 17
#endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
// This class provides a non-trivial default constructor to the class that derives from it
// if the condition is satisfied.
@@ -100,9 +98,7 @@ public:
typedef ptrdiff_t difference_type;
typedef _Tp value_type;
typedef true_type propagate_on_container_move_assignment;
#if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS)
_LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal;
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default;
@@ -119,12 +115,6 @@ public:
}
}
#if _LIBCPP_STD_VER >= 23
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<_Tp*> allocate_at_least(size_t __n) {
return {allocate(__n), __n};
}
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
if (__libcpp_is_constant_evaluated()) {
::operator delete(__p);
@@ -134,7 +124,6 @@ public:
}
// C++20 Removed members
#if _LIBCPP_STD_VER <= 17
_LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;
@@ -166,103 +155,19 @@ public:
}
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); }
#endif
};
// TODO(LLVM 20): Remove the escape hatch
#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
: private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > {
static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef const _Tp value_type;
typedef true_type propagate_on_container_move_assignment;
# if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS)
_LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal;
# endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default;
template <class _Up>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {}
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) {
if (__n > allocator_traits<allocator>::max_size(*this))
__throw_bad_array_new_length();
if (__libcpp_is_constant_evaluated()) {
return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp)));
} else {
return static_cast<const _Tp*>(std::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
}
}
# if _LIBCPP_STD_VER >= 23
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) {
return {allocate(__n), __n};
}
# endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(const _Tp* __p, size_t __n) {
if (__libcpp_is_constant_evaluated()) {
::operator delete(const_cast<_Tp*>(__p));
} else {
std::__libcpp_deallocate((void*)const_cast<_Tp*>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
}
}
// C++20 Removed members
# if _LIBCPP_STD_VER <= 17
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
template <class _Up>
struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
typedef allocator<_Up> other;
};
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI const_pointer address(const_reference __x) const _NOEXCEPT {
return std::addressof(__x);
}
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp* allocate(size_t __n, const void*) {
return allocate(__n);
}
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
return size_type(~0) / sizeof(_Tp);
}
template <class _Up, class... _Args>
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void construct(_Up* __p, _Args&&... __args) {
::new ((void*)__p) _Up(std::forward<_Args>(__args)...);
}
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); }
# endif
};
#endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
template <class _Tp, class _Up>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {
return true;
}
#if _LIBCPP_STD_VER <= 17
template <class _Tp, class _Up>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {
return false;
}
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___MEMORY_ALLOCATOR_H

View File

@@ -27,49 +27,6 @@ struct _LIBCPP_TEMPLATE_VIS allocator_arg_t {
explicit allocator_arg_t() = default;
};
#if _LIBCPP_STD_VER >= 17
inline constexpr allocator_arg_t allocator_arg = allocator_arg_t();
#elif !defined(_LIBCPP_CXX03_LANG)
constexpr allocator_arg_t allocator_arg = allocator_arg_t();
#endif
#ifndef _LIBCPP_CXX03_LANG
// allocator construction
template <class _Tp, class _Alloc, class... _Args>
struct __uses_alloc_ctor_imp {
typedef _LIBCPP_NODEBUG __remove_cvref_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;
static const int value = __ua ? 2 - __ic : 0;
};
template <class _Tp, class _Alloc, class... _Args>
struct __uses_alloc_ctor : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value> {};
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_HIDE_FROM_ABI void
__user_alloc_construct_impl(integral_constant<int, 0>, _Tp* __storage, const _Allocator&, _Args&&... __args) {
new (__storage) _Tp(std::forward<_Args>(__args)...);
}
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_HIDE_FROM_ABI void
__user_alloc_construct_impl(integral_constant<int, 1>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) {
new (__storage) _Tp(allocator_arg, __a, std::forward<_Args>(__args)...);
}
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_HIDE_FROM_ABI void
__user_alloc_construct_impl(integral_constant<int, 2>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) {
new (__storage) _Tp(std::forward<_Args>(__args)..., __a);
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___FUNCTIONAL_ALLOCATOR_ARG_T_H

View File

@@ -61,11 +61,7 @@ struct __const_pointer {
};
template <class _Tp, class _Ptr, class _Alloc>
struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
#ifdef _LIBCPP_CXX03_LANG
using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
#else
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
#endif
};
// __void_pointer
@@ -76,11 +72,7 @@ struct __void_pointer {
};
template <class _Ptr, class _Alloc>
struct __void_pointer<_Ptr, _Alloc, false> {
#ifdef _LIBCPP_CXX03_LANG
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>::other;
#else
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>;
#endif
};
// __const_void_pointer
@@ -91,11 +83,7 @@ struct __const_void_pointer {
};
template <class _Ptr, class _Alloc>
struct __const_void_pointer<_Ptr, _Alloc, false> {
#ifdef _LIBCPP_CXX03_LANG
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>::other;
#else
using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>;
#endif
};
// __size_type
@@ -231,17 +219,6 @@ struct __has_select_on_container_copy_construction<
_LIBCPP_SUPPRESS_DEPRECATED_POP
#if _LIBCPP_STD_VER >= 23
template <class _Pointer, class _SizeType = size_t>
struct allocation_result {
_Pointer ptr;
_SizeType count;
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
#endif // _LIBCPP_STD_VER
template <class _Alloc>
struct _LIBCPP_TEMPLATE_VIS allocator_traits {
using allocator_type = _Alloc;
@@ -259,12 +236,6 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
using propagate_on_container_swap = typename __propagate_on_container_swap<allocator_type>::type;
using is_always_equal = typename __is_always_equal<allocator_type>::type;
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp>
using rebind_alloc = __allocator_traits_rebind_t<allocator_type, _Tp>;
template <class _Tp>
using rebind_traits = allocator_traits<rebind_alloc<_Tp> >;
#else // _LIBCPP_CXX03_LANG
template <class _Tp>
struct rebind_alloc {
using other = __allocator_traits_rebind_t<allocator_type, _Tp>;
@@ -273,7 +244,6 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
struct rebind_traits {
using other = allocator_traits<typename rebind_alloc<_Tp>::other>;
};
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
allocate(allocator_type& __a, size_type __n) {
@@ -295,18 +265,6 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
return __a.allocate(__n);
}
#if _LIBCPP_STD_VER >= 23
template <class _Ap = _Alloc>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr allocation_result<pointer, size_type>
allocate_at_least(_Ap& __alloc, size_type __n) {
if constexpr (requires { __alloc.allocate_at_least(__n); }) {
return __alloc.allocate_at_least(__n);
} else {
return {__alloc.allocate(__n), __n};
}
}
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT {
__a.deallocate(__p, __n);
@@ -364,13 +322,8 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
}
};
#ifndef _LIBCPP_CXX03_LANG
template <class _Traits, class _Tp>
using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
#else
template <class _Traits, class _Tp>
using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other;
#endif
template <class _Alloc>
struct __check_valid_allocator : true_type {

View File

@@ -36,15 +36,6 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __ass
}
}
#if _LIBCPP_STD_VER >= 20
template <size_t _Np, class _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* assume_aligned(_Tp* __ptr) {
return std::__assume_aligned<_Np>(__ptr);
}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___MEMORY_ASSUME_ALIGNED_H

View File

@@ -16,8 +16,6 @@
# pragma GCC system_header
#endif
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
@@ -87,6 +85,4 @@ public:
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
#endif // _LIBCPP___CXX03___MEMORY_AUTO_PTR_H

View File

@@ -52,13 +52,6 @@ struct __compressed_pair_elem {
_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... _Indices>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit __compressed_pair_elem(
piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
: __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {}
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return __value_; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
@@ -81,13 +74,6 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
_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... _Indices>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
__compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
: __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {}
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }
};
@@ -118,14 +104,6 @@ public:
_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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename _Base1::reference first() _NOEXCEPT {
return static_cast<_Base1&>(*this).__get();
}

View File

@@ -33,24 +33,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// construct_at
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
_LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at");
return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
}
#endif
template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
#if _LIBCPP_STD_VER >= 20
return std::construct_at(__location, std::forward<_Args>(__args)...);
#else
return _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at"),
::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
#endif
}
// destroy_at
@@ -67,14 +53,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc
__loc->~_Tp();
}
#if _LIBCPP_STD_VER >= 20
template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) {
_LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at");
std::__destroy(std::begin(*__loc), std::end(*__loc));
}
#endif
template <class _ForwardIterator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
__destroy(_ForwardIterator __first, _ForwardIterator __last) {
@@ -93,34 +71,6 @@ __reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last)
return __last;
}
#if _LIBCPP_STD_VER >= 17
template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) {
std::__destroy_at(__loc);
}
# if _LIBCPP_STD_VER >= 20
template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) {
std::__destroy_at(__loc);
}
# endif
template <class _ForwardIterator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) {
(void)std::__destroy(std::move(__first), std::move(__last));
}
template <class _ForwardIterator, class _Size>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
for (; __n > 0; (void)++__first, --__n)
std::__destroy_at(std::addressof(*__first));
return __first;
}
#endif // _LIBCPP_STD_VER >= 17
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -93,20 +93,12 @@ public:
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
struct __pointer_traits_rebind {
#ifndef _LIBCPP_CXX03_LANG
typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up> type;
#else
typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up>::other type;
#endif
};
template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> {
#ifndef _LIBCPP_CXX03_LANG
typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
#else
typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
#endif
};
template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up>
@@ -123,15 +115,10 @@ struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_ty
typedef typename __pointer_traits_element_type<pointer>::type element_type;
typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
#ifndef _LIBCPP_CXX03_LANG
template <class _Up>
using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
#else
template <class _Up>
struct rebind {
typedef typename __pointer_traits_rebind<pointer, _Up>::type other;
};
#endif // _LIBCPP_CXX03_LANG
private:
struct __nat {};
@@ -152,15 +139,10 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> {
typedef _Tp element_type;
typedef ptrdiff_t difference_type;
#ifndef _LIBCPP_CXX03_LANG
template <class _Up>
using rebind = _Up*;
#else
template <class _Up>
struct rebind {
typedef _Up* other;
};
#endif
private:
struct __nat {};
@@ -172,13 +154,8 @@ public:
}
};
#ifndef _LIBCPP_CXX03_LANG
template <class _From, class _To>
using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>;
#else
template <class _From, class _To>
using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>::other;
#endif
// to_address
@@ -236,70 +213,6 @@ struct __to_address_helper<_Pointer,
}
};
#if _LIBCPP_STD_VER >= 20
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept {
return std::__to_address(__p);
}
template <class _Pointer>
inline _LIBCPP_HIDE_FROM_ABI constexpr auto
to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) {
return std::__to_address(__p);
}
#endif
#if _LIBCPP_STD_VER >= 23
template <class _Tp>
struct __pointer_of {};
template <class _Tp>
requires(__has_pointer<_Tp>::value)
struct __pointer_of<_Tp> {
using type = typename _Tp::pointer;
};
template <class _Tp>
requires(!__has_pointer<_Tp>::value && __has_element_type<_Tp>::value)
struct __pointer_of<_Tp> {
using type = typename _Tp::element_type*;
};
template <class _Tp>
requires(!__has_pointer<_Tp>::value && !__has_element_type<_Tp>::value &&
__has_element_type<pointer_traits<_Tp>>::value)
struct __pointer_of<_Tp> {
using type = typename pointer_traits<_Tp>::element_type*;
};
template <typename _Tp>
using __pointer_of_t = typename __pointer_of<_Tp>::type;
template <class _Tp, class _Up>
struct __pointer_of_or {
using type _LIBCPP_NODEBUG = _Up;
};
template <class _Tp, class _Up>
requires requires { typename __pointer_of_t<_Tp>; }
struct __pointer_of_or<_Tp, _Up> {
using type _LIBCPP_NODEBUG = __pointer_of_t<_Tp>;
};
template <typename _Tp, typename _Up>
using __pointer_of_or_t = typename __pointer_of_or<_Tp, _Up>::type;
template <class _Smart>
concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); };
template <class _Smart, class _Pointer, class... _Args>
concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p, _Args... __args) {
__s.reset(static_cast<__pointer_of_or_t<_Smart, _Pointer>>(__p), std::forward<_Args>(__args)...);
};
#endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -27,15 +27,10 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _OutputIterator, class _Tp>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator
# if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
: public iterator<output_iterator_tag, void, void, void, void>
# endif
{
: public iterator<output_iterator_tag, void, void, void, void> {
_LIBCPP_SUPPRESS_DEPRECATED_POP
private:
@@ -44,11 +39,7 @@ private:
public:
typedef output_iterator_tag iterator_category;
typedef void value_type;
# if _LIBCPP_STD_VER >= 20
typedef ptrdiff_t difference_type;
# else
typedef void difference_type;
# endif
typedef void pointer;
typedef void reference;
@@ -58,12 +49,6 @@ public:
::new ((void*)std::addressof(*__x_)) _Tp(__element);
return *this;
}
# if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI raw_storage_iterator& operator=(_Tp&& __element) {
::new ((void*)std::addressof(*__x_)) _Tp(std::move(__element));
return *this;
}
# endif
_LIBCPP_HIDE_FROM_ABI raw_storage_iterator& operator++() {
++__x_;
return *this;
@@ -73,13 +58,8 @@ public:
++__x_;
return __t;
}
# if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI _OutputIterator base() const { return __x_; }
# endif
};
#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -340,41 +340,16 @@ class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;
// http://eel.is/c++draft/util.sharedptr#util.smartptr.shared.general-6
// A pointer type Y* is said to be compatible with a pointer type T*
// when either Y* is convertible to T* or Y is U[N] and T is cv U[].
#if _LIBCPP_STD_VER >= 17
template <class _Yp, class _Tp>
struct __bounded_convertible_to_unbounded : false_type {};
template <class _Up, std::size_t _Np, class _Tp>
struct __bounded_convertible_to_unbounded<_Up[_Np], _Tp> : is_same<__remove_cv_t<_Tp>, _Up[]> {};
template <class _Yp, class _Tp>
struct __compatible_with : _Or< is_convertible<_Yp*, _Tp*>, __bounded_convertible_to_unbounded<_Yp, _Tp> > {};
#else
template <class _Yp, class _Tp>
struct __compatible_with : is_convertible<_Yp*, _Tp*> {};
#endif // _LIBCPP_STD_VER >= 17
// Constructors that take raw pointers have a different set of "compatible" constraints
// http://eel.is/c++draft/util.sharedptr#util.smartptr.shared.const-9.1
// - If T is an array type, then either T is U[N] and Y(*)[N] is convertible to T*,
// or T is U[] and Y(*)[] is convertible to T*.
// - If T is not an array type, then Y* is convertible to T*.
#if _LIBCPP_STD_VER >= 17
template <class _Yp, class _Tp, class = void>
struct __raw_pointer_compatible_with : _And< _Not<is_array<_Tp>>, is_convertible<_Yp*, _Tp*> > {};
template <class _Yp, class _Up, std::size_t _Np>
struct __raw_pointer_compatible_with<_Yp, _Up[_Np], __enable_if_t< is_convertible<_Yp (*)[_Np], _Up (*)[_Np]>::value> >
: true_type {};
template <class _Yp, class _Up>
struct __raw_pointer_compatible_with<_Yp, _Up[], __enable_if_t< is_convertible<_Yp (*)[], _Up (*)[]>::value> >
: true_type {};
#else
template <class _Yp, class _Tp>
struct __raw_pointer_compatible_with : is_convertible<_Yp*, _Tp*> {};
#endif // _LIBCPP_STD_VER >= 17
template <class _Ptr, class = void>
struct __is_deletable : false_type {};
@@ -415,12 +390,7 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr {
struct __nullptr_sfinae_tag {};
public:
#if _LIBCPP_STD_VER >= 17
typedef weak_ptr<_Tp> weak_type;
typedef remove_extent_t<_Tp> element_type;
#else
typedef _Tp element_type;
#endif
// A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
// any bookkeeping, so it's always trivially relocatable.
@@ -435,17 +405,7 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {}
template <class _Yp,
__enable_if_t< _And< __raw_pointer_compatible_with<_Yp, _Tp>
// In C++03 we get errors when trying to do SFINAE with the
// delete operator, so we always pretend that it's deletable.
// The same happens on GCC.
#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_COMPILER_GCC)
,
_If<is_array<_Tp>::value, __is_array_deletable<_Yp*>, __is_deletable<_Yp*> >
#endif
>::value,
int> = 0>
template <class _Yp, __enable_if_t< _And< __raw_pointer_compatible_with<_Yp, _Tp> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI explicit shared_ptr(_Yp* __p) : __ptr_(__p) {
unique_ptr<_Yp> __hold(__p);
typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
@@ -462,11 +422,7 @@ public:
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk;
#ifndef _LIBCPP_CXX03_LANG
__cntrl_ = new _CntrlBlk(__p, std::move(__d), _AllocT());
#else
__cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
#endif // not _LIBCPP_CXX03_LANG
__cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
__enable_weak_this(__p, __p);
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
@@ -489,12 +445,7 @@ public:
typedef __allocator_destructor<_A2> _D2;
_A2 __a2(__a);
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
::new ((void*)std::addressof(*__hold2.get()))
#ifndef _LIBCPP_CXX03_LANG
_CntrlBlk(__p, std::move(__d), __a);
#else
_CntrlBlk(__p, __d, __a);
#endif // not _LIBCPP_CXX03_LANG
::new ((void*)std::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
__cntrl_ = std::addressof(*__hold2.release());
__enable_weak_this(__p, __p);
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
@@ -516,11 +467,7 @@ public:
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;
typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk;
#ifndef _LIBCPP_CXX03_LANG
__cntrl_ = new _CntrlBlk(__p, std::move(__d), _AllocT());
#else
__cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
#endif // not _LIBCPP_CXX03_LANG
__cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__d(__p);
@@ -544,12 +491,7 @@ public:
typedef __allocator_destructor<_A2> _D2;
_A2 __a2(__a);
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
::new ((void*)std::addressof(*__hold2.get()))
#ifndef _LIBCPP_CXX03_LANG
_CntrlBlk(__p, std::move(__d), __a);
#else
_CntrlBlk(__p, __d, __a);
#endif // not _LIBCPP_CXX03_LANG
::new ((void*)std::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
__cntrl_ = std::addressof(*__hold2.release());
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
@@ -567,17 +509,6 @@ public:
__cntrl_->__add_shared();
}
// LWG-2996
// We don't backport because it is an evolutionary change.
#if _LIBCPP_STD_VER >= 20
template <class _Yp>
_LIBCPP_HIDE_FROM_ABI shared_ptr(shared_ptr<_Yp>&& __r, element_type* __p) noexcept
: __ptr_(__p), __cntrl_(__r.__cntrl_) {
__r.__ptr_ = nullptr;
__r.__cntrl_ = nullptr;
}
#endif
_LIBCPP_HIDE_FROM_ABI shared_ptr(const shared_ptr& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
if (__cntrl_)
__cntrl_->__add_shared();
@@ -607,7 +538,6 @@ public:
__throw_bad_weak_ptr();
}
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
template <class _Yp, __enable_if_t<is_convertible<_Yp*, element_type*>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr(auto_ptr<_Yp>&& __r) : __ptr_(__r.get()) {
typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<__remove_cv_t<_Yp> > > _CntrlBlk;
@@ -615,7 +545,6 @@ public:
__enable_weak_this(__r.get(), __r.get());
__r.release();
}
#endif
template <class _Yp,
class _Dp,
@@ -623,11 +552,6 @@ public:
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) {
#if _LIBCPP_STD_VER >= 14
if (__ptr_ == nullptr)
__cntrl_ = nullptr;
else
#endif
{
typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT> _CntrlBlk;
@@ -644,11 +568,6 @@ public:
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) {
#if _LIBCPP_STD_VER >= 14
if (__ptr_ == nullptr)
__cntrl_ = nullptr;
else
#endif
{
typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,
@@ -688,7 +607,6 @@ public:
return *this;
}
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
template <class _Yp,
__enable_if_t<!is_array<_Yp>::value && is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value,
int> = 0>
@@ -696,7 +614,6 @@ public:
shared_ptr(std::move(__r)).swap(*this);
return *this;
}
#endif
template <class _Yp,
class _Dp,
@@ -744,9 +661,7 @@ public:
_LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __cntrl_ ? __cntrl_->use_count() : 0; }
#if _LIBCPP_STD_VER < 20 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE)
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI bool unique() const _NOEXCEPT { return use_count() == 1; }
#endif
_LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return get() != nullptr; }
@@ -762,13 +677,6 @@ public:
_LIBCPP_HIDE_FROM_ABI bool __owner_equivalent(const shared_ptr& __p) const { return __cntrl_ == __p.__cntrl_; }
#if _LIBCPP_STD_VER >= 17
_LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<element_type> operator[](ptrdiff_t __i) const {
static_assert(is_array<_Tp>::value, "std::shared_ptr<T>::operator[] is only valid when T is an array type.");
return __ptr_[__i];
}
#endif
#ifndef _LIBCPP_HAS_NO_RTTI
template <class _Dp>
_LIBCPP_HIDE_FROM_ABI _Dp* __get_deleter() const _NOEXCEPT {
@@ -823,13 +731,6 @@ private:
friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>;
template <class _Tp, class _Dp>
shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>;
#endif
//
// std::allocate_shared and std::make_shared
//
@@ -849,281 +750,11 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(_Args&&... __args) {
return std::allocate_shared<_Tp>(allocator<__remove_cv_t<_Tp> >(), std::forward<_Args>(__args)...);
}
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Alloc, __enable_if_t<!is_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a) {
using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>;
_ForOverwriteAllocator __alloc(__a);
return std::allocate_shared<_Tp>(__alloc);
}
template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() {
return std::allocate_shared_for_overwrite<_Tp>(allocator<__remove_cv_t<_Tp>>());
}
#endif // _LIBCPP_STD_VER >= 20
#if _LIBCPP_STD_VER >= 17
template <size_t _Alignment>
struct __sp_aligned_storage {
alignas(_Alignment) char __storage[_Alignment];
};
template <class _Tp, class _Alloc>
struct __unbounded_array_control_block;
template <class _Tp, class _Alloc>
struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count {
_LIBCPP_HIDE_FROM_ABI constexpr _Tp* __get_data() noexcept { return __data_; }
_LIBCPP_HIDE_FROM_ABI explicit __unbounded_array_control_block(
_Alloc const& __alloc, size_t __count, _Tp const& __arg)
: __alloc_(__alloc), __count_(__count) {
std::__uninitialized_allocator_fill_n_multidimensional(__alloc_, std::begin(__data_), __count_, __arg);
}
_LIBCPP_HIDE_FROM_ABI explicit __unbounded_array_control_block(_Alloc const& __alloc, size_t __count)
: __alloc_(__alloc), __count_(__count) {
# if _LIBCPP_STD_VER >= 20
if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) {
// We are purposefully not using an allocator-aware default construction because the spec says so.
// There's currently no way of expressing default initialization in an allocator-aware manner anyway.
std::uninitialized_default_construct_n(std::begin(__data_), __count_);
} else {
std::__uninitialized_allocator_value_construct_n_multidimensional(__alloc_, std::begin(__data_), __count_);
}
# else
std::__uninitialized_allocator_value_construct_n_multidimensional(__alloc_, std::begin(__data_), __count_);
# endif
}
// Returns the number of bytes required to store a control block followed by the given number
// of elements of _Tp, with the whole storage being aligned to a multiple of _Tp's alignment.
_LIBCPP_HIDE_FROM_ABI static constexpr size_t __bytes_for(size_t __elements) {
// When there's 0 elements, the control block alone is enough since it holds one element.
// Otherwise, we allocate one fewer element than requested because the control block already
// holds one. Also, we use the bitwise formula below to ensure that we allocate enough bytes
// for the whole allocation to be a multiple of _Tp's alignment. That formula is taken from [1].
//
// [1]: https://en.wikipedia.org/wiki/Data_structure_alignment#Computing_padding
size_t __bytes = __elements == 0 ? sizeof(__unbounded_array_control_block)
: (__elements - 1) * sizeof(_Tp) + sizeof(__unbounded_array_control_block);
constexpr size_t __align = alignof(_Tp);
return (__bytes + __align - 1) & ~(__align - 1);
}
_LIBCPP_HIDE_FROM_ABI_VIRTUAL
~__unbounded_array_control_block() override {
} // can't be `= default` because of the sometimes-non-trivial union member __data_
private:
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override {
# if _LIBCPP_STD_VER >= 20
if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) {
std::__reverse_destroy(__data_, __data_ + __count_);
} else {
__allocator_traits_rebind_t<_Alloc, _Tp> __value_alloc(__alloc_);
std::__allocator_destroy_multidimensional(__value_alloc, __data_, __data_ + __count_);
}
# else
__allocator_traits_rebind_t<_Alloc, _Tp> __value_alloc(__alloc_);
std::__allocator_destroy_multidimensional(__value_alloc, __data_, __data_ + __count_);
# endif
}
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override {
using _AlignedStorage = __sp_aligned_storage<alignof(__unbounded_array_control_block)>;
using _StorageAlloc = __allocator_traits_rebind_t<_Alloc, _AlignedStorage>;
using _PointerTraits = pointer_traits<typename allocator_traits<_StorageAlloc>::pointer>;
_StorageAlloc __tmp(__alloc_);
__alloc_.~_Alloc();
size_t __size = __unbounded_array_control_block::__bytes_for(__count_);
_AlignedStorage* __storage = reinterpret_cast<_AlignedStorage*>(this);
allocator_traits<_StorageAlloc>::deallocate(
__tmp, _PointerTraits::pointer_to(*__storage), __size / sizeof(_AlignedStorage));
}
_LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_;
size_t __count_;
union {
_Tp __data_[1];
};
};
template <class _Array, class _Alloc, class... _Arg>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Array>
__allocate_shared_unbounded_array(const _Alloc& __a, size_t __n, _Arg&&... __arg) {
static_assert(__libcpp_is_unbounded_array<_Array>::value);
// We compute the number of bytes necessary to hold the control block and the
// array elements. Then, we allocate an array of properly-aligned dummy structs
// large enough to hold the control block and array. This allows shifting the
// burden of aligning memory properly from us to the allocator.
using _ControlBlock = __unbounded_array_control_block<_Array, _Alloc>;
using _AlignedStorage = __sp_aligned_storage<alignof(_ControlBlock)>;
using _StorageAlloc = __allocator_traits_rebind_t<_Alloc, _AlignedStorage>;
__allocation_guard<_StorageAlloc> __guard(__a, _ControlBlock::__bytes_for(__n) / sizeof(_AlignedStorage));
_ControlBlock* __control_block = reinterpret_cast<_ControlBlock*>(std::addressof(*__guard.__get()));
std::__construct_at(__control_block, __a, __n, std::forward<_Arg>(__arg)...);
__guard.__release_ptr();
return shared_ptr<_Array>::__create_with_control_block(__control_block->__get_data(), __control_block);
}
template <class _Tp, class _Alloc>
struct __bounded_array_control_block;
template <class _Tp, size_t _Count, class _Alloc>
struct __bounded_array_control_block<_Tp[_Count], _Alloc> : __shared_weak_count {
_LIBCPP_HIDE_FROM_ABI constexpr _Tp* __get_data() noexcept { return __data_; }
_LIBCPP_HIDE_FROM_ABI explicit __bounded_array_control_block(_Alloc const& __alloc, _Tp const& __arg)
: __alloc_(__alloc) {
std::__uninitialized_allocator_fill_n_multidimensional(__alloc_, std::addressof(__data_[0]), _Count, __arg);
}
_LIBCPP_HIDE_FROM_ABI explicit __bounded_array_control_block(_Alloc const& __alloc) : __alloc_(__alloc) {
# if _LIBCPP_STD_VER >= 20
if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) {
// We are purposefully not using an allocator-aware default construction because the spec says so.
// There's currently no way of expressing default initialization in an allocator-aware manner anyway.
std::uninitialized_default_construct_n(std::addressof(__data_[0]), _Count);
} else {
std::__uninitialized_allocator_value_construct_n_multidimensional(__alloc_, std::addressof(__data_[0]), _Count);
}
# else
std::__uninitialized_allocator_value_construct_n_multidimensional(__alloc_, std::addressof(__data_[0]), _Count);
# endif
}
_LIBCPP_HIDE_FROM_ABI_VIRTUAL
~__bounded_array_control_block() override {
} // can't be `= default` because of the sometimes-non-trivial union member __data_
private:
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override {
# if _LIBCPP_STD_VER >= 20
if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) {
std::__reverse_destroy(__data_, __data_ + _Count);
} else {
__allocator_traits_rebind_t<_Alloc, _Tp> __value_alloc(__alloc_);
std::__allocator_destroy_multidimensional(__value_alloc, __data_, __data_ + _Count);
}
# else
__allocator_traits_rebind_t<_Alloc, _Tp> __value_alloc(__alloc_);
std::__allocator_destroy_multidimensional(__value_alloc, __data_, __data_ + _Count);
# endif
}
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override {
using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, __bounded_array_control_block>;
using _PointerTraits = pointer_traits<typename allocator_traits<_ControlBlockAlloc>::pointer>;
_ControlBlockAlloc __tmp(__alloc_);
__alloc_.~_Alloc();
allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*this), 1);
}
_LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_;
union {
_Tp __data_[_Count];
};
};
template <class _Array, class _Alloc, class... _Arg>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&&... __arg) {
static_assert(__libcpp_is_bounded_array<_Array>::value);
using _ControlBlock = __bounded_array_control_block<_Array, _Alloc>;
using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, _ControlBlock>;
__allocation_guard<_ControlBlockAlloc> __guard(__a, 1);
_ControlBlock* __control_block = reinterpret_cast<_ControlBlock*>(std::addressof(*__guard.__get()));
std::__construct_at(__control_block, __a, std::forward<_Arg>(__arg)...);
__guard.__release_ptr();
return shared_ptr<_Array>::__create_with_control_block(__control_block->__get_data(), __control_block);
}
#endif // _LIBCPP_STD_VER >= 17
#if _LIBCPP_STD_VER >= 20
// bounded array variants
template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a) {
return std::__allocate_shared_bounded_array<_Tp>(__a);
}
template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u) {
return std::__allocate_shared_bounded_array<_Tp>(__a, __u);
}
template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a) {
using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>;
_ForOverwriteAllocator __alloc(__a);
return std::__allocate_shared_bounded_array<_Tp>(__alloc);
}
template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared() {
return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>());
}
template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u) {
return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u);
}
template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() {
return std::__allocate_shared_bounded_array<_Tp>(allocator<__for_overwrite_tag>());
}
// unbounded array variants
template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n) {
return std::__allocate_shared_unbounded_array<_Tp>(__a, __n);
}
template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u) {
return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u);
}
template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a, size_t __n) {
using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>;
_ForOverwriteAllocator __alloc(__a);
return std::__allocate_shared_unbounded_array<_Tp>(__alloc, __n);
}
template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n) {
return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n);
}
template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u) {
return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u);
}
template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite(size_t __n) {
return std::__allocate_shared_unbounded_array<_Tp>(allocator<__for_overwrite_tag>(), __n);
}
#endif // _LIBCPP_STD_VER >= 20
template <class _Tp, class _Up>
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT {
return __x.get() == __y.get();
}
#if _LIBCPP_STD_VER <= 17
template <class _Tp, class _Up>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT {
return !(__x == __y);
@@ -1131,12 +762,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const shared_ptr<_Tp>& __x, const s
template <class _Tp, class _Up>
inline _LIBCPP_HIDE_FROM_ABI bool operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT {
# if _LIBCPP_STD_VER <= 11
typedef typename common_type<_Tp*, _Up*>::type _Vp;
return less<_Vp>()(__x.get(), __y.get());
# else
return less<>()(__x.get(), __y.get());
# endif
}
template <class _Tp, class _Up>
@@ -1154,22 +781,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const shared_ptr<_Tp>& __x, const s
return !(__x < __y);
}
#endif // _LIBCPP_STD_VER <= 17
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) noexcept {
return compare_three_way()(__x.get(), __y.get());
}
#endif
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT {
return !__x;
}
#if _LIBCPP_STD_VER <= 17
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI bool operator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT {
return !__x;
@@ -1225,15 +841,6 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(nullptr_t, const shared_ptr<_Tp>& _
return !(nullptr < __x);
}
#endif // _LIBCPP_STD_VER <= 17
#if _LIBCPP_STD_VER >= 20
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(shared_ptr<_Tp> const& __x, nullptr_t) noexcept {
return compare_three_way()(__x.get(), static_cast<typename shared_ptr<_Tp>::element_type*>(nullptr));
}
#endif
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI void swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT {
__x.swap(__y);
@@ -1244,15 +851,6 @@ inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> static_pointer_cast(const shared_pt
return shared_ptr<_Tp>(__r, static_cast< typename shared_ptr<_Tp>::element_type*>(__r.get()));
}
// LWG-2996
// We don't backport because it is an evolutionary change.
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> static_pointer_cast(shared_ptr<_Up>&& __r) noexcept {
return shared_ptr<_Tp>(std::move(__r), static_cast<typename shared_ptr<_Tp>::element_type*>(__r.get()));
}
#endif
template <class _Tp, class _Up>
inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT {
typedef typename shared_ptr<_Tp>::element_type _ET;
@@ -1260,45 +858,17 @@ inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(const shared_p
return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>();
}
// LWG-2996
// We don't backport because it is an evolutionary change.
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(shared_ptr<_Up>&& __r) noexcept {
auto* __p = dynamic_cast<typename shared_ptr<_Tp>::element_type*>(__r.get());
return __p ? shared_ptr<_Tp>(std::move(__r), __p) : shared_ptr<_Tp>();
}
#endif
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT {
typedef typename shared_ptr<_Tp>::element_type _RTp;
return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get()));
}
// LWG-2996
// We don't backport because it is an evolutionary change.
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(shared_ptr<_Up>&& __r) noexcept {
return shared_ptr<_Tp>(std::move(__r), const_cast<typename shared_ptr<_Tp>::element_type*>(__r.get()));
}
#endif
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT {
return shared_ptr<_Tp>(__r, reinterpret_cast< typename shared_ptr<_Tp>::element_type*>(__r.get()));
}
// LWG-2996
// We don't backport because it is an evolutionary change.
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&& __r) noexcept {
return shared_ptr<_Tp>(std::move(__r), reinterpret_cast<typename shared_ptr<_Tp>::element_type*>(__r.get()));
}
#endif
#ifndef _LIBCPP_HAS_NO_RTTI
template <class _Dp, class _Tp>
@@ -1311,11 +881,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXC
template <class _Tp>
class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr {
public:
#if _LIBCPP_STD_VER >= 17
typedef remove_extent_t<_Tp> element_type;
#else
typedef _Tp element_type;
#endif
// A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
// any bookkeeping, so it's always trivially relocatable.
@@ -1375,11 +941,6 @@ public:
friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>;
#endif
template <class _Tp>
inline _LIBCPP_CONSTEXPR weak_ptr<_Tp>::weak_ptr() _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {}
@@ -1481,13 +1042,8 @@ shared_ptr<_Tp> weak_ptr<_Tp>::lock() const _NOEXCEPT {
return __r;
}
#if _LIBCPP_STD_VER >= 17
template <class _Tp = void>
struct owner_less;
#else
template <class _Tp>
struct owner_less;
#endif
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> {
@@ -1515,29 +1071,6 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > : __binary_function<weak_
}
};
#if _LIBCPP_STD_VER >= 17
template <>
struct _LIBCPP_TEMPLATE_VIS owner_less<void> {
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT {
return __x.owner_before(__y);
}
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const _NOEXCEPT {
return __x.owner_before(__y);
}
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI bool operator()(weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT {
return __x.owner_before(__y);
}
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI bool operator()(weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const _NOEXCEPT {
return __x.owner_before(__y);
}
typedef void is_transparent;
};
#endif
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS enable_shared_from_this {
mutable weak_ptr<_Tp> __weak_this_;
@@ -1552,12 +1085,6 @@ public:
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> shared_from_this() { return shared_ptr<_Tp>(__weak_this_); }
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp const> shared_from_this() const { return shared_ptr<const _Tp>(__weak_this_); }
#if _LIBCPP_STD_VER >= 17
_LIBCPP_HIDE_FROM_ABI weak_ptr<_Tp> weak_from_this() _NOEXCEPT { return __weak_this_; }
_LIBCPP_HIDE_FROM_ABI weak_ptr<const _Tp> weak_from_this() const _NOEXCEPT { return __weak_this_; }
#endif // _LIBCPP_STD_VER >= 17
template <class _Up>
friend class shared_ptr;
};
@@ -1567,10 +1094,8 @@ struct _LIBCPP_TEMPLATE_VIS hash;
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash<shared_ptr<_Tp> > {
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
_LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> argument_type;
_LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
#endif
_LIBCPP_HIDE_FROM_ABI size_t operator()(const shared_ptr<_Tp>& __ptr) const _NOEXCEPT {
return hash<typename shared_ptr<_Tp>::element_type*>()(__ptr.get());

View File

@@ -23,12 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <typename _Alloc>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>)
#endif
{
_NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>) {
using std::swap;
swap(__a1, __a2);
}
@@ -39,12 +34,7 @@ __swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {}
template <typename _Alloc>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>)
#endif
{
_NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>) {
std::__swap_allocator(
__a1, __a2, integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
}

View File

@@ -25,21 +25,11 @@ 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;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __addr() {
#ifdef _LIBCPP_CXX03_LANG
return reinterpret_cast<_Tp*>(std::addressof(__v));
#else
return std::addressof(__v);
#endif
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& get() { return *__addr(); }

View File

@@ -169,347 +169,6 @@ uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {
return std::__uninitialized_fill_n<_ValueType>(__first, __n, __x);
}
#if _LIBCPP_STD_VER >= 17
// uninitialized_default_construct
template <class _ValueType, class _ForwardIterator, class _Sentinel>
inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
__uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) {
auto __idx = __first;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
# endif
for (; __idx != __last; ++__idx)
::new (std::__voidify(*__idx)) _ValueType;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
}
# endif
return __idx;
}
template <class _ForwardIterator>
inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) {
using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
(void)std::__uninitialized_default_construct<_ValueType>(std::move(__first), std::move(__last));
}
// uninitialized_default_construct_n
template <class _ValueType, class _ForwardIterator, class _Size>
inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
auto __idx = __first;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
# endif
for (; __n > 0; ++__idx, (void)--__n)
::new (std::__voidify(*__idx)) _ValueType;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
}
# endif
return __idx;
}
template <class _ForwardIterator, class _Size>
inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
return std::__uninitialized_default_construct_n<_ValueType>(std::move(__first), __n);
}
// uninitialized_value_construct
template <class _ValueType, class _ForwardIterator, class _Sentinel>
inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
__uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) {
auto __idx = __first;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
# endif
for (; __idx != __last; ++__idx)
::new (std::__voidify(*__idx)) _ValueType();
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
}
# endif
return __idx;
}
template <class _ForwardIterator>
inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) {
using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
(void)std::__uninitialized_value_construct<_ValueType>(std::move(__first), std::move(__last));
}
// uninitialized_value_construct_n
template <class _ValueType, class _ForwardIterator, class _Size>
inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
auto __idx = __first;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
# endif
for (; __n > 0; ++__idx, (void)--__n)
::new (std::__voidify(*__idx)) _ValueType();
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
}
# endif
return __idx;
}
template <class _ForwardIterator, class _Size>
inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
return std::__uninitialized_value_construct_n<_ValueType>(std::move(__first), __n);
}
// uninitialized_move
template <class _ValueType,
class _InputIterator,
class _Sentinel1,
class _ForwardIterator,
class _EndPredicate,
class _IterMove>
inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move(
_InputIterator __ifirst,
_Sentinel1 __ilast,
_ForwardIterator __ofirst,
_EndPredicate __stop_moving,
_IterMove __iter_move) {
auto __idx = __ofirst;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
# endif
for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) {
::new (std::__voidify(*__idx)) _ValueType(__iter_move(__ifirst));
}
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
std::__destroy(__ofirst, __idx);
throw;
}
# endif
return {std::move(__ifirst), std::move(__idx)};
}
template <class _InputIterator, class _ForwardIterator>
inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
uninitialized_move(_InputIterator __ifirst, _InputIterator __ilast, _ForwardIterator __ofirst) {
using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
auto __iter_move = [](auto&& __iter) -> decltype(auto) { return std::move(*__iter); };
auto __result = std::__uninitialized_move<_ValueType>(
std::move(__ifirst), std::move(__ilast), std::move(__ofirst), __always_false(), __iter_move);
return std::move(__result.second);
}
// uninitialized_move_n
template <class _ValueType,
class _InputIterator,
class _Size,
class _ForwardIterator,
class _EndPredicate,
class _IterMove>
inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n(
_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) {
auto __idx = __ofirst;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
# endif
for (; __n > 0 && !__stop_moving(__idx); ++__idx, (void)++__ifirst, --__n)
::new (std::__voidify(*__idx)) _ValueType(__iter_move(__ifirst));
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
std::__destroy(__ofirst, __idx);
throw;
}
# endif
return {std::move(__ifirst), std::move(__idx)};
}
template <class _InputIterator, class _Size, class _ForwardIterator>
inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst) {
using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
auto __iter_move = [](auto&& __iter) -> decltype(auto) { return std::move(*__iter); };
return std::__uninitialized_move_n<_ValueType>(
std::move(__ifirst), __n, std::move(__ofirst), __always_false(), __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,
__enable_if_t<__has_bidirectional_iterator_category<_BidirIter>::value, int> = 0>
_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_multidimensional(_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.
auto __guard = std::__make_exception_guard([&]() {
std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
});
for (; __i != extent_v<_Tp>; ++__i) {
std::__allocator_construct_at_multidimensional(__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_multidimensional(_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_multidimensional 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.
auto __guard = std::__make_exception_guard([&]() {
std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
});
for (; __i != extent_v<_Tp>; ++__i) {
std::__allocator_construct_at_multidimensional(__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_multidimensional(_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.
auto __guard =
std::__make_exception_guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
for (; __n != 0; --__n, ++__it) {
std::__allocator_construct_at_multidimensional(__value_alloc, std::addressof(*__it), __value);
}
__guard.__complete();
}
// Same as __uninitialized_allocator_fill_n_multidimensional, 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_multidimensional(_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.
auto __guard =
std::__make_exception_guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
for (; __n != 0; --__n, ++__it) {
std::__allocator_construct_at_multidimensional(__value_alloc, std::addressof(*__it));
}
__guard.__complete();
}
#endif // _LIBCPP_STD_VER >= 17
// 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_SINCE_CXX20 void

View File

@@ -49,25 +49,10 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_CXX03_LANG
template <class _Ptr>
struct __is_noexcept_deref_or_void {
static constexpr bool value = noexcept(*std::declval<_Ptr>());
};
template <>
struct __is_noexcept_deref_or_void<void*> : true_type {};
#endif
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS default_delete {
static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default;
#else
_LIBCPP_HIDE_FROM_ABI default_delete() {}
#endif
template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up>&) _NOEXCEPT {}
@@ -85,11 +70,7 @@ private:
struct _EnableIfConvertible : enable_if<is_convertible<_Up (*)[], _Tp (*)[]>::value> {};
public:
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default;
#else
_LIBCPP_HIDE_FROM_ABI default_delete() {}
#endif
template <class _Up>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
@@ -219,11 +200,9 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
: __ptr_(__u.release(), std::forward<_Ep>(__u.get_deleter())) {}
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
template <class _Up,
__enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release(), __value_init_tag()) {}
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
reset(__u.release());
@@ -241,19 +220,15 @@ public:
return *this;
}
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
template <class _Up,
__enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI unique_ptr& operator=(auto_ptr<_Up> __p) {
reset(__p.release());
return *this;
}
#endif
#ifdef _LIBCPP_CXX03_LANG
unique_ptr(unique_ptr const&) = delete;
unique_ptr& operator=(unique_ptr const&) = delete;
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
@@ -431,10 +406,8 @@ public:
return *this;
}
#ifdef _LIBCPP_CXX03_LANG
unique_ptr(unique_ptr const&) = delete;
unique_ptr& operator=(unique_ptr const&) = delete;
#endif
public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
@@ -494,12 +467,10 @@ operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
return __x.get() == __y.get();
}
#if _LIBCPP_STD_VER <= 17
template <class _T1, class _D1, class _T2, class _D2>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
return !(__x == __y);
}
#endif
template <class _T1, class _D1, class _T2, class _D2>
inline _LIBCPP_HIDE_FROM_ABI bool operator<(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
@@ -524,23 +495,12 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const unique_ptr<_T1, _D1>& __x, co
return !(__x < __y);
}
#if _LIBCPP_STD_VER >= 20
template <class _T1, class _D1, class _T2, class _D2>
requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>
_LIBCPP_HIDE_FROM_ABI
compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>
operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
return compare_three_way()(__x.get(), __y.get());
}
#endif
template <class _T1, class _D1>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT {
return !__x;
}
#if _LIBCPP_STD_VER <= 17
template <class _T1, class _D1>
inline _LIBCPP_HIDE_FROM_ABI bool operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT {
return !__x;
@@ -555,7 +515,6 @@ template <class _T1, class _D1>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT {
return static_cast<bool>(__x);
}
#endif // _LIBCPP_STD_VER <= 17
template <class _T1, class _D1>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
@@ -599,83 +558,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>=(nullp
return !(nullptr < __x);
}
#if _LIBCPP_STD_VER >= 20
template <class _T1, class _D1>
requires three_way_comparable< typename unique_ptr<_T1, _D1>::pointer>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer>
operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
return compare_three_way()(__x.get(), static_cast<typename unique_ptr<_T1, _D1>::pointer>(nullptr));
}
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
struct __unique_if {
typedef unique_ptr<_Tp> __unique_single;
};
template <class _Tp>
struct __unique_if<_Tp[]> {
typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
};
template <class _Tp, size_t _Np>
struct __unique_if<_Tp[_Np]> {
typedef void __unique_array_known_bound;
};
template <class _Tp, class... _Args>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single
make_unique(_Args&&... __args) {
return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
}
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound
make_unique(size_t __n) {
typedef __remove_extent_t<_Tp> _Up;
return unique_ptr<_Tp>(new _Up[__n]());
}
template <class _Tp, class... _Args>
typename __unique_if<_Tp>::__unique_array_known_bound make_unique(_Args&&...) = delete;
#endif // _LIBCPP_STD_VER >= 14
#if _LIBCPP_STD_VER >= 20
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single
make_unique_for_overwrite() {
return unique_ptr<_Tp>(new _Tp);
}
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound
make_unique_for_overwrite(size_t __n) {
return unique_ptr<_Tp>(new __remove_extent_t<_Tp>[__n]);
}
template <class _Tp, class... _Args>
typename __unique_if<_Tp>::__unique_array_known_bound make_unique_for_overwrite(_Args&&...) = delete;
#endif // _LIBCPP_STD_VER >= 20
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash;
template <class _Tp, class _Dp>
#ifdef _LIBCPP_CXX03_LANG
struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >
#else
struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >
#endif
{
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> > {
_LIBCPP_DEPRECATED_IN_CXX17 typedef unique_ptr<_Tp, _Dp> argument_type;
_LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
#endif
_LIBCPP_HIDE_FROM_ABI size_t operator()(const unique_ptr<_Tp, _Dp>& __ptr) const {
typedef typename unique_ptr<_Tp, _Dp>::pointer pointer;

View File

@@ -42,11 +42,6 @@ struct __uses_allocator<_Tp, _Alloc, false> : public false_type {};
template <class _Tp, class _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator : public __uses_allocator<_Tp, _Alloc> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp, class _Alloc>
inline constexpr bool uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___MEMORY_USES_ALLOCATOR_H

View File

@@ -17,9 +17,6 @@
#include <__cxx03/__utility/forward.h>
#include <__cxx03/__utility/move.h>
#include <__cxx03/cstdint>
#ifndef _LIBCPP_CXX03_LANG
# include <__cxx03/tuple>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -32,21 +29,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TEMPLATE_VIS once_flag;
#ifndef _LIBCPP_CXX03_LANG
template <class _Callable, class... _Args>
_LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, _Callable&&, _Args&&...);
#else // _LIBCPP_CXX03_LANG
template <class _Callable>
_LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, _Callable&);
template <class _Callable>
_LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, const _Callable&);
#endif // _LIBCPP_CXX03_LANG
struct _LIBCPP_TEMPLATE_VIS once_flag {
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR once_flag() _NOEXCEPT : __state_(_Unset) {}
once_flag(const once_flag&) = delete;
@@ -65,41 +53,13 @@ struct _LIBCPP_TEMPLATE_VIS once_flag {
private:
_State_type __state_;
#ifndef _LIBCPP_CXX03_LANG
template <class _Callable, class... _Args>
friend void call_once(once_flag&, _Callable&&, _Args&&...);
#else // _LIBCPP_CXX03_LANG
template <class _Callable>
friend void call_once(once_flag&, _Callable&);
template <class _Callable>
friend void call_once(once_flag&, const _Callable&);
#endif // _LIBCPP_CXX03_LANG
};
#ifndef _LIBCPP_CXX03_LANG
template <class _Fp>
class __call_once_param {
_Fp& __f_;
public:
_LIBCPP_HIDE_FROM_ABI explicit __call_once_param(_Fp& __f) : __f_(__f) {}
_LIBCPP_HIDE_FROM_ABI void operator()() {
typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index;
__execute(_Index());
}
private:
template <size_t... _Indices>
_LIBCPP_HIDE_FROM_ABI void __execute(__tuple_indices<_Indices...>) {
std::__invoke(std::get<0>(std::move(__f_)), std::get<_Indices>(std::move(__f_))...);
}
};
#else
template <class _Fp>
class __call_once_param {
_Fp& __f_;
@@ -110,8 +70,6 @@ public:
_LIBCPP_HIDE_FROM_ABI void operator()() { __f_(); }
};
#endif
template <class _Fp>
void _LIBCPP_HIDE_FROM_ABI __call_once_proxy(void* __vp) {
__call_once_param<_Fp>* __p = static_cast<__call_once_param<_Fp>*>(__vp);
@@ -120,20 +78,6 @@ void _LIBCPP_HIDE_FROM_ABI __call_once_proxy(void* __vp) {
_LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile once_flag::_State_type&, void*, void (*)(void*));
#ifndef _LIBCPP_CXX03_LANG
template <class _Callable, class... _Args>
inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) {
if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
typedef tuple<_Callable&&, _Args&&...> _Gp;
_Gp __f(std::forward<_Callable>(__func), std::forward<_Args>(__args)...);
__call_once_param<_Gp> __p(__f);
std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);
}
}
#else // _LIBCPP_CXX03_LANG
template <class _Callable>
inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func) {
if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
@@ -150,8 +94,6 @@ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, const _Callable&
}
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -29,16 +29,6 @@ struct _LIBCPP_EXPORTED_FROM_ABI adopt_lock_t {
explicit adopt_lock_t() = default;
};
#if _LIBCPP_STD_VER >= 17
inline constexpr defer_lock_t defer_lock = defer_lock_t();
inline constexpr try_to_lock_t try_to_lock = try_to_lock_t();
inline constexpr adopt_lock_t adopt_lock = adopt_lock_t();
#elif !defined(_LIBCPP_CXX03_LANG)
constexpr defer_lock_t defer_lock = defer_lock_t();
constexpr try_to_lock_t try_to_lock = try_to_lock_t();
constexpr adopt_lock_t adopt_lock = adopt_lock_t();
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___CXX03___MUTEX_TAG_TYPES_H

View File

@@ -26,11 +26,7 @@ template <class _InputIterator, class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) {
for (; __first != __last; ++__first)
#if _LIBCPP_STD_VER >= 20
__init = std::move(__init) + *__first;
#else
__init = __init + *__first;
#endif
return __init;
}
@@ -38,11 +34,7 @@ template <class _InputIterator, class _Tp, class _BinaryOperation>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op) {
for (; __first != __last; ++__first)
#if _LIBCPP_STD_VER >= 20
__init = __binary_op(std::move(__init), *__first);
#else
__init = __binary_op(__init, *__first);
#endif
return __init;
}

View File

@@ -31,11 +31,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
*__result = __acc;
for (++__first, (void)++__result; __first != __last; ++__first, (void)++__result) {
typename iterator_traits<_InputIterator>::value_type __val(*__first);
#if _LIBCPP_STD_VER >= 20
*__result = __val - std::move(__acc);
#else
*__result = __val - __acc;
#endif
__acc = std::move(__val);
}
}
@@ -50,11 +46,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator adjacent_dif
*__result = __acc;
for (++__first, (void)++__result; __first != __last; ++__first, (void)++__result) {
typename iterator_traits<_InputIterator>::value_type __val(*__first);
#if _LIBCPP_STD_VER >= 20
*__result = __binary_op(__val, std::move(__acc));
#else
*__result = __binary_op(__val, __acc);
#endif
__acc = std::move(__val);
}
}

Some files were not shown because too many files have changed in this diff Show More