]> 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 17:08:56 +0000 (18:08 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 4 Sep 2017 17:08:56 +0000 (18:08 +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: r251678

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 1a998a66cf74bf13a4f21ad9f6e98566ca5c3cc1..465f996e967bbe6bf625b012f573e999d72d9889 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 ebbf7e8798b4b7c4c5fa6c82991c8190d39ee339..2f30d2aa48fda9028e618c30f17d4ed5e7133cd5 100644 (file)
@@ -2025,7 +2025,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);
       }
@@ -2084,7 +2084,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 31b74efcb4cc8274040189c07434fd8ec73f3eac..d14350d337397b3314bfbec72c3497db5254dcb8 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 a272cf5bc6ed5b7ca7a1270f055d327ba36f0755..8d7a5d1d55db64b39eef1620a7fffaa01a5d0870 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;
 }