Commit 853ed6bc by Jonathan Wakely Committed by Jonathan Wakely

PR libstdc++/81017 add noexcept to std::function move operations

	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
parent 0b6bc904
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> 2017-06-07 Jonathan Wakely <jwakely@redhat.com>
* include/bits/regex.h (basic_regex): Add deduction guide from P0433. * include/bits/regex.h (basic_regex): Add deduction guide from P0433.
......
...@@ -438,7 +438,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -438,7 +438,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* The newly-created %function contains the target of @a __x * The newly-created %function contains the target of @a __x
* (if it has one). * (if it has one).
*/ */
function(function&& __x) : _Function_base() function(function&& __x) noexcept : _Function_base()
{ {
__x.swap(*this); __x.swap(*this);
} }
...@@ -495,7 +495,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -495,7 +495,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* object, then this operation will not throw an %exception. * object, then this operation will not throw an %exception.
*/ */
function& function&
operator=(function&& __x) operator=(function&& __x) noexcept
{ {
function(std::move(__x)).swap(*this); function(std::move(__x)).swap(*this);
return *this; return *this;
......
...@@ -38,11 +38,12 @@ void test01() ...@@ -38,11 +38,12 @@ void test01()
fo2 = (std::move(fo)); fo2 = (std::move(fo));
VERIFY( static_cast<bool>(fo2) ); VERIFY( static_cast<bool>(fo2) );
VERIFY( fo2() == 2 ); VERIFY( fo2() == 2 );
static_assert(std::is_nothrow_move_assignable<function>::value,
"PR libstdc++/81017");
} }
int main() int main()
{ {
test01(); test01();
return 0;
} }
...@@ -36,11 +36,12 @@ void test01() ...@@ -36,11 +36,12 @@ void test01()
function fo2(std::move(fo)); function fo2(std::move(fo));
VERIFY( static_cast<bool>(fo2) ); VERIFY( static_cast<bool>(fo2) );
VERIFY( fo2() == 2 ); VERIFY( fo2() == 2 );
static_assert(std::is_nothrow_move_constructible<function>::value,
"PR libstdc++/81017");
} }
int main() int main()
{ {
test01(); test01();
return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment