aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/vector
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-10 17:53:52 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-10 17:53:52 +0300
commit5c64b97bb7e4034eff8833e4c367f61d34fcb4ee (patch)
tree7c5769528f2fcdaa5a718aa73e4aa64d50905269 /contrib/libs/cxxsupp/libcxx/include/vector
parent1b56f620ac98766b198121ca1b728e7e61efbb56 (diff)
downloadydb-5c64b97bb7e4034eff8833e4c367f61d34fcb4ee.tar.gz
intermediate changes
ref:4635f4dd763168c3fa295f87727595c785b4d5a4
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/vector')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/vector364
1 files changed, 164 insertions, 200 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector
index c02253c751..ce52a88570 100644
--- a/contrib/libs/cxxsupp/libcxx/include/vector
+++ b/contrib/libs/cxxsupp/libcxx/include/vector
@@ -245,7 +245,7 @@ public:
template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
vector(InputIterator, InputIterator, Allocator = Allocator())
- -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
+ -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
template <class Allocator> struct hash<std::vector<bool, Allocator>>;
@@ -275,6 +275,7 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
#include <__bit_reference>
#include <__debug>
#include <__functional_base>
+#include <__iterator/iterator_traits.h>
#include <__iterator/wrap_iter.h>
#include <__split_buffer>
#include <__utility/forward.h>
@@ -315,192 +316,60 @@ template <class _Tp, class _Allocator>
class __vector_base
: protected __vector_base_common<true> // This base class is historical, but it needs to remain for ABI compatibility
{
-public:
- typedef _Allocator allocator_type;
- typedef allocator_traits<allocator_type> __alloc_traits;
- typedef typename __alloc_traits::size_type size_type;
+ typedef _Allocator allocator_type;
+ typedef typename allocator_traits<allocator_type>::pointer pointer;
protected:
- typedef _Tp value_type;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef typename __alloc_traits::difference_type difference_type;
- typedef typename __alloc_traits::pointer pointer;
- typedef typename __alloc_traits::const_pointer const_pointer;
- typedef pointer iterator;
- typedef const_pointer const_iterator;
-
- pointer __begin_;
- pointer __end_;
- __compressed_pair<pointer, allocator_type> __end_cap_;
-
- _LIBCPP_INLINE_VISIBILITY
- allocator_type& __alloc() _NOEXCEPT
- {return __end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY
- const allocator_type& __alloc() const _NOEXCEPT
- {return __end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY
- pointer& __end_cap() _NOEXCEPT
- {return __end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
- const pointer& __end_cap() const _NOEXCEPT
- {return __end_cap_.first();}
+ pointer __begin_;
+ pointer __end_;
+ __compressed_pair<pointer, allocator_type> __end_cap_;
_LIBCPP_INLINE_VISIBILITY
__vector_base()
- _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a);
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT;
-#endif
- ~__vector_base();
+ : __begin_(nullptr),
+ __end_(nullptr),
+ __end_cap_(nullptr, __default_init_tag()) {}
- _LIBCPP_INLINE_VISIBILITY
- void clear() _NOEXCEPT {__destruct_at_end(__begin_);}
- _LIBCPP_INLINE_VISIBILITY
- size_type capacity() const _NOEXCEPT
- {return static_cast<size_type>(__end_cap() - __begin_);}
-
- _LIBCPP_INLINE_VISIBILITY
- void __destruct_at_end(pointer __new_last) _NOEXCEPT;
-
- _LIBCPP_INLINE_VISIBILITY
- void __copy_assign_alloc(const __vector_base& __c)
- {__copy_assign_alloc(__c, integral_constant<bool,
- __alloc_traits::propagate_on_container_copy_assignment::value>());}
-
- _LIBCPP_INLINE_VISIBILITY
- void __move_assign_alloc(__vector_base& __c)
- _NOEXCEPT_(
- !__alloc_traits::propagate_on_container_move_assignment::value ||
- is_nothrow_move_assignable<allocator_type>::value)
- {__move_assign_alloc(__c, integral_constant<bool,
- __alloc_traits::propagate_on_container_move_assignment::value>());}
-
- _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
- void __throw_length_error() const {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- __vector_base_common<true>::__throw_length_error();
-#else
- _VSTD::abort();
-#endif
- }
-
- _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
- void __throw_out_of_range() const {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- __vector_base_common<true>::__throw_out_of_range();
-#else
- _VSTD::abort();
-#endif
- }
-
-private:
- _LIBCPP_INLINE_VISIBILITY
- void __copy_assign_alloc(const __vector_base& __c, true_type)
- {
- if (__alloc() != __c.__alloc())
- {
- clear();
- __alloc_traits::deallocate(__alloc(), __begin_, capacity());
- __begin_ = __end_ = __end_cap() = nullptr;
- }
- __alloc() = __c.__alloc();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void __copy_assign_alloc(const __vector_base&, false_type)
- {}
-
- _LIBCPP_INLINE_VISIBILITY
- void __move_assign_alloc(__vector_base& __c, true_type)
- _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
- {
- __alloc() = _VSTD::move(__c.__alloc());
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void __move_assign_alloc(__vector_base&, false_type)
- _NOEXCEPT
- {}
-};
-
-template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-__vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
-{
- pointer __soon_to_be_end = __end_;
- while (__new_last != __soon_to_be_end)
- __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end));
- __end_ = __new_last;
-}
-
-template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-__vector_base<_Tp, _Allocator>::__vector_base()
- _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
- : __begin_(nullptr),
- __end_(nullptr),
- __end_cap_(nullptr, __default_init_tag())
-{
-}
-
-template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-__vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a)
- : __begin_(nullptr),
- __end_(nullptr),
- __end_cap_(nullptr, __a)
-{
-}
+ _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a)
+ : __begin_(nullptr),
+ __end_(nullptr),
+ __end_cap_(nullptr, __a) {}
#ifndef _LIBCPP_CXX03_LANG
-template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
-__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT
- : __begin_(nullptr),
- __end_(nullptr),
- __end_cap_(nullptr, _VSTD::move(__a)) {}
+ _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT
+ : __begin_(nullptr),
+ __end_(nullptr),
+ __end_cap_(nullptr, _VSTD::move(__a)) {}
#endif
-
-template <class _Tp, class _Allocator>
-__vector_base<_Tp, _Allocator>::~__vector_base()
-{
- if (__begin_ != nullptr)
- {
- clear();
- __alloc_traits::deallocate(__alloc(), __begin_, capacity());
- }
-}
+};
template <class _Tp, class _Allocator /* = allocator<_Tp> */>
class _LIBCPP_TEMPLATE_VIS vector
+ // This base class is historical, but it needs to remain for ABI compatibility.
: private __vector_base<_Tp, _Allocator>
{
private:
- typedef __vector_base<_Tp, _Allocator> __base;
- typedef allocator<_Tp> __default_allocator_type;
+ typedef __vector_base<_Tp, _Allocator> __base;
+ typedef allocator<_Tp> __default_allocator_type;
public:
- typedef vector __self;
- typedef _Tp value_type;
- typedef _Allocator allocator_type;
- typedef typename __base::__alloc_traits __alloc_traits;
- typedef typename __base::reference reference;
- typedef typename __base::const_reference const_reference;
- typedef typename __base::size_type size_type;
- typedef typename __base::difference_type difference_type;
- typedef typename __base::pointer pointer;
- typedef typename __base::const_pointer const_pointer;
+ typedef vector __self;
+ typedef _Tp value_type;
+ typedef _Allocator allocator_type;
+ typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef typename __allocator_traits<allocator_type>::size_type size_type;
+ typedef typename __alloc_traits::difference_type difference_type;
+ typedef typename __alloc_traits::pointer pointer;
+ typedef typename __alloc_traits::const_pointer const_pointer;
#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 1
- typedef typename __base::pointer iterator;
- typedef typename __base::const_pointer const_iterator;
+ typedef pointer iterator;
+ typedef const_pointer const_iterator;
#else
- typedef __wrap_iter<pointer> iterator;
- typedef __wrap_iter<const_pointer> const_iterator;
+ typedef __wrap_iter<pointer> iterator;
+ typedef __wrap_iter<const_pointer> const_iterator;
#endif
- typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
- typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
+ typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
@@ -562,10 +431,16 @@ public:
_LIBCPP_INLINE_VISIBILITY
~vector()
{
- __annotate_delete();
+ __annotate_delete();
#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__erase_c(this);
+ __get_db()->__erase_c(this);
#endif
+
+ if (this->__begin_ != nullptr)
+ {
+ __clear();
+ __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());
+ }
}
vector(const vector& __x);
@@ -670,7 +545,7 @@ public:
{return static_cast<size_type>(this->__end_ - this->__begin_);}
_LIBCPP_INLINE_VISIBILITY
size_type capacity() const _NOEXCEPT
- {return __base::capacity();}
+ {return static_cast<size_type>(__end_cap() - this->__begin_);}
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{return this->__begin_ == this->__end_;}
@@ -783,7 +658,7 @@ public:
void clear() _NOEXCEPT
{
size_type __old_size = size();
- __base::clear();
+ __clear();
__annotate_shrink(__old_size);
__invalidate_all_iterators();
}
@@ -849,7 +724,7 @@ private:
{
__invalidate_iterators_past(__new_last);
size_type __old_size = size();
- __base::__destruct_at_end(__new_last);
+ __base_destruct_at_end(__new_last);
__annotate_shrink(__old_size);
}
@@ -921,7 +796,7 @@ private:
struct _ConstructTransaction {
explicit _ConstructTransaction(vector &__v, size_type __n)
- : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
+ : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
#ifndef _LIBCPP_HAS_NO_ASAN
__v_.__annotate_increase(__n);
#endif
@@ -952,11 +827,95 @@ private:
_VSTD::forward<_Args>(__args)...);
++__tx.__pos_;
}
+
+ _LIBCPP_INLINE_VISIBILITY
+ allocator_type& __alloc() _NOEXCEPT
+ {return this->__end_cap_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ const allocator_type& __alloc() const _NOEXCEPT
+ {return this->__end_cap_.second();}
+ _LIBCPP_INLINE_VISIBILITY
+ pointer& __end_cap() _NOEXCEPT
+ {return this->__end_cap_.first();}
+ _LIBCPP_INLINE_VISIBILITY
+ const pointer& __end_cap() const _NOEXCEPT
+ {return this->__end_cap_.first();}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
+ pointer __soon_to_be_end = this->__end_;
+ while (__new_last != __soon_to_be_end)
+ __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end));
+ this->__end_ = __new_last;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector& __c)
+ {__copy_assign_alloc(__c, integral_constant<bool,
+ __alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector& __c)
+ _NOEXCEPT_(
+ !__alloc_traits::propagate_on_container_move_assignment::value ||
+ is_nothrow_move_assignable<allocator_type>::value)
+ {__move_assign_alloc(__c, integral_constant<bool,
+ __alloc_traits::propagate_on_container_move_assignment::value>());}
+
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
+ void __throw_length_error() const {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ __vector_base_common<true>::__throw_length_error();
+#else
+ _VSTD::abort();
+#endif
+ }
+
+ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
+ void __throw_out_of_range() const {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ __vector_base_common<true>::__throw_out_of_range();
+#else
+ _VSTD::abort();
+#endif
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector& __c, true_type)
+ {
+ if (__alloc() != __c.__alloc())
+ {
+ __clear();
+ __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());
+ this->__begin_ = this->__end_ = __end_cap() = nullptr;
+ }
+ __alloc() = __c.__alloc();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __copy_assign_alloc(const vector&, false_type)
+ {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+ {
+ __alloc() = _VSTD::move(__c.__alloc());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __move_assign_alloc(vector&, false_type)
+ _NOEXCEPT
+ {}
};
#if _LIBCPP_STD_VER >= 17
template<class _InputIterator,
class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
class = enable_if_t<__is_allocator<_Alloc>::value>
>
vector(_InputIterator, _InputIterator)
@@ -964,6 +923,7 @@ vector(_InputIterator, _InputIterator)
template<class _InputIterator,
class _Alloc,
+ class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
class = enable_if_t<__is_allocator<_Alloc>::value>
>
vector(_InputIterator, _InputIterator, _Alloc)
@@ -1331,7 +1291,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
{
#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_c(this);
- __get_db()->swap(this, &__x);
+ __get_db()->swap(this, _VSTD::addressof(__x));
#endif
this->__begin_ = __x.__begin_;
this->__end_ = __x.__end_;
@@ -1354,7 +1314,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>
this->__end_cap() = __x.__end_cap();
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, &__x);
+ __get_db()->swap(this, _VSTD::addressof(__x));
#endif
}
else
@@ -1409,7 +1369,7 @@ void
vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value)
{
- if (__base::__alloc() != __c.__alloc())
+ if (__alloc() != __c.__alloc())
{
typedef move_iterator<iterator> _Ip;
assign(_Ip(__c.begin()), _Ip(__c.end()));
@@ -1424,13 +1384,13 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__vdeallocate();
- __base::__move_assign_alloc(__c); // this can throw
+ __move_assign_alloc(__c); // this can throw
this->__begin_ = __c.__begin_;
this->__end_ = __c.__end_;
this->__end_cap() = __c.__end_cap();
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, &__c);
+ __get_db()->swap(this, _VSTD::addressof(__c));
#endif
}
@@ -1443,7 +1403,7 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)
{
if (this != _VSTD::addressof(__x))
{
- __base::__copy_assign_alloc(__x);
+ __copy_assign_alloc(__x);
assign(__x.__begin_, __x.__end_);
}
return *this;
@@ -1625,6 +1585,8 @@ vector<_Tp, _Allocator>::reserve(size_type __n)
{
if (__n > capacity())
{
+ if (__n > max_size())
+ this->__throw_length_error();
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__n, size(), __a);
__swap_out_circular_buffer(__v);
@@ -1749,7 +1711,7 @@ typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __position)
{
#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::erase(iterator) called with an iterator not"
" referring to this vector");
#endif
@@ -1768,11 +1730,11 @@ typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
- "vector::erase(iterator, iterator) called with an iterator not"
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this,
+ "vector::erase(iterator, iterator) called with an iterator not"
" referring to this vector");
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this,
- "vector::erase(iterator, iterator) called with an iterator not"
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this,
+ "vector::erase(iterator, iterator) called with an iterator not"
" referring to this vector");
#endif
_LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
@@ -1809,7 +1771,7 @@ typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
{
#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::insert(iterator, x) called with an iterator not"
" referring to this vector");
#endif
@@ -1846,7 +1808,7 @@ typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
{
#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::insert(iterator, x) called with an iterator not"
" referring to this vector");
#endif
@@ -1879,7 +1841,7 @@ typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
{
#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::emplace(iterator, x) called with an iterator not"
" referring to this vector");
#endif
@@ -1914,7 +1876,7 @@ typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
{
#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::insert(iterator, n, x) called with an iterator not"
" referring to this vector");
#endif
@@ -1965,7 +1927,7 @@ typename enable_if
vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
{
#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::insert(iterator, range) called with an iterator not"
" referring to this vector");
#endif
@@ -2018,7 +1980,7 @@ typename enable_if
vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
{
#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::insert(iterator, range) called with an iterator not"
" referring to this vector");
#endif
@@ -2116,7 +2078,7 @@ vector<_Tp, _Allocator>::swap(vector& __x)
_VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->swap(this, &__x);
+ __get_db()->swap(this, _VSTD::addressof(__x));
#endif
}
@@ -3016,7 +2978,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
__size_ = __n;
else
{
- vector __v(__alloc());
+ vector __v(get_allocator());
__v.reserve(__recommend(__n));
__v.__size_ = __n;
swap(__v);
@@ -3071,7 +3033,9 @@ vector<bool, _Allocator>::reserve(size_type __n)
{
if (__n > capacity())
{
- vector __v(this->__alloc());
+ if (__n > max_size())
+ this->__throw_length_error();
+ vector __v(this->get_allocator());
__v.__vallocate(__n);
__v.__construct_at_end(this->begin(), this->end());
swap(__v);
@@ -3141,7 +3105,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
}
else
{
- vector __v(__alloc());
+ vector __v(get_allocator());
__v.reserve(__recommend(__size_ + 1));
__v.__size_ = __size_ + 1;
__r = _VSTD::copy(cbegin(), __position, __v.begin());
@@ -3167,7 +3131,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
}
else
{
- vector __v(__alloc());
+ vector __v(get_allocator());
__v.reserve(__recommend(__size_ + __n));
__v.__size_ = __size_ + __n;
__r = _VSTD::copy(cbegin(), __position, __v.begin());
@@ -3196,7 +3160,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
++this->__size_;
back() = *__first;
}
- vector __v(__alloc());
+ vector __v(get_allocator());
if (__first != __last)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -3246,7 +3210,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
}
else
{
- vector __v(__alloc());
+ vector __v(get_allocator());
__v.reserve(__recommend(__size_ + __n));
__v.__size_ = __size_ + __n;
__r = _VSTD::copy(cbegin(), __position, __v.begin());
@@ -3313,7 +3277,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
}
else
{
- vector __v(__alloc());
+ vector __v(get_allocator());
__v.reserve(__recommend(__size_ + __n));
__v.__size_ = __size_ + __n;
__r = _VSTD::copy(cbegin(), cend(), __v.begin());