[cfe-commits] [libcxx] r140023 - /libcxx/trunk/include/vector

Howard Hinnant hhinnant at apple.com
Mon Sep 19 09:34:29 PDT 2011


Author: hhinnant
Date: Mon Sep 19 11:34:29 2011
New Revision: 140023

URL: http://llvm.org/viewvc/llvm-project?rev=140023&view=rev
Log:
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.

Modified:
    libcxx/trunk/include/vector

Modified: libcxx/trunk/include/vector
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=140023&r1=140022&r2=140023&view=diff
==============================================================================
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Mon Sep 19 11:34:29 2011
@@ -1106,8 +1106,8 @@
     : __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 @@
         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 @@
     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





More information about the cfe-commits mailing list