summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/vector
diff options
context:
space:
mode:
authormikhnenko <[email protected]>2024-01-26 10:38:46 +0300
committermikhnenko <[email protected]>2024-01-26 11:13:08 +0300
commit885b105cca4721eee2ee14d6b83d856dac3739ef (patch)
treec40b876bba01bcb469aadd981ef6d9dcbbbd589d /contrib/libs/cxxsupp/libcxx/include/vector
parent15e6154017194456fd8a7a76513e14aa4ae5f5d1 (diff)
Update libcxx to 02 June 2023 185b81e034ba60081023b6e59504dfffb560f3e3 (llvmorg-16.0.5)
:warning: Для всех проектов и мимо проходящим коллегам :warning: Если по каким-то причинам ваши тесты подломались, пожалуйста, переканонизируйте их сами. По статистике там просто поменялся порядок в канонизации. Если изменения действительно серьезные -- приходите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/createTicket?queue=DEVTOOLSSUPPORT) / пишите в телеграм / призывайте в тикеты, будем разбираться. ``` Changes: [libc++] Don't try to provide source_location on AppleClang 1403 [release/16.x][libc++] Revert the bitset sort optimization [libc++] Avoid ODR violations in __exception_guard [libc++][ranges] Fix incorrect integer typedef in `elements_view` test. [libc++][format] Fix a missing include in tests. [libc++][format] Fixes invalid usage of m type. [libc++][format] Fix floating point formatting. [libc++] Fix ranges::binary_search() returning true for cases where the element is not in the range [libc++] Temporarily not use compiler intrinsics for some type traits in Objective-C++ mode. [libc++][ranges] move all range iterators back in class [libcxx][ranges] revert join_view::iterator and sentinel to be in-class [libc++] Add FTM for views::as_rvalue [libc++] Fix bug in allocate_shared_for_overwrite [libc++] fix `shared_ptr`'s incorrect constraints [libc++] In tests, use `abort` to terminate upon an error. [libc++] Guard the fix to CityHash behind ABI v2 [libc++][format] Fixes constexpr validation. [libc++] Remove use of internal glibc macros to determine if c8rtomb() and mbrtoc8() are present. [libc++] Fixes the Clang modular build. [libc++][ranges] Temporarily mark `ranges::join_view` as experimental. libcxx: Don't apply ABI tags to extern "C" fns [libc++] Introduce a compile-time mechanism to override __libcpp_verbose_abort [libc++][format] Fixes usage of contiguous ranges. [libc++][doc] Updates format status. [libc++][ranges] implement `std::ranges::split_view` [libc++] implement P1020R1 P1973R1 make_unique[shared]_for_overwrite [libc++] Improve binary size when using __transaction [libc++] Rename take_while_view::__sentinel to __take_while_view_sentinel [libc++] Granularize <type_traits> includes in <bit>, <numbers> and <coroutine> [libc++] Implement P1413R3 (Deprecate std::aligned_storage and std::aligned_union) [libc++] Add FreeBSD XFAILs in preparation for CI [libc++] add FreeBSD atomic wait support [libc++][format] range-default-formatter for set. [libc++] Move iota_view::iterator and sentinel out of iota_view [libc++] Enable clang-tidy from the buildkite pipeline instead of hard-coding it in run-buildbot [libc++] Enable segmented iterator optimizations for join_view::iterator [libc++] Mark LWG3349 as complete [libc++] Remove old CI configurations and update the supported compiler versions [libc++] Implement P2446R2 (views::as_rvalue) [libc++][format] range-default-formatter for map [libc++][format] Adds formatter std::vector<bool>. [libc++][format] Adds container adaptor formatters. [libc++][format] Implements range_formatter [libc++][format] Adds new test macros. [libc++][ranges] Remove a leftover include version control markers in Cxx20Papers.csv [libc++][ranges] Mark completed Ranges papers and issues as done, bump version macro [libc++] Add ALLOW_RETRIES to a few flaky tests [SystemZ][z/OS] Fix cityhash lit for EBCDIC [libc++] Mark std::pmr virtual functions as _LIBCPP_HIDE_FROM_ABI_VIRTUAL [libc++] Remove <type_traits> includes from <atomic> and <ratio> [libcxx] Add missing includes [libc++] allow redefined macro in non_trivial_copy_move_ABI test [libc++][ranges] implement `std::views::elements_view` [libc++] Add [[clang::lifetimebound]] attribute to std::forward and friends Reapply "[libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`" [libc++] Add clang-tidy to the list of possible substitutions for %{clang-tidy} [libc++] Add missing includes in move_iterator.h [libc++] Make pmr::monotonic_buffer_resource bump down [libc++] Add [[nodiscard]] extensions in <math.h> [libc++] Fix ranges::uninitialized_move{, _n} for move-only types [libc++][ranges] Fix incorrect integer type in `view_interface` tests. [libc++] Hold mutex lock while notify_all is called at notify_all_at_thread_exit [Libcxx] Add <source_location> header. [libc++] Rename transform_view::{__iterator, __sentinel} to __transform_view_{iterator, sentinel} [libc++] Add FreeBSD exceptions.nonew ABI list [libc++][format] Fixes escaping string literals. [libc++] Use _LIBCPP_HIDE_FROM_ABI_VIRTUAL instead of _LIBCPP_INLINE_VISIBILITY attribute on virtual function [libc++][test] Move `common_input_iterator` to `test_iterators.h` [libc++][utils] Remove unused import in `run.py` [libc++] Remove warning for `LIBCXX_SYSROOT`, `LIBCXX_TARGET_TRIPLE`, and `LIBCXX_GCC_TOOLCHAIN` [libc++] Fix aligned_alloc usage for Android [libc++] Use %{clang-query} when calling clang-query [libc++] Add missing include in __format/unicode.h [libc++] Remove HIDE_FROM_ABI from virtual functions [libc++] Fix transitive includes list for C++23 [libc++] Add _LIBCPP_HIDE_FROM_ABI to __constexpr_logb and __constexpr_scalbn [libc++] Granularize <bit> and remove <__bits> [libc++] [C++20] [P0415] Constexpr for std::complex. libc++: bring back the unsigned in the return type in wcstoull_l [libc++][CI] Improves clang-(tidy|query) selection. [libc++] Granularize <type_traits> includes in <iterator> [libc++] Implement constexpr {isfinite, isinf, isnan, isnormal} [libc++][chrono] Add calendar type formatters. [libc++] LWG3738 Validates a missing precondition. [libc++] LWG3745 noexcept for atomic_wait. [libc++] Granularize <type_traits> includes in <compare> std::sort: add BlockQuickSort partitioning algorithm for arithmetic types [libc++] Granularize <type_traits> includes in <utility> [libc++][format] Removes test redundancy. [libc++][format] Adds formatter for tuple and pair [libc++] Use aligned_alloc instead of posix_memalign for C++17 [libc++] Rename __tuple to __tuple_dir to avoid file collision [libc++] Add FreeBSD ABI list [libc++] Adds __cpp_lib_constexpr_algorithms to utility. [libc++] Granularize <type_traits> includes in <concepts [libc++][format] Renames __null_sentinel. Implementstd::ranges::view_interface::size returns a signed type [libc++] Implement P1169R4 (static operator()) [libc++] Implement `std::expected` P0323R12 [libc++][Android] Disable pbump2gig for Android [libc++][Android] Android/Bionic headers don't work with modules yet [libc++][math.h] Add double overloads [libc++] Move filter_view::iterator and sentinel out of filter_view [libc++] Implement P0339R6 (polymorphic_allocator<> as a vocabulary type) [libc++][format] Adds range-default-formatter. [libc++][Android] Rename user NS to User to avoid conflict with struct [libc++] Fix memory leaks when throwing inside std::vector constructors ```
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/vector')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/vector145
1 files changed, 111 insertions, 34 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector
index 53bb94c828e..32ee8cd450b 100644
--- a/contrib/libs/cxxsupp/libcxx/include/vector
+++ b/contrib/libs/cxxsupp/libcxx/include/vector
@@ -267,6 +267,13 @@ template <class T, class Allocator, class Predicate>
typename vector<T, Allocator>::size_type
erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
+
+template<class T>
+ inline constexpr bool is-vector-bool-reference = see below; // exposition only, since C++23
+
+template<class T, class charT> requires is-vector-bool-reference<T> // Since C++23
+ struct formatter<T, charT>;
+
} // std
*/
@@ -281,9 +288,11 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
#include <__algorithm/unwrap_iter.h>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__bit_reference>
+#include <__concepts/same_as.h>
#include <__config>
#include <__debug>
#include <__format/enable_insertable.h>
+#include <__format/formatter.h>
#include <__functional/hash.h>
#include <__functional/unary_function.h>
#include <__iterator/advance.h>
@@ -299,6 +308,7 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
#include <__split_buffer>
#include <__type_traits/is_allocator.h>
#include <__type_traits/noexcept_move_assign_container.h>
+#include <__utility/exception_guard.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/swap.h>
@@ -428,18 +438,27 @@ public:
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
- _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
- ~vector()
- {
- __annotate_delete();
- std::__debug_db_erase_c(this);
+private:
+ class __destroy_vector {
+ public:
+ _LIBCPP_CONSTEXPR __destroy_vector(vector& __vec) : __vec_(__vec) {}
- if (this->__begin_ != nullptr)
- {
- __clear();
- __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
+ __vec_.__annotate_delete();
+ std::__debug_db_erase_c(std::addressof(__vec_));
+
+ if (__vec_.__begin_ != nullptr) {
+ __vec_.__clear();
+ __alloc_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.capacity());
+ }
}
- }
+
+ private:
+ vector& __vec_;
+ };
+
+public:
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector(*this)(); }
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x);
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
@@ -1080,12 +1099,14 @@ template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(size_type __n)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n);
}
+ __guard.__complete();
}
#if _LIBCPP_STD_VER > 11
@@ -1094,12 +1115,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n);
}
+ __guard.__complete();
}
#endif
@@ -1107,12 +1130,14 @@ template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n, __x);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
@@ -1122,9 +1147,11 @@ template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<
_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
for (; __first != __last; ++__first)
emplace_back(*__first);
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
@@ -1135,9 +1162,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
for (; __first != __last; ++__first)
emplace_back(*__first);
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
@@ -1147,6 +1176,7 @@ template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_For
_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n > 0)
@@ -1154,6 +1184,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
__vallocate(__n);
__construct_at_end(__first, __last, __n);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
@@ -1164,6 +1195,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n > 0)
@@ -1171,6 +1203,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
__vallocate(__n);
__construct_at_end(__first, __last, __n);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
@@ -1178,6 +1211,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(const vector& __x)
: __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
size_type __n = __x.size();
if (__n > 0)
@@ -1185,6 +1219,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
__vallocate(__n);
__construct_at_end(__x.__begin_, __x.__end_, __n);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
@@ -1192,6 +1227,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
: __end_cap_(nullptr, __a)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
size_type __n = __x.size();
if (__n > 0)
@@ -1199,6 +1235,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<alloc
__vallocate(__n);
__construct_at_end(__x.__begin_, __x.__end_, __n);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
@@ -1238,7 +1275,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_
else
{
typedef move_iterator<iterator> _Ip;
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
assign(_Ip(__x.begin()), _Ip(__x.end()));
+ __guard.__complete();
}
}
@@ -1249,12 +1288,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20
inline _LIBCPP_HIDE_FROM_ABI
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
if (__il.size() > 0)
{
__vallocate(__il.size());
__construct_at_end(__il.begin(), __il.end(), __il.size());
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
@@ -1263,12 +1304,14 @@ inline _LIBCPP_HIDE_FROM_ABI
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
std::__debug_db_insert_c(this);
if (__il.size() > 0)
{
__vallocate(__il.size());
__construct_at_end(__il.begin(), __il.end(), __il.size());
}
+ __guard.__complete();
}
#endif // _LIBCPP_CXX03_LANG
@@ -1923,18 +1966,6 @@ vector<_Tp, _Allocator>::resize(size_type __sz)
this->__destruct_at_end(this->__begin_ + __sz);
}
-template <class _Tp, class _Allocator>
-_LIBCPP_CONSTEXPR_SINCE_CXX20
-void
-vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
-{
- size_type __cs = size();
- if (__cs < __sz)
- this->__append(__sz - __cs, __x);
- else if (__cs > __sz)
- this->__destruct_at_end(this->__begin_ + __sz);
-}
-
#if _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED
template <class _Tp, class _Allocator>
@@ -1955,6 +1986,18 @@ vector<_Tp, _Allocator>::resize_uninitialized(size_type __sz)
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20
void
+vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
+{
+ size_type __cs = size();
+ if (__cs < __sz)
+ this->__append(__sz - __cs, __x);
+ else if (__cs > __sz)
+ this->__destruct_at_end(this->__begin_ + __sz);
+}
+
+template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+void
vector<_Tp, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
@@ -2132,7 +2175,25 @@ public:
#else
_NOEXCEPT;
#endif
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector();
+
+private:
+ class __destroy_vector {
+ public:
+ _LIBCPP_CONSTEXPR __destroy_vector(vector& __vec) : __vec_(__vec) {}
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
+ if (__vec_.__begin_ != nullptr)
+ __storage_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.__cap());
+ std::__debug_db_invalidate_all(this);
+ }
+
+ private:
+ vector& __vec_;
+ };
+
+public:
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector(*this)(); }
+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a);
@@ -2668,12 +2729,14 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
__size_(0),
__cap_alloc_(0, __default_init_tag())
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last);
}
+ __guard.__complete();
}
template <class _Allocator>
@@ -2685,12 +2748,14 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last);
}
+ __guard.__complete();
}
#ifndef _LIBCPP_CXX03_LANG
@@ -2729,15 +2794,6 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
template <class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20
-vector<bool, _Allocator>::~vector()
-{
- if (__begin_ != nullptr)
- __storage_traits::deallocate(__alloc(), __begin_, __cap());
- std::__debug_db_invalidate_all(this);
-}
-
-template <class _Allocator>
-_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(const vector& __v)
: __begin_(nullptr),
__size_(0),
@@ -3355,14 +3411,35 @@ erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
}
template <>
-inline constexpr bool __format::__enable_insertable<std::vector<char>> = true;
+inline constexpr bool __format::__enable_insertable<vector<char>> = true;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true;
+inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;
#endif
#endif // _LIBCPP_STD_VER > 17
+#if _LIBCPP_STD_VER > 20
+template <class _Tp, class CharT>
+// Since is-vector-bool-reference is only used once it's inlined here.
+ requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_Tp, CharT> {
+private:
+ formatter<bool, CharT> __underlying_;
+
+public:
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return __underlying_.parse(__ctx);
+ }
+
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const {
+ return __underlying_.format(__ref, __ctx);
+ }
+};
+#endif // _LIBCPP_STD_VER > 20
+
_LIBCPP_END_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14