aboutsummaryrefslogtreecommitdiff
path: root/system/include/libcxx/vector
diff options
context:
space:
mode:
Diffstat (limited to 'system/include/libcxx/vector')
-rw-r--r--system/include/libcxx/vector93
1 files changed, 73 insertions, 20 deletions
diff --git a/system/include/libcxx/vector b/system/include/libcxx/vector
index 876b7e56..d1bc23e6 100644
--- a/system/include/libcxx/vector
+++ b/system/include/libcxx/vector
@@ -481,7 +481,7 @@ __vector_base<_Tp, _Allocator>::~__vector_base()
}
template <class _Tp, class _Allocator = allocator<_Tp> >
-class _LIBCPP_VISIBLE vector
+class _LIBCPP_TYPE_VIS vector
: private __vector_base<_Tp, _Allocator>
{
private:
@@ -502,6 +502,9 @@ public:
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");
+
_LIBCPP_INLINE_VISIBILITY
vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
@@ -523,17 +526,29 @@ public:
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value>::type* = 0);
+ !__is_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value>::type* = 0);
+ !__is_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
+ typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
+ typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il);
@@ -574,14 +589,20 @@ public:
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ !__is_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value,
void
>::type
assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
void
>::type
assign(_ForwardIterator __first, _ForwardIterator __last);
@@ -697,14 +718,20 @@ public:
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ !__is_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value,
iterator
>::type
insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
iterator
>::type
insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
@@ -1031,7 +1058,10 @@ template <class _Tp, class _Allocator>
template <class _InputIterator>
vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value>::type*)
+ !__is_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value>::type*)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1044,7 +1074,10 @@ template <class _Tp, class _Allocator>
template <class _InputIterator>
vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value>::type*)
+ !__is_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_InputIterator>::reference>::value>::type*)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1057,7 +1090,10 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
+ typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1073,7 +1109,10 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
- typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
+ typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ value_type,
+ typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1255,7 +1294,10 @@ template <class _InputIterator>
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ !__is_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ _Tp,
+ typename iterator_traits<_InputIterator>::reference>::value,
void
>::type
vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
@@ -1269,7 +1311,10 @@ template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ _Tp,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
void
>::type
vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
@@ -1550,6 +1595,8 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
"vector::erase(iterator) called with an iterator not"
" referring to this vector");
#endif
+ _LIBCPP_ASSERT(__position != end(),
+ "vector::erase(iterator) called with a non-dereferenceable iterator");
pointer __p = const_cast<pointer>(&*__position);
iterator __r = __make_iter(__p);
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
@@ -1748,7 +1795,10 @@ template <class _InputIterator>
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
- !__is_forward_iterator<_InputIterator>::value,
+ !__is_forward_iterator<_InputIterator>::value &&
+ is_constructible<
+ _Tp,
+ typename iterator_traits<_InputIterator>::reference>::value,
typename vector<_Tp, _Allocator>::iterator
>::type
vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
@@ -1800,7 +1850,10 @@ template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
- __is_forward_iterator<_ForwardIterator>::value,
+ __is_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<
+ _Tp,
+ typename iterator_traits<_ForwardIterator>::reference>::value,
typename vector<_Tp, _Allocator>::iterator
>::type
vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
@@ -1963,7 +2016,7 @@ struct __has_storage_type<vector<bool, _Allocator> >
};
template <class _Allocator>
-class _LIBCPP_VISIBLE vector<bool, _Allocator>
+class _LIBCPP_TYPE_VIS vector<bool, _Allocator>
: private __vector_base_common<true>
{
public:
@@ -2321,7 +2374,7 @@ private:
friend class __bit_iterator<vector, false>;
friend class __bit_iterator<vector, true>;
friend struct __bit_array<vector>;
- friend struct _LIBCPP_VISIBLE hash<vector>;
+ friend struct _LIBCPP_TYPE_VIS hash<vector>;
};
template <class _Allocator>
@@ -3104,7 +3157,7 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
}
template <class _Allocator>
-struct _LIBCPP_VISIBLE hash<vector<bool, _Allocator> >
+struct _LIBCPP_TYPE_VIS hash<vector<bool, _Allocator> >
: public unary_function<vector<bool, _Allocator>, size_t>
{
_LIBCPP_INLINE_VISIBILITY