Implement P0084R2, Emplace return type, for C++17
authorJonathan Wakely <jwakely@redhat.com>
Mon, 17 Oct 2016 12:00:38 +0000 (13:00 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 17 Oct 2016 12:00:38 +0000 (13:00 +0100)
* doc/xml/manual/status_cxx2017.xml: Update status.
* doc/html/*: Regenerate.
* include/bits/deque.tcc (deque::emplace_front, deque::emplace_back):
Return a reference in C++17 mode.
* include/bits/forward_list.h (forward_list::emplace_front): Likewise.
* include/bits/stl_bvector.h (vector<bool>::emplace_back): Likewise.
* include/bits/stl_deque.h (deque::emplace_front, deque::emplace_back):
Likewise.
* include/bits/stl_list.h (list::emplace_front, list::emplace_back):
Likewise.
* include/bits/stl_queue.h (queue::emplace): Likewise.
* include/bits/stl_stack.h (stack::emplace): Likewise.
* include/bits/stl_vector.h (vector::emplace_back): Likewise.
* include/bits/vector.tcc (vector::emplace_back): Likewise.
* include/debug/deque (__gnu_debug::deque::emplace_front)
(__gnu_debug::deque::emplace_back): Likewise.
* include/debug/vector (__gnu_debug::vector::emplace_back): Likewise.
* testsuite/23_containers/deque/modifiers/emplace/cxx17_return.cc:
New.
* testsuite/23_containers/forward_list/modifiers/
emplace_cxx17_return.cc: New.
* testsuite/23_containers/list/modifiers/emplace/cxx17_return.cc: New.
* testsuite/23_containers/queue/members/emplace_cxx17_return.cc: New.
* testsuite/23_containers/stack/members/emplace_cxx17_return.cc: New.
* testsuite/23_containers/vector/bool/emplace_cxx17_return.cc: New.
* testsuite/23_containers/vector/modifiers/emplace/cxx17_return.cc:
New.

From-SVN: r241234

22 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/doc/html/manual/status.html
libstdc++-v3/doc/html/manual/test.html
libstdc++-v3/doc/xml/manual/status_cxx2017.xml
libstdc++-v3/include/bits/deque.tcc
libstdc++-v3/include/bits/forward_list.h
libstdc++-v3/include/bits/stl_bvector.h
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/include/bits/stl_list.h
libstdc++-v3/include/bits/stl_queue.h
libstdc++-v3/include/bits/stl_stack.h
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/bits/vector.tcc
libstdc++-v3/include/debug/deque
libstdc++-v3/include/debug/vector
libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/cxx17_return.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/modifiers/emplace_cxx17_return.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/cxx17_return.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/queue/members/emplace_cxx17_return.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/stack/members/emplace_cxx17_return.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/bool/emplace_cxx17_return.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/cxx17_return.cc [new file with mode: 0644]

index 5f72a961ca9f88bbe18a9a8e365127e99d1cd672..b31c1dd331a4a804519d26ce2429eb6de34796a5 100644 (file)
@@ -1,3 +1,33 @@
+2016-10-17  Jonathan Wakely  <jwakely@redhat.com>
+
+       * doc/xml/manual/status_cxx2017.xml: Update status.
+       * doc/html/*: Regenerate.
+       * include/bits/deque.tcc (deque::emplace_front, deque::emplace_back):
+       Return a reference in C++17 mode.
+       * include/bits/forward_list.h (forward_list::emplace_front): Likewise.
+       * include/bits/stl_bvector.h (vector<bool>::emplace_back): Likewise.
+       * include/bits/stl_deque.h (deque::emplace_front, deque::emplace_back):
+       Likewise.
+       * include/bits/stl_list.h (list::emplace_front, list::emplace_back):
+       Likewise.
+       * include/bits/stl_queue.h (queue::emplace): Likewise.
+       * include/bits/stl_stack.h (stack::emplace): Likewise.
+       * include/bits/stl_vector.h (vector::emplace_back): Likewise.
+       * include/bits/vector.tcc (vector::emplace_back): Likewise.
+       * include/debug/deque (__gnu_debug::deque::emplace_front)
+       (__gnu_debug::deque::emplace_back): Likewise.
+       * include/debug/vector (__gnu_debug::vector::emplace_back): Likewise.
+       * testsuite/23_containers/deque/modifiers/emplace/cxx17_return.cc:
+       New.
+       * testsuite/23_containers/forward_list/modifiers/
+       emplace_cxx17_return.cc: New.
+       * testsuite/23_containers/list/modifiers/emplace/cxx17_return.cc: New.
+       * testsuite/23_containers/queue/members/emplace_cxx17_return.cc: New.
+       * testsuite/23_containers/stack/members/emplace_cxx17_return.cc: New.
+       * testsuite/23_containers/vector/bool/emplace_cxx17_return.cc: New.
+       * testsuite/23_containers/vector/modifiers/emplace/cxx17_return.cc:
+       New.
+
 2016-10-16  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * testsuite/22_locale/classification/isblank.cc: Remove 'test'
index 5ef66daa49469da13b05d948440c615c080e8223..7a79f0d83b0f9e7f0a5a1e9c5d9891c006a87566 100644 (file)
@@ -706,11 +706,11 @@ Feature-testing recommendations for C++</a>.
        </a>
       </td><td align="center"> 6.2 (3.0)</td><td align="left"><code class="code"> __cpp_lib_incomplete_container_elements &gt;= 201505 </code>
             (the feature was always supported, but the macro was not defined until GCC 6.2)
-      </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Emplace return type </td><td align="left">
+      </td></tr><tr><td align="left"> Emplace return type </td><td align="left">
        <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0084r2.pdf" target="_top">
        P0084R2
        </a>
-      </td><td align="center"> No </td><td align="left"> </td></tr><tr><td align="left">Improved insertion interface for unique-key maps</td><td align="left">
+      </td><td align="center"> 7 </td><td align="left"> </td></tr><tr><td align="left">Improved insertion interface for unique-key maps</td><td align="left">
        <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4279.html" target="_top">
          N4279
        </a>
index 9e5b64fa151f10e467882cc84e38ed97856bf53f..f37d7be8a47aa61f1e13d49ad09a13822f9cd51d 100644 (file)
@@ -322,7 +322,7 @@ cat 27_io/objects/char/3_xin.in | a.out</pre></dd><dt><span class="term"><code c
       <span class="command"><strong>make</strong></span>, or via options for the DejaGnu test framework
       (described below). The latter approach uses the
       <code class="option">--target_board</code> option that was shown earlier.
-      For example, to run the tests with <code class="option">-O1 -D_GLIBCXX_ASSERT</code>
+      For example, to run the tests with <code class="option">-O1 -D_GLIBCXX_ASSERTIONS</code>
       you could use:
 </p><pre class="programlisting">    make RUNTESTFLAGS=--target_board=unix/-O1/-D_GLIBCXX_ASSERTIONS</pre><p>
     </p><p>
index ae8dfa9529be332f6b2edde69b48c760a5d755cd..a1190bc1afa529e2cf1b7a4452777603b13324f9 100644 (file)
@@ -542,14 +542,13 @@ Feature-testing recommendations for C++</link>.
     </row>
 
     <row>
-      <?dbhtml bgcolor="#C8B0B0" ?>
       <entry> Emplace return type </entry>
       <entry>
        <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0084r2.pdf">
        P0084R2
        </link>
       </entry>
-      <entry align="center"> No </entry>
+      <entry align="center"> 7 </entry>
       <entry/>
     </row>
 
index 96ec9f82d8f0c7254aebe7d2fa209b3c06b09d03..796b0cd9239cce1950c04246c9c503920b68bb1b 100644 (file)
@@ -129,7 +129,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 #if __cplusplus >= 201103L
   template<typename _Tp, typename _Alloc>
     template<typename... _Args>
+#if __cplusplus > 201402L
+      typename deque<_Tp, _Alloc>::reference
+#else
       void
+#endif
       deque<_Tp, _Alloc>::
       emplace_front(_Args&&... __args)
       {
@@ -142,11 +146,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
          }
        else
          _M_push_front_aux(std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+       return front();
+#endif
       }
 
   template<typename _Tp, typename _Alloc>
     template<typename... _Args>
+#if __cplusplus > 201402L
+      typename deque<_Tp, _Alloc>::reference
+#else
       void
+#endif
       deque<_Tp, _Alloc>::
       emplace_back(_Args&&... __args)
       {
@@ -160,6 +171,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
          }
        else
          _M_push_back_aux(std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+       return back();
+#endif
       }
 #endif
 
index 39615094131386a539072c2d94b3e09364752efc..0ea88063d7ed0a87449e6a7acdf2a0c0db3cab96 100644 (file)
@@ -797,10 +797,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  and references.
        */
       template<typename... _Args>
-        void
+#if __cplusplus > 201402L
+        reference
+#else
+       void
+#endif
         emplace_front(_Args&&... __args)
-        { this->_M_insert_after(cbefore_begin(),
-                                std::forward<_Args>(__args)...); }
+        {
+         this->_M_insert_after(cbefore_begin(),
+                                std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+         return front();
+#endif
+       }
 
       /**
        *  @brief  Add data to the front of the %forward_list.
index b3ac63f521fdc834063da1bdc2356f2a1842bf69..2e231b9d86bb582069954abd6c21894fe9279b76 100644 (file)
@@ -1056,9 +1056,18 @@ template<typename _Alloc>
 
 #if __cplusplus >= 201103L
     template<typename... _Args>
+#if __cplusplus > 201402L
+      reference
+#else
       void
+#endif
       emplace_back(_Args&&... __args)
-      { push_back(bool(__args...)); }
+      {
+       push_back(bool(__args...));
+#if __cplusplus > 201402L
+       return back();
+#endif
+      }
 
     template<typename... _Args>
       iterator
index 7192f65a1c0312d58c89414f0c88f2c2cb48baf9..8539a08f3a9e4a9c5e03bb4f9efb5cbd209868e2 100644 (file)
@@ -1519,7 +1519,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { emplace_front(std::move(__x)); }
 
       template<typename... _Args>
-        void
+#if __cplusplus > 201402L
+       reference
+#else
+       void
+#endif
         emplace_front(_Args&&... __args);
 #endif
 
@@ -1552,7 +1556,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { emplace_back(std::move(__x)); }
 
       template<typename... _Args>
-        void
+#if __cplusplus > 201402L
+       reference
+#else
+       void
+#endif
         emplace_back(_Args&&... __args);
 #endif
 
index 87c8a393d7c8f1eb04353033aa47ab53f7b40e7f..8693a6f55c6a70e3572862c52bd7f3c4a11057d3 100644 (file)
@@ -1069,9 +1069,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
       { this->_M_insert(begin(), std::move(__x)); }
 
       template<typename... _Args>
-        void
+#if __cplusplus > 201402L
+        reference
+#else
+       void
+#endif
         emplace_front(_Args&&... __args)
-        { this->_M_insert(begin(), std::forward<_Args>(__args)...); }
+        {
+         this->_M_insert(begin(), std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+         return front();
+#endif
+       }
 #endif
 
       /**
@@ -1110,9 +1119,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
       { this->_M_insert(end(), std::move(__x)); }
 
       template<typename... _Args>
-        void
+#if __cplusplus > 201402L
+        reference
+#else
+       void
+#endif
         emplace_back(_Args&&... __args)
-        { this->_M_insert(end(), std::forward<_Args>(__args)...); }
+        {
+         this->_M_insert(end(), std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+        return back();
+#endif
+       }
 #endif
 
       /**
index 843199c5b0605ed1abc11bb68c114ee374b1e409..178e4b2c22bf97b4612cb04a4e0dd9d4a3138f60 100644 (file)
@@ -247,10 +247,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       push(value_type&& __x)
       { c.push_back(std::move(__x)); }
 
+#if __cplusplus > 201402L
+      template<typename... _Args>
+       decltype(auto)
+       emplace(_Args&&... __args)
+       { return c.emplace_back(std::forward<_Args>(__args)...); }
+#else
       template<typename... _Args>
         void
         emplace(_Args&&... __args)
        { c.emplace_back(std::forward<_Args>(__args)...); }
+#endif
 #endif
 
       /**
index 612913da935aedf0ee3840d1002f1c6eadf88927..ebc8816d56a122de9feb27e0033b26be4741f9a6 100644 (file)
@@ -223,10 +223,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       push(value_type&& __x)
       { c.push_back(std::move(__x)); }
 
+#if __cplusplus > 201402L
+      template<typename... _Args>
+       decltype(auto)
+       emplace(_Args&&... __args)
+       { return c.emplace_back(std::forward<_Args>(__args)...); }
+#else
       template<typename... _Args>
         void
         emplace(_Args&&... __args)
        { c.emplace_back(std::forward<_Args>(__args)...); }
+#endif
 #endif
 
       /**
index 9a05dd54f7d69539068646651b398b7e4010451c..efc569b9c847033e22256e2c18184c578ba70060 100644 (file)
@@ -960,7 +960,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { emplace_back(std::move(__x)); }
 
       template<typename... _Args>
+#if __cplusplus > 201402L
+        reference
+#else
        void
+#endif
        emplace_back(_Args&&... __args);
 #endif
 
index 6926a8b91c4d23968fab78d154a40e6522d1813f..b6050d34cc9e0570849d5ee7ba35829d06070e25 100644 (file)
@@ -87,7 +87,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 #if __cplusplus >= 201103L
   template<typename _Tp, typename _Alloc>
     template<typename... _Args>
+#if __cplusplus > 201402L
+      typename vector<_Tp, _Alloc>::reference
+#else
       void
+#endif
       vector<_Tp, _Alloc>::
       emplace_back(_Args&&... __args)
       {
@@ -99,6 +103,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
          }
        else
          _M_realloc_insert(end(), std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+       return back();
+#endif
       }
 #endif
 
index f15faadbb7b182379bb3f4d5114eeba83a28a0a3..bf4cba6e72523411d45d7af94cb03fbce22cf595 100644 (file)
@@ -386,19 +386,33 @@ namespace __debug
       { emplace_back(std::move(__x)); }
 
       template<typename... _Args>
+#if __cplusplus > 201402L
+       reference
+#else
        void
+#endif
        emplace_front(_Args&&... __args)
        {
          _Base::emplace_front(std::forward<_Args>(__args)...);
          this->_M_invalidate_all();
+#if __cplusplus > 201402L
+         return front();
+#endif
        }
 
       template<typename... _Args>
+#if __cplusplus > 201402L
+       reference
+#else
        void
+#endif
        emplace_back(_Args&&... __args)
        {
          _Base::emplace_back(std::forward<_Args>(__args)...);
          this->_M_invalidate_all();
+#if __cplusplus > 201402L
+         return back();
+#endif
        }
 
       template<typename... _Args>
index 9bcda733a7005b184019c4e047773cd82da3da4e..b2d70bd5f6b651b8bea0c9187bf5269d98340e94 100644 (file)
@@ -478,7 +478,11 @@ namespace __debug
        { emplace_back(std::move(__x)); }
 
       template<typename... _Args>
+#if __cplusplus > 201402L
+       deque<_Tp, _Alloc>::reference
+#else
        void
+#endif
        emplace_back(_Args&&... __args)
        {
          bool __realloc = this->_M_requires_reallocation(this->size() + 1);
@@ -486,6 +490,9 @@ namespace __debug
          if (__realloc)
            this->_M_invalidate_all();
          this->_M_update_guaranteed_capacity();
+#if __cplusplus > 201402L
+         return back();
+#endif
        }
 #endif
 
diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/cxx17_return.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/cxx17_return.cc
new file mode 100644 (file)
index 0000000..3e5da96
--- /dev/null
@@ -0,0 +1,49 @@
+// 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-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <deque>
+#include <testsuite_hooks.h>
+
+using test_type = std::deque<int>;
+
+void
+test01()
+{
+  test_type x{1, 2, 3, 4};
+  test_type::reference r = x.emplace_front(0);
+  VERIFY( r == 0 );
+  VERIFY( &r == &x.front() );
+}
+
+void
+test02()
+{
+  test_type x{1, 2, 3, 4};
+  test_type::reference r = x.emplace_back(5);
+  VERIFY( r == 5 );
+  VERIFY( &r == &x.back() );
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/emplace_cxx17_return.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/emplace_cxx17_return.cc
new file mode 100644 (file)
index 0000000..b91c1ca
--- /dev/null
@@ -0,0 +1,39 @@
+// 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-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+
+using test_type = std::forward_list<int>;
+
+void
+test01()
+{
+  test_type x{1, 2, 3, 4};
+  test_type::reference r = x.emplace_front(0);
+  VERIFY( r == 0 );
+  VERIFY( &r == &x.front() );
+}
+
+int
+main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/cxx17_return.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/cxx17_return.cc
new file mode 100644 (file)
index 0000000..c88d8d2
--- /dev/null
@@ -0,0 +1,49 @@
+// 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-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <list>
+#include <testsuite_hooks.h>
+
+using test_type = std::list<int>;
+
+void
+test01()
+{
+  test_type x{1, 2, 3, 4};
+  test_type::reference r = x.emplace_front(0);
+  VERIFY( r == 0 );
+  VERIFY( &r == &x.front() );
+}
+
+void
+test02()
+{
+  test_type x{1, 2, 3, 4};
+  test_type::reference r = x.emplace_back(5);
+  VERIFY( r == 5 );
+  VERIFY( &r == &x.back() );
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/queue/members/emplace_cxx17_return.cc b/libstdc++-v3/testsuite/23_containers/queue/members/emplace_cxx17_return.cc
new file mode 100644 (file)
index 0000000..a618e9c
--- /dev/null
@@ -0,0 +1,39 @@
+// 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-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <queue>
+#include <testsuite_hooks.h>
+
+using test_type = std::queue<int>;
+
+void
+test01()
+{
+  test_type x{ test_type::container_type{1, 2, 3, 4} };
+  test_type::reference r = x.emplace(5);
+  VERIFY( r == 5 );
+  VERIFY( &r == &x.back() );
+}
+
+int
+main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/stack/members/emplace_cxx17_return.cc b/libstdc++-v3/testsuite/23_containers/stack/members/emplace_cxx17_return.cc
new file mode 100644 (file)
index 0000000..76964eb
--- /dev/null
@@ -0,0 +1,39 @@
+// 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-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <stack>
+#include <testsuite_hooks.h>
+
+using test_type = std::stack<int>;
+
+void
+test01()
+{
+  test_type x{ test_type::container_type{1, 2, 3, 4} };
+  test_type::reference r = x.emplace(5);
+  VERIFY( r == 5 );
+  VERIFY( &r == &x.top() );
+}
+
+int
+main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/emplace_cxx17_return.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/emplace_cxx17_return.cc
new file mode 100644 (file)
index 0000000..d4f70fb
--- /dev/null
@@ -0,0 +1,38 @@
+// 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-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+using test_type = std::vector<bool>;
+
+void
+test02()
+{
+  test_type x{true, true};
+  test_type::reference r = x.emplace_back(false);
+  VERIFY( r == false );
+}
+
+int
+main()
+{
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/cxx17_return.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/cxx17_return.cc
new file mode 100644 (file)
index 0000000..9006dab
--- /dev/null
@@ -0,0 +1,39 @@
+// 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-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+using test_type = std::vector<int>;
+
+void
+test02()
+{
+  test_type x{1, 2, 3, 4};
+  test_type::reference r = x.emplace_back(5);
+  VERIFY( r == 5 );
+  VERIFY( &r == &x.back() );
+}
+
+int
+main()
+{
+  test02();
+}