summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2011-09-19 16:34:29 +0000
committerHoward Hinnant <hhinnant@apple.com>2011-09-19 16:34:29 +0000
commitc756bb3574e437ec57a8777aee16d579afc91565 (patch)
treecba20d62bfd97f4fb070c1b11618d7496c647845
parenta195a5182c7e3111ad5a0ae1f59f5d6b016ef6d3 (diff)
downloadbcm5719-llvm-c756bb3574e437ec57a8777aee16d579afc91565.tar.gz
bcm5719-llvm-c756bb3574e437ec57a8777aee16d579afc91565.zip
Chris Jefferson noted that vector iterator ownership can be transferred from source to target under move construction and move assignment. This commit makes that happen for debug mode.
llvm-svn: 140023
-rw-r--r--libcxx/include/vector9
1 files changed, 7 insertions, 2 deletions
diff --git a/libcxx/include/vector b/libcxx/include/vector
index f469a3a0de5..b334074d0b9 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -1106,8 +1106,8 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
: __base(_VSTD::move(__x.__alloc()))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
- __x.__invalidate_all_iterators();
__get_db()->__insert_c(this);
+ __get_db()->swap(this, &__x);
#endif
this->__begin_ = __x.__begin_;
this->__end_ = __x.__end_;
@@ -1129,7 +1129,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
this->__end_ = __x.__end_;
this->__end_cap() = __x.__end_cap();
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
- __x.__invalidate_all_iterators();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->swap(this, &__x);
+#endif
}
else
{
@@ -1208,6 +1210,9 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
this->__end_cap() = __c.__end_cap();
__base::__move_assign_alloc(__c);
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->swap(this, &__c);
+#endif
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
OpenPOWER on IntegriCloud