diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2023-10-11 11:15:58 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2023-10-11 12:05:11 +0300 |
commit | 84c5d4bb733b49d5f9f36dbf0c22ec200d9e6334 (patch) | |
tree | 8dc43a7531874e613966d58a48af6acda89954fe /contrib/libs/cxxsupp/libcxx/include/vector | |
parent | b95dc8e862f26368aa0275e2571eefe238c1951e (diff) | |
download | ydb-84c5d4bb733b49d5f9f36dbf0c22ec200d9e6334.tar.gz |
Upd libc++ to 0cc34ca7ecfc9d0efee322f60ed6c3169f4f70ca (12 Apr 2022)
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/vector')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/vector | 86 |
1 files changed, 46 insertions, 40 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector index d340417601..1e9e9984da 100644 --- a/contrib/libs/cxxsupp/libcxx/include/vector +++ b/contrib/libs/cxxsupp/libcxx/include/vector @@ -279,13 +279,15 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 #include <__algorithm/remove_if.h> #include <__algorithm/rotate.h> #include <__algorithm/unwrap_iter.h> -#include <__assert> +#include <__assert> // all public C++ headers provide the assertion handler #include <__bit_reference> #include <__config> #include <__debug> +#include <__format/enable_insertable.h> #include <__functional/hash.h> #include <__iterator/iterator_traits.h> #include <__iterator/wrap_iter.h> +#include <__memory/allocate_at_least.h> #include <__split_buffer> #include <__utility/forward.h> #include <__utility/move.h> @@ -681,7 +683,25 @@ private: _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); - void __vallocate(size_type __n); + + + // Allocate space for __n objects + // throws length_error if __n > max_size() + // throws (probably bad_alloc) if memory run out + // Precondition: __begin_ == __end_ == __end_cap() == 0 + // Precondition: __n > 0 + // Postcondition: capacity() >= __n + // Postcondition: size() == 0 + _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { + if (__n > max_size()) + __throw_length_error(); + auto __allocation = std::__allocate_at_least(__alloc(), __n); + __begin_ = __allocation.ptr; + __end_ = __allocation.ptr; + __end_cap() = __begin_ + __allocation.count; + __annotate_new(0); + } + void __vdeallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; void __construct_at_end(size_type __n); @@ -943,24 +963,6 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a return __r; } -// Allocate space for __n objects -// throws length_error if __n > max_size() -// throws (probably bad_alloc) if memory run out -// Precondition: __begin_ == __end_ == __end_cap() == 0 -// Precondition: __n > 0 -// Postcondition: capacity() == __n -// Postcondition: size() == 0 -template <class _Tp, class _Allocator> -void -vector<_Tp, _Allocator>::__vallocate(size_type __n) -{ - if (__n > max_size()) - this->__throw_length_error(); - this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n); - this->__end_cap() = this->__begin_ + __n; - __annotate_new(0); -} - template <class _Tp, class _Allocator> void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT @@ -2381,8 +2383,23 @@ private: _VSTD::__throw_out_of_range("vector"); } + // Allocate space for __n objects + // throws length_error if __n > max_size() + // throws (probably bad_alloc) if memory run out + // Precondition: __begin_ == __end_ == __cap() == 0 + // Precondition: __n > 0 + // Postcondition: capacity() >= __n + // Postcondition: size() == 0 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); - void __vallocate(size_type __n); + _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { + if (__n > max_size()) + __throw_length_error(); + auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n)); + __begin_ = __allocation.ptr; + __size_ = 0; + __cap() = __allocation.count; + } + void __vdeallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY static size_type __align_it(size_type __new_size) _NOEXCEPT @@ -2468,25 +2485,6 @@ vector<bool, _Allocator>::__invalidate_all_iterators() { } -// Allocate space for __n objects -// throws length_error if __n > max_size() -// throws (probably bad_alloc) if memory run out -// Precondition: __begin_ == __end_ == __cap() == 0 -// Precondition: __n > 0 -// Postcondition: capacity() == __n -// Postcondition: size() == 0 -template <class _Allocator> -void -vector<bool, _Allocator>::__vallocate(size_type __n) -{ - if (__n > max_size()) - this->__throw_length_error(); - __n = __external_cap_to_internal(__n); - this->__begin_ = __storage_traits::allocate(this->__alloc(), __n); - this->__size_ = 0; - this->__cap() = __n; -} - template <class _Allocator> void vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT @@ -3383,8 +3381,16 @@ erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) { __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); return __old_size - __c.size(); } + +template <> +inline constexpr bool __format::__enable_insertable<std::vector<char>> = true; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +template <> +inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true; #endif +#endif // _LIBCPP_STD_VER > 17 + _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS |