PR libstdc++/81017 add noexcept to std::function move operations
authorJonathan Wakely <jwakely@redhat.com>
Thu, 8 Jun 2017 14:27:45 +0000 (15:27 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 8 Jun 2017 14:27:45 +0000 (15:27 +0100)
PR libstdc++/81017
* include/bits/std_function.h (function::function(function&&))
(function::operator=(funtion&&)): Add noexcept.
* testsuite/20_util/function/assign/move.cc: Check for noexcept.
* testsuite/20_util/function/cons/move.cc: Likewise.

From-SVN: r249018

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/std_function.h
libstdc++-v3/testsuite/20_util/function/assign/move.cc
libstdc++-v3/testsuite/20_util/function/cons/move.cc

index a53c1ece09abbd4cf3e8989e42d9c0861d8692b8..6896c15fa6e71b97d1f884c70633af87bcb7605a 100644 (file)
@@ -1,3 +1,11 @@
+2017-06-08  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/81017
+       * include/bits/std_function.h (function::function(function&&))
+       (function::operator=(funtion&&)): Add noexcept.
+       * testsuite/20_util/function/assign/move.cc: Check for noexcept.
+       * testsuite/20_util/function/cons/move.cc: Likewise.
+
 2017-06-07  Jonathan Wakely  <jwakely@redhat.com>
 
        * include/bits/regex.h (basic_regex): Add deduction guide from P0433.
index c4ea34733609d5f5da47d0ded3188c5c371df9c7..a9ba7567b33c4caf5a19acd78f3d0592ee806477 100644 (file)
@@ -438,7 +438,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  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);
       }
@@ -495,7 +495,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  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 5264623c2f38d3794e342b138abbbcc4f41a0963..8658527fce45ff264a24c17eeb5fe58eeccd9b8b 100644 (file)
@@ -38,11 +38,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 1cdfeeddbafd8e7c96560c9b863c758d45daabdd..7dbc511d3268ee43f10c9530d982f8ef38349499 100644 (file)
@@ -36,11 +36,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;
 }