From 48816135df30a7246fdd7e1e8f851a319755200e Mon Sep 17 00:00:00 2001 From: joaquintides Date: Wed, 5 Oct 2022 10:05:10 +0200 Subject: [PATCH] refactored move assignment to silence warnings --- include/boost/unordered/detail/foa.hpp | 27 +++++++------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index e6ece045..08a60d76 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1035,16 +1035,6 @@ public: return *this; } -#if defined(BOOST_MSVC) -#pragma warning(push) -#pragma warning(disable:4297) /* throw inside noexcept function */ -#endif - -#if defined(BOOST_GCC) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wterminate" -#endif - table& operator=(table&& x) noexcept( alloc_traits::is_always_equal::value&& @@ -1066,7 +1056,12 @@ public: swap(arrays,x.arrays); swap(ml,x.ml); } - else{ + else if_constexpr([&,this]{ + /* The check above is redundant: we're setting up a compile-time + * barrier so that the compiler is convinced we're not throwing + * under noexcept(true) conditions. + */ + reserve(x.size()); BOOST_TRY{ /* This works because subsequent x.clear() does not depend on the @@ -1083,19 +1078,11 @@ public: } BOOST_CATCH_END x.clear(); - } + }); } return *this; } -#if defined(BOOST_GCC) -#pragma GCC diagnostic pop -#endif - -#if defined(BOOST_MSVC) -#pragma warning(pop) /* C4297 */ -#endif - allocator_type get_allocator()const noexcept{return al();} iterator begin()noexcept