[libcxx] r251247 - Fix LWG#2127: Move-construction with raw_storage_iterator.

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 25 11:58:07 PDT 2015


Author: marshall
Date: Sun Oct 25 13:58:07 2015
New Revision: 251247

URL: http://llvm.org/viewvc/llvm-project?rev=251247&view=rev
Log:
Fix LWG#2127: Move-construction with raw_storage_iterator.

Modified:
    libcxx/trunk/include/memory
    libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
    libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=251247&r1=251246&r2=251247&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Sun Oct 25 13:58:07 2015
@@ -1909,6 +1909,10 @@ public:
     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}
     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)
         {::new(&*__x_) _Tp(__element); return *this;}
+#if _LIBCPP_STD_VER >= 14
+    _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element)
+        {::new(&*__x_) _Tp(_VSTD::move(__element)); return *this;}
+#endif
     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator  operator++(int)
         {raw_storage_iterator __t(*this); ++__x_; return __t;}

Modified: libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp?rev=251247&r1=251246&r2=251247&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp Sun Oct 25 13:58:07 2015
@@ -13,6 +13,8 @@
 #include <type_traits>
 #include <cassert>
 
+#include <MoveOnly.h>
+
 int A_constructed = 0;
 
 struct A
@@ -29,16 +31,33 @@ public:
 
 int main()
 {
-    typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
+    {
+    typedef A S;
+    typedef std::aligned_storage<3*sizeof(S), std::alignment_of<S>::value>::type
             Storage;
     Storage buffer;
-    std::raw_storage_iterator<A*, A> it((A*)&buffer);
+    std::raw_storage_iterator<S*, S> it((S*)&buffer);
     assert(A_constructed == 0);
     for (int i = 0; i < 3; ++i)
     {
-        *it++ = A(i+1);
-        A* ap = (A*)&buffer + i;
+        *it++ = S(i+1);
+        S* ap = (S*)&buffer + i;
         assert(*ap == i+1);
         assert(A_constructed == i+1);
     }
+    }
+#if _LIBCPP_STD_VER >= 14
+    {
+    typedef MoveOnly S;
+    typedef std::aligned_storage<3*sizeof(S), std::alignment_of<S>::value>::type
+            Storage;
+    Storage buffer;
+    std::raw_storage_iterator<S*, S> it((S*)&buffer);
+    S m{1};
+    *it++ = std::move(m);
+    assert(m.get() == 0); // moved from
+    S *ap = (S*) &buffer;
+    assert(ap->get() == 1); // original value
+    }
+#endif
 }

Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=251247&r1=251246&r2=251247&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Sun Oct 25 13:58:07 2015
@@ -152,7 +152,7 @@
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2101">2101</a></td><td>Some transformation types can produce impossible types</td><td>Kona</td><td></td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2111">2111</a></td><td>Which <tt>unexpected</tt>/<tt>terminate</tt> handler is called from the exception handling runtime?</td><td>Kona</td><td>Complete</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2119">2119</a></td><td>Missing <tt>hash</tt> specializations for extended integer types</td><td>Kona</td><td></td></tr>
-	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2127">2127</a></td><td>Move-construction with <tt>raw_storage_iterator</tt></td><td>Kona</td><td>Patch Ready</td></tr>
+	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2127">2127</a></td><td>Move-construction with <tt>raw_storage_iterator</tt></td><td>Kona</td><td>Complete</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2133">2133</a></td><td>Attitude to overloaded comma for iterators</td><td>Kona</td><td>Complete</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2156">2156</a></td><td>Unordered containers' <tt>reserve(n)</tt> reserves for <tt>n-1</tt> elements</td><td>Kona</td><td></td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2218">2218</a></td><td>Unclear how containers use <tt>allocator_traits::construct()</tt></td><td>Kona</td><td></td></tr>




More information about the cfe-commits mailing list