]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/81017 add noexcept to std::function move operations
authorJonathan Wakely <jwakely@redhat.com>
Mon, 4 Sep 2017 16:52:20 +0000 (17:52 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 4 Sep 2017 16:52:20 +0000 (17:52 +0100)
Backport from mainline
2017-06-08  Jonathan Wakely  <jwakely@redhat.com>

PR libstdc++/81017
* include/std/functional (function::function(function&&))
(function::operator=(function&&)): Add noexcept.
* testsuite/20_util/function/assign/move.cc: Check for noexcept.
* testsuite/20_util/function/cons/move.cc: Likewise.

From-SVN: r251674

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/functional
libstdc++-v3/testsuite/20_util/function/assign/move.cc
libstdc++-v3/testsuite/20_util/function/cons/move.cc

index 1e902da3f1c48834df7d4095dfd1356b9f0a2d54..444a1c00fec2ce0bec51377d01955c0a7b40b64a 100644 (file)
@@ -1,5 +1,14 @@
 2017-09-04  Jonathan Wakely  <jwakely@redhat.com>
 
+       Backport from mainline
+       2017-06-08  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/81017
+       * include/std/functional (function::function(function&&))
+       (function::operator=(function&&)): Add noexcept.
+       * testsuite/20_util/function/assign/move.cc: Check for noexcept.
+       * testsuite/20_util/function/cons/move.cc: Likewise.
+
        Backport from mainline
        2017-06-05  Jonathan Wakely  <jwakely@redhat.com>
 
index ecc9fa94d1a9fbdca0c09076fa9cbdc032804464..47774805e44b0e0c4f2e97f53f31d7d78005ddd9 100644 (file)
@@ -1885,7 +1885,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
        *  The newly-created %function contains the target of @a __x
        *  (if it has one).
        */
-      function(function&& __x) : _Function_base()
+      function(function&& __x) noexcept : _Function_base()
       {
        __x.swap(*this);
       }
@@ -1944,7 +1944,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
        *  object, then this operation will not throw an %exception.
        */
       function&
-      operator=(function&& __x)
+      operator=(function&& __x) noexcept
       {
        function(std::move(__x)).swap(*this);
        return *this;
index e792646606441ad5fc1099d50a3a9ff6147563cf..e57794fcfb768b5e2898c15487e8f85d7fc1c666 100644 (file)
@@ -40,11 +40,12 @@ void test01()
   fo2 = (std::move(fo));
   VERIFY( static_cast<bool>(fo2) );
   VERIFY( fo2() == 2 );
+
+  static_assert(std::is_nothrow_move_assignable<function>::value,
+               "PR libstdc++/81017");
 }
 
 int main()
 {
   test01();
-
-  return 0;
 }
index 3bd1eda79dc7cbefa7f7ff2c28d68b1245ca2e1d..88e8bdda55198da1b84f69fdfa642e54458396a1 100644 (file)
@@ -38,11 +38,12 @@ void test01()
   function fo2(std::move(fo));
   VERIFY( static_cast<bool>(fo2) );
   VERIFY( fo2() == 2 );
+
+  static_assert(std::is_nothrow_move_constructible<function>::value,
+               "PR libstdc++/81017");
 }
 
 int main()
 {
   test01();
-
-  return 0;
 }