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
This commit is contained in:
Jonathan Wakely 2017-06-08 15:27:45 +01:00 committed by Jonathan Wakely
parent 0b6bc90422
commit 853ed6bc10
4 changed files with 16 additions and 6 deletions

View 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.

View 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;

View 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;
}

View 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;
}