diff --git a/sprout/utility/move.hpp b/sprout/utility/move.hpp index 022c7da2..80f4817c 100644 --- a/sprout/utility/move.hpp +++ b/sprout/utility/move.hpp @@ -9,8 +9,20 @@ namespace sprout { // move // template - inline SPROUT_CONSTEXPR typename std::remove_reference::type&& move(T&& t) SPROUT_NOEXCEPT { - return static_cast::type&&>(t); + inline SPROUT_CONSTEXPR typename std::remove_reference::type&& move(T&& x) SPROUT_NOEXCEPT { + return static_cast::type&&>(x); + } + + // + // move_if_noexcept + // + template + inline SPROUT_CONSTEXPR typename std::conditional< + !std::is_nothrow_move_constructible::value && std::is_copy_constructible::value, + T const&, + T&& + >::type move_if_noexcept(T& x) SPROUT_NOEXCEPT { + return sprout::move(x); } } // namespace sprout