From 4fc8d43b4b09ccf126f3db22b5df2c22ef7c6741 Mon Sep 17 00:00:00 2001 From: Lakshay Garg Date: Sun, 20 Aug 2017 22:21:04 +0530 Subject: [PATCH] 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. --- include/boost/math/tools/polynomial.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/math/tools/polynomial.hpp b/include/boost/math/tools/polynomial.hpp index d0b7ee8a7..1f4b1f6fe 100644 --- a/include/boost/math/tools/polynomial.hpp +++ b/include/boost/math/tools/polynomial.hpp @@ -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;