libstdc++/51960 move-construction for raw_storage_iterator
authorJonathan Wakely <jwakely@redhat.com>
Fri, 26 Aug 2016 13:11:29 +0000 (14:11 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 26 Aug 2016 13:11:29 +0000 (14:11 +0100)
PR libstdc++/51960
* doc/xml/manual/intro.xml: Document DR 2127 change.
* doc/html/*: Regenerate.
* include/bits/stl_raw_storage_iter.h (operator=(_Tp&&)): Add.
(operator++(), operator++(int)): Use injected class name.
* testsuite/20_util/raw_storage_iterator/dr2127.cc: New test.

From-SVN: r239781

libstdc++-v3/ChangeLog
libstdc++-v3/doc/html/manual/bugs.html
libstdc++-v3/doc/xml/manual/intro.xml
libstdc++-v3/include/bits/stl_raw_storage_iter.h
libstdc++-v3/testsuite/20_util/raw_storage_iterator/dr2127.cc [new file with mode: 0644]

index 594b9725c50c5ec0f8bda75a3b0221c250916b2b..6b21648fcbd28a259eca1ea829040a7859d76aa9 100644 (file)
@@ -1,5 +1,12 @@
 2016-08-26  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/51960
+       * doc/xml/manual/intro.xml: Document DR 2127 change.
+       * doc/html/*: Regenerate.
+       * include/bits/stl_raw_storage_iter.h (operator=(_Tp&&)): Add.
+       (operator++(), operator++(int)): Use injected class name.
+       * testsuite/20_util/raw_storage_iterator/dr2127.cc: New test.
+
        * testsuite/*: Use { target c++11 } or { target c++14 } instead of
        using -std in dg-options.
 
index 14ba1d2506ae758bf477ea0bfa813e2cc0f70972..de2ad5f1182b41ef10a1ab756139b62c6c87db9c 100644 (file)
     </p></dd><dt><span class="term"><a class="link" href="../ext/lwg-defects.html#2118" target="_top">2118</a>:
        <span class="emphasis"><em><code class="code">unique_ptr</code> for array does not support cv qualification conversion of actual argument</em></span>
     </span></dt><dd><p>Adjust constraints to allow safe conversions.
+    </p></dd><dt><span class="term"><a class="link" href="../ext/lwg-defects.html#2127" target="_top">2127</a>:
+       <span class="emphasis"><em>Move-construction with <code class="code">raw_storage_iterator</code></em></span>
+    </span></dt><dd><p>Add assignment operator taking an rvalue.
     </p></dd><dt><span class="term"><a class="link" href="../ext/lwg-defects.html#2132" target="_top">2132</a>:
        <span class="emphasis"><em><code class="code">std::function</code> ambiguity</em></span>
     </span></dt><dd><p>Constrain the constructor to only accept callable types.
index d02306edbf67be8b7c6380c04219a387d03f38ef..238ab241080ea756341b884f452d46da02969fef 100644 (file)
@@ -898,6 +898,12 @@ requirements of the license of GCC.
     <listitem><para>Adjust constraints to allow safe conversions.
     </para></listitem></varlistentry>
 
+    <varlistentry><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="../ext/lwg-defects.html#2127">2127</link>:
+       <emphasis>Move-construction with <code>raw_storage_iterator</code></emphasis>
+    </term>
+    <listitem><para>Add assignment operator taking an rvalue.
+    </para></listitem></varlistentry>
+
     <varlistentry><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="../ext/lwg-defects.html#2132">2132</link>:
        <emphasis><code>std::function</code> ambiguity</emphasis>
     </term>
index 8b5e793dbc4add795a7c7c0454654629341100e5..2d29e7cf53345a98bdd61f6b93ae8252eb46e0d1 100644 (file)
@@ -86,17 +86,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        return *this;
       }
 
-      raw_storage_iterator<_OutputIterator, _Tp>&
+#if __cplusplus >= 201103L
+      // _GLIBCXX_RESOLVE_LIB_DEFECTS
+      // 2127. Move-construction with raw_storage_iterator
+      raw_storage_iterator&
+      operator=(_Tp&& __element)
+      {
+       std::_Construct(std::__addressof(*_M_iter), std::move(__element));
+       return *this;
+      }
+#endif
+
+      raw_storage_iterator&
       operator++()
       {
        ++_M_iter;
        return *this;
       }
 
-      raw_storage_iterator<_OutputIterator, _Tp>
+      raw_storage_iterator
       operator++(int)
       {
-       raw_storage_iterator<_OutputIterator, _Tp> __tmp = *this;
+       raw_storage_iterator __tmp = *this;
        ++_M_iter;
        return __tmp;
       }
diff --git a/libstdc++-v3/testsuite/20_util/raw_storage_iterator/dr2127.cc b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/dr2127.cc
new file mode 100644 (file)
index 0000000..9a084f6
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct MoveOnly
+{
+  MoveOnly(int i) : i(i) { }
+  MoveOnly(MoveOnly&&) = default;
+  int i;
+};
+
+void
+test01()
+{
+  char buf[sizeof(MoveOnly)*2];
+  MoveOnly* addr = (MoveOnly*)buf;
+  std::raw_storage_iterator<MoveOnly*, MoveOnly> iter(addr);
+  *iter++ = MoveOnly{1};
+  *iter++ = MoveOnly{2};
+  VERIFY( addr[0].i == 1 );
+  VERIFY( addr[1].i == 2 );
+}
+
+int
+main()
+{
+  test01();
+}