The vector test suite now passes for no-debug, debug-lite and debug-regular
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@139930 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/vector b/include/vector
index 5c3a697..f469a3a 100644
--- a/include/vector
+++ b/include/vector
@@ -970,41 +970,41 @@
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
if (__n > 0)
{
allocate(__n);
__construct_at_end(__n);
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
if (__n > 0)
{
allocate(__n);
__construct_at_end(__n, __x);
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const allocator_type& __a)
: __base(__a)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
if (__n > 0)
{
allocate(__n);
__construct_at_end(__n, __x);
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
template <class _Tp, class _Allocator>
@@ -1013,11 +1013,11 @@
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value>::type*)
{
- for (; __first != __last; ++__first)
- push_back(*__first);
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
+ for (; __first != __last; ++__first)
+ push_back(*__first);
}
template <class _Tp, class _Allocator>
@@ -1027,11 +1027,11 @@
!__is_forward_iterator<_InputIterator>::value>::type*)
: __base(__a)
{
- for (; __first != __last; ++__first)
- push_back(*__first);
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
+ for (; __first != __last; ++__first)
+ push_back(*__first);
}
template <class _Tp, class _Allocator>
@@ -1039,15 +1039,15 @@
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n > 0)
{
allocate(__n);
__construct_at_end(__first, __last);
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
template <class _Tp, class _Allocator>
@@ -1056,45 +1056,45 @@
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
: __base(__a)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n > 0)
{
allocate(__n);
__construct_at_end(__first, __last);
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(const vector& __x)
: __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc()))
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
size_type __n = __x.size();
if (__n > 0)
{
allocate(__n);
__construct_at_end(__x.__begin_, __x.__end_);
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
: __base(__a)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
size_type __n = __x.size();
if (__n > 0)
{
allocate(__n);
__construct_at_end(__x.__begin_, __x.__end_);
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1105,14 +1105,14 @@
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
: __base(_VSTD::move(__x.__alloc()))
{
- this->__begin_ = __x.__begin_;
- this->__end_ = __x.__end_;
- this->__end_cap() = __x.__end_cap();
- __x.__begin_ = __x.__end_ = __x.__end_cap() = 0;
#if _LIBCPP_DEBUG_LEVEL >= 2
__x.__invalidate_all_iterators();
__get_db()->__insert_c(this);
#endif
+ this->__begin_ = __x.__begin_;
+ this->__end_ = __x.__end_;
+ this->__end_cap() = __x.__end_cap();
+ __x.__begin_ = __x.__end_ = __x.__end_cap() = 0;
}
template <class _Tp, class _Allocator>
@@ -1120,6 +1120,9 @@
vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
: __base(__a)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
if (__a == __x.__alloc())
{
this->__begin_ = __x.__begin_;
@@ -1133,9 +1136,6 @@
typedef move_iterator<iterator> _I;
assign(_I(__x.begin()), _I(__x.end()));
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -1144,14 +1144,14 @@
_LIBCPP_INLINE_VISIBILITY inline
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
if (__il.size() > 0)
{
allocate(__il.size());
__construct_at_end(__il.begin(), __il.end());
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
template <class _Tp, class _Allocator>
@@ -1159,14 +1159,14 @@
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __base(__a)
{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+#endif
if (__il.size() > 0)
{
allocate(__il.size());
__construct_at_end(__il.begin(), __il.end());
}
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -1747,8 +1747,8 @@
#endif // _LIBCPP_NO_EXCEPTIONS
}
__p = _VSTD::rotate(__p, __old_last, this->__end_);
- insert(__make_iter(__p), move_iterator<iterator>(__v.begin()),
- move_iterator<iterator>(__v.end()));
+ insert(__make_iter(__p), make_move_iterator(__v.begin()),
+ make_move_iterator(__v.end()));
return begin() + __off;
}