summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include/vector
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-09-16 22:26:52 +0000
committerdim <dim@FreeBSD.org>2015-09-16 22:26:52 +0000
commitea5248cdc11d47e16b420831d52143ca4afb904a (patch)
treeaaccdba1a8c990ea730287a164e76e70733b424a /contrib/libc++/include/vector
parent5cc32d7f18f18fb3a5f4155b7f748cc7be60d2da (diff)
parent50ffe587e08aebe69879f2e5b67ba1304ff781b3 (diff)
downloadFreeBSD-src-ea5248cdc11d47e16b420831d52143ca4afb904a.zip
FreeBSD-src-ea5248cdc11d47e16b420831d52143ca4afb904a.tar.gz
Update libc++ to 3.7.0 release.
Diffstat (limited to 'contrib/libc++/include/vector')
-rw-r--r--contrib/libc++/include/vector185
1 files changed, 92 insertions, 93 deletions
diff --git a/contrib/libc++/include/vector b/contrib/libc++/include/vector
index 22a6343..c168c8e 100644
--- a/contrib/libc++/include/vector
+++ b/contrib/libc++/include/vector
@@ -119,8 +119,8 @@ public:
void resize(size_type sz, const value_type& c);
void swap(vector&)
- noexcept(!allocator_type::propagate_on_container_swap::value ||
- __is_nothrow_swappable<allocator_type>::value);
+ noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
+ allocator_traits<allocator_type>::is_always_equal::value); // C++17
bool __invariants() const;
};
@@ -237,8 +237,8 @@ public:
void resize(size_type sz, value_type x);
void swap(vector&)
- noexcept(!allocator_type::propagate_on_container_swap::value ||
- __is_nothrow_swappable<allocator_type>::value);
+ noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
+ allocator_traits<allocator_type>::is_always_equal::value); // C++17
void flip() noexcept;
bool __invariants() const;
@@ -385,14 +385,6 @@ protected:
is_nothrow_move_assignable<allocator_type>::value)
{__move_assign_alloc(__c, integral_constant<bool,
__alloc_traits::propagate_on_container_move_assignment::value>());}
-
- _LIBCPP_INLINE_VISIBILITY
- static void __swap_alloc(allocator_type& __x, allocator_type& __y)
- _NOEXCEPT_(
- !__alloc_traits::propagate_on_container_swap::value ||
- __is_nothrow_swappable<allocator_type>::value)
- {__swap_alloc(__x, __y, integral_constant<bool,
- __alloc_traits::propagate_on_container_swap::value>());}
private:
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __vector_base& __c, true_type)
@@ -421,18 +413,6 @@ private:
void __move_assign_alloc(__vector_base&, false_type)
_NOEXCEPT
{}
-
- _LIBCPP_INLINE_VISIBILITY
- static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type)
- _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
- {
- using _VSTD::swap;
- swap(__x, __y);
- }
- _LIBCPP_INLINE_VISIBILITY
- static void __swap_alloc(allocator_type&, allocator_type&, false_type)
- _NOEXCEPT
- {}
};
template <class _Tp, class _Allocator>
@@ -500,14 +480,18 @@ public:
"Allocator::value_type must be same type as value_type");
_LIBCPP_INLINE_VISIBILITY
- vector()
- _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
}
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+ _NOEXCEPT
+#endif
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -569,7 +553,11 @@ public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT;
+#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#endif
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
@@ -756,8 +744,12 @@ public:
void resize(size_type __sz, const_reference __x);
void swap(vector&)
- _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
- __is_nothrow_swappable<allocator_type>::value);
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value);
+#endif
bool __invariants() const;
@@ -783,7 +775,7 @@ private:
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
- __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+ __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
void __append(size_type __n);
void __append(size_type __n, const_reference __x);
_LIBCPP_INLINE_VISIBILITY
@@ -868,17 +860,17 @@ private:
// but if an exception is thrown after that the annotation has to be undone.
struct __RAII_IncreaseAnnotator {
__RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1)
- : __commit(false), __v(__v), __n(__n) {
+ : __commit(false), __v(__v), __old_size(__v.size() + __n) {
__v.__annotate_increase(__n);
}
void __done() { __commit = true; }
~__RAII_IncreaseAnnotator() {
if (__commit) return;
- __v.__annotate_shrink(__v.size() + __n);
+ __v.__annotate_shrink(__old_size);
}
bool __commit;
- size_type __n;
const vector &__v;
+ size_type __old_size;
};
#else
struct __RAII_IncreaseAnnotator {
@@ -1021,16 +1013,12 @@ typename enable_if
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
-vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
+vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
{
allocator_type& __a = this->__alloc();
- for (; __first != __last; ++__first)
- {
- __RAII_IncreaseAnnotator __annotator(*this);
- __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
- __annotator.__done();
- ++this->__end_;
- }
+ __RAII_IncreaseAnnotator __annotator(*this, __n);
+ __alloc_traits::__construct_range_forward(__a, __first, __last, this->__end_);
+ __annotator.__done();
}
// Default constructs __n objects starting at __end_
@@ -1177,7 +1165,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
if (__n > 0)
{
allocate(__n);
- __construct_at_end(__first, __last);
+ __construct_at_end(__first, __last, __n);
}
}
@@ -1197,7 +1185,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
if (__n > 0)
{
allocate(__n);
- __construct_at_end(__first, __last);
+ __construct_at_end(__first, __last, __n);
}
}
@@ -1212,7 +1200,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
if (__n > 0)
{
allocate(__n);
- __construct_at_end(__x.__begin_, __x.__end_);
+ __construct_at_end(__x.__begin_, __x.__end_, __n);
}
}
@@ -1227,7 +1215,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
if (__n > 0)
{
allocate(__n);
- __construct_at_end(__x.__begin_, __x.__end_);
+ __construct_at_end(__x.__begin_, __x.__end_, __n);
}
}
@@ -1236,7 +1224,11 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT
+#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#endif
: __base(_VSTD::move(__x.__alloc()))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1286,7 +1278,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
if (__il.size() > 0)
{
allocate(__il.size());
- __construct_at_end(__il.begin(), __il.end());
+ __construct_at_end(__il.begin(), __il.end(), __il.size());
}
}
@@ -1301,7 +1293,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
if (__il.size() > 0)
{
allocate(__il.size());
- __construct_at_end(__il.begin(), __il.end());
+ __construct_at_end(__il.begin(), __il.end(), __il.size());
}
}
@@ -1394,12 +1386,12 @@ typename enable_if
>::type
vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
{
- typename iterator_traits<_ForwardIterator>::difference_type __new_size = _VSTD::distance(__first, __last);
- if (static_cast<size_type>(__new_size) <= capacity())
+ size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last));
+ if (__new_size <= capacity())
{
_ForwardIterator __mid = __last;
bool __growing = false;
- if (static_cast<size_type>(__new_size) > size())
+ if (__new_size > size())
{
__growing = true;
__mid = __first;
@@ -1407,15 +1399,15 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
}
pointer __m = _VSTD::copy(__first, __mid, this->__begin_);
if (__growing)
- __construct_at_end(__mid, __last);
+ __construct_at_end(__mid, __last, __new_size - size());
else
this->__destruct_at_end(__m);
}
else
{
deallocate();
- allocate(__recommend(static_cast<size_type>(__new_size)));
- __construct_at_end(__first, __last);
+ allocate(__recommend(__new_size));
+ __construct_at_end(__first, __last, __new_size);
}
}
@@ -1967,8 +1959,9 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
if (__n > __dx)
{
__m = __first;
- _VSTD::advance(__m, this->__end_ - __p);
- __construct_at_end(__m, __last);
+ difference_type __diff = this->__end_ - __p;
+ _VSTD::advance(__m, __diff);
+ __construct_at_end(__m, __last, __n - __diff);
__n = __dx;
}
if (__n > 0)
@@ -2015,8 +2008,12 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::swap(vector& __x)
- _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
- __is_nothrow_swappable<allocator_type>::value)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value)
+#endif
{
_LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
this->__alloc() == __x.__alloc(),
@@ -2025,7 +2022,8 @@ vector<_Tp, _Allocator>::swap(vector& __x)
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__end_, __x.__end_);
_VSTD::swap(this->__end_cap(), __x.__end_cap());
- __base::__swap_alloc(this->__alloc(), __x.__alloc());
+ __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);
#endif // _LIBCPP_DEBUG_LEVEL >= 2
@@ -2128,13 +2126,7 @@ public:
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
private:
- typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
- rebind_alloc<__storage_type>
-#else
- rebind_alloc<__storage_type>::other
-#endif
- __storage_allocator;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;
typedef allocator_traits<__storage_allocator> __storage_traits;
typedef typename __storage_traits::pointer __storage_pointer;
typedef typename __storage_traits::const_pointer __const_storage_pointer;
@@ -2170,9 +2162,14 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY
- vector()
- _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a);
+ vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+
+ _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
+#else
+ _NOEXCEPT;
+#endif
~vector();
explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
@@ -2206,7 +2203,11 @@ public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __v)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT;
+#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#endif
vector(vector&& __v, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __v)
@@ -2354,8 +2355,12 @@ public:
void clear() _NOEXCEPT {__size_ = 0;}
void swap(vector&)
- _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
- __is_nothrow_swappable<allocator_type>::value);
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT;
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value);
+#endif
void resize(size_type __sz, value_type __x = false);
void flip() _NOEXCEPT;
@@ -2433,26 +2438,6 @@ private:
_NOEXCEPT
{}
- _LIBCPP_INLINE_VISIBILITY
- static void __swap_alloc(__storage_allocator& __x, __storage_allocator& __y)
- _NOEXCEPT_(
- !__storage_traits::propagate_on_container_swap::value ||
- __is_nothrow_swappable<allocator_type>::value)
- {__swap_alloc(__x, __y, integral_constant<bool,
- __storage_traits::propagate_on_container_swap::value>());}
-
- _LIBCPP_INLINE_VISIBILITY
- static void __swap_alloc(__storage_allocator& __x, __storage_allocator& __y, true_type)
- _NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value)
- {
- using _VSTD::swap;
- swap(__x, __y);
- }
- _LIBCPP_INLINE_VISIBILITY
- static void __swap_alloc(__storage_allocator&, __storage_allocator&, false_type)
- _NOEXCEPT
- {}
-
size_t __hash_code() const _NOEXCEPT;
friend class __bit_reference<vector>;
@@ -2559,7 +2544,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>::vector()
- _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0)
@@ -2569,6 +2554,11 @@ vector<bool, _Allocator>::vector()
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>::vector(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+#else
+ _NOEXCEPT
+#endif
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
@@ -2807,7 +2797,11 @@ vector<bool, _Allocator>::operator=(const vector& __v)
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>::vector(vector&& __v)
+#if _LIBCPP_STD_VER > 14
+ _NOEXCEPT
+#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#endif
: __begin_(__v.__begin_),
__size_(__v.__size_),
__cap_alloc_(__v.__cap_alloc_)
@@ -3150,13 +3144,18 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
template <class _Allocator>
void
vector<bool, _Allocator>::swap(vector& __x)
- _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
- __is_nothrow_swappable<allocator_type>::value)
+#if _LIBCPP_STD_VER >= 14
+ _NOEXCEPT
+#else
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+ __is_nothrow_swappable<allocator_type>::value)
+#endif
{
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__size_, __x.__size_);
_VSTD::swap(this->__cap(), __x.__cap());
- __swap_alloc(this->__alloc(), __x.__alloc());
+ __swap_allocator(this->__alloc(), __x.__alloc(),
+ integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
}
template <class _Allocator>
OpenPOWER on IntegriCloud