From c60351de0ff225a741e995ad1d0ed8b57be5458f Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Mon, 23 Jun 2014 12:35:41 +0400 Subject: [PATCH] Fix move_if_noexcept: add const to reference --- include/boost/move/utility.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/boost/move/utility.hpp b/include/boost/move/utility.hpp index 33c861f..80b2716 100644 --- a/include/boost/move/utility.hpp +++ b/include/boost/move/utility.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) @@ -89,7 +90,7 @@ template inline typename ::boost::move_detail::enable_if_c - < enable_move_utility_emulation::value && !has_move_emulation_enabled::value, T&>::type + < enable_move_utility_emulation::value && !has_move_emulation_enabled::value, typename add_const::type & >::type move_if_noexcept(T& x) BOOST_NOEXCEPT { return x; @@ -116,7 +117,7 @@ template inline typename ::boost::move_detail::enable_if_c < enable_move_utility_emulation::value && has_move_emulation_enabled::value - && !::boost::move_detail::has_nothrow_move_or_uncopyable::value, T&>::type + && !::boost::move_detail::has_nothrow_move_or_uncopyable::value, typename add_const::type & >::type move_if_noexcept(T& x) BOOST_NOEXCEPT { return x; @@ -125,7 +126,7 @@ template inline typename ::boost::move_detail::enable_if_c < enable_move_utility_emulation::value && has_move_emulation_enabled::value - && !::boost::move_detail::has_nothrow_move_or_uncopyable::value, T&>::type + && !::boost::move_detail::has_nothrow_move_or_uncopyable::value, typename add_const::type & >::type move_if_noexcept(rv& x) BOOST_NOEXCEPT { return x; @@ -245,7 +246,8 @@ //! in compilers with rvalue references. For other compilers converts T & into //! ::boost::rv & so that move emulation is activated. Reference //! would be converted to rvalue reference only if input type is nothrow move - //! constructible or if it has no copy constructor. + //! constructible or if it has no copy constructor. In all other cases const + //! reference would be returned template rvalue_reference move_if_noexcept(input_reference) noexcept; @@ -262,7 +264,9 @@ template inline typename ::boost::move_detail::enable_if_c - < !::boost::move_detail::has_nothrow_move_or_uncopyable::value, typename remove_reference::type&>::type + < !::boost::move_detail::has_nothrow_move_or_uncopyable::value, + typename add_const::type>::type& + >::type move_if_noexcept(T& x) BOOST_NOEXCEPT { return x; @@ -279,7 +283,7 @@ template inline typename ::boost::move_detail::enable_if_c - < !::boost::move_detail::has_nothrow_move_or_uncopyable::value, T&>::type + < !::boost::move_detail::has_nothrow_move_or_uncopyable::value, typename add_const::type & >::type move_if_noexcept(T& x) BOOST_NOEXCEPT { return x;