From d45f2cd73436ef16a0876e7fe79d99907a90d664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 3 Aug 2014 21:26:46 +0200 Subject: [PATCH] Reduced dependencies with type_traits. Updated "forward" to be standard conforming. --- include/boost/move/detail/meta_utils.hpp | 23 +++++++++++++++++++ include/boost/move/utility.hpp | 28 ++++++++++++------------ 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/include/boost/move/detail/meta_utils.hpp b/include/boost/move/detail/meta_utils.hpp index 0da3c68..c95d7cf 100644 --- a/include/boost/move/detail/meta_utils.hpp +++ b/include/boost/move/detail/meta_utils.hpp @@ -120,6 +120,29 @@ struct is_lvalue_reference : public integral_constant {}; +//remove_reference +template +struct remove_reference +{ + typedef T type; +}; + +template +struct remove_reference +{ + typedef T type; +}; + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + +template +struct remove_reference +{ + typedef T type; +}; + +#endif + template struct is_class_or_union { diff --git a/include/boost/move/utility.hpp b/include/boost/move/utility.hpp index 964500e..d4219a1 100644 --- a/include/boost/move/utility.hpp +++ b/include/boost/move/utility.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) @@ -96,8 +97,6 @@ #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE - #include - namespace boost { //! This trait's internal boolean `value` is false in compilers with rvalue references @@ -129,14 +128,14 @@ //Old move approach, lvalues could bind to rvalue references template - inline typename remove_reference::type && move(T&& t) BOOST_NOEXCEPT + inline typename ::boost::move_detail::remove_reference::type && move(T&& t) BOOST_NOEXCEPT { return t; } #else //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES template - inline typename remove_reference::type && move(T&& t) BOOST_NOEXCEPT - { return static_cast::type &&>(t); } + inline typename ::boost::move_detail::remove_reference::type && move(T&& t) BOOST_NOEXCEPT + { return static_cast::type &&>(t); } #endif //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES @@ -170,16 +169,17 @@ #else //Old move - //Implementation #5 from N2951, thanks to Howard Hinnant + template + inline T&& forward(typename ::boost::move_detail::remove_reference::type& t) BOOST_NOEXCEPT + { return static_cast(t); } - template - inline T&& forward(U&& t - , typename ::boost::move_detail::enable_if_c< - move_detail::is_lvalue_reference::value ? move_detail::is_lvalue_reference::value : true>::type * = 0/* - , typename ::boost::move_detail::enable_if_c< - move_detail::is_convertible - ::type*, typename remove_reference::type*>::value>::type * = 0*/) BOOST_NOEXCEPT - { return static_cast(t); } + template + inline T&& forward(typename ::boost::move_detail::remove_reference::type&& t) BOOST_NOEXCEPT + { + //"boost::forward error: 'T' is a lvalue reference, can't forward as rvalue."; + BOOST_STATIC_ASSERT(!boost::move_detail::is_lvalue_reference::value); + return static_cast(t); + } #endif //BOOST_MOVE_DOXYGEN_INVOKED