2
0
mirror of https://github.com/boostorg/math.git synced 2026-02-01 20:42:19 +00:00

make move constructor and operator= noexcept

This change helps the polynomial class play well with STL
containers.

> If the move constructor for an element type in a container
> is not noexcept then the container will use the copy constructor rather
> than the move constructor -- HIC++ Version 4.0

Benchmarking shows that the number of calls to copy constructor
are reduced.
This commit is contained in:
Lakshay Garg
2017-08-20 22:21:04 +05:30
parent 532f873cbc
commit 4fc8d43b4b

View File

@@ -318,7 +318,7 @@ public:
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
// move:
polynomial(polynomial&& p)
polynomial(polynomial&& p) BOOST_NOEXCEPT
: m_data(std::move(p.m_data)) { }
#endif
@@ -387,7 +387,7 @@ public:
// operators:
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
polynomial& operator =(polynomial&& p)
polynomial& operator =(polynomial&& p) BOOST_NOEXCEPT
{
m_data = std::move(p.m_data);
return *this;