diff --git a/include/boost/move/detail/meta_utils.hpp b/include/boost/move/detail/meta_utils.hpp index 736c82a..e45394c 100644 --- a/include/boost/move/detail/meta_utils.hpp +++ b/include/boost/move/detail/meta_utils.hpp @@ -312,6 +312,17 @@ class is_convertible #endif +template ::value> +struct is_same_or_convertible + : is_convertible +{}; + +template +struct is_same_or_convertible +{ + static const bool value = true; +}; + template< bool C , typename F1 @@ -345,6 +356,16 @@ struct disable_if_convertible : disable_if< is_convertible, R> {}; +template +struct enable_if_same_or_convertible + : enable_if< is_same_or_convertible, R> +{}; + +template +struct disable_if_same_or_convertible + : disable_if< is_same_or_convertible, R> +{}; + ////////////////////////////////////////////////////////////////////////////// // // and_ diff --git a/include/boost/move/detail/move_helpers.hpp b/include/boost/move/detail/move_helpers.hpp index 7b62e26..a2502bf 100644 --- a/include/boost/move/detail/move_helpers.hpp +++ b/include/boost/move/detail/move_helpers.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2010-2012. +// (C) Copyright Ion Gaztanaga 2010-2016. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -20,8 +20,9 @@ # pragma once #endif +#include #include -#include +#include #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) @@ -43,6 +44,30 @@ //////////////////////////////////////// #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES + + template + struct boost_move_conversion_aware_catch_1 + : public ::boost::move_detail::enable_if_and + < RETURN_VALUE + , ::boost::move_detail::is_same + , ::boost::move_detail::is_class + , ::boost::has_move_emulation_disabled + > + {}; + + template + struct boost_move_conversion_aware_catch_2 + : public ::boost::move_detail::disable_if_or + < RETURN_VALUE + , ::boost::move_detail::is_same + , ::boost::move_detail::is_rv_impl + , ::boost::move_detail::and_ + < ::boost::move_detail::is_rv_impl + , ::boost::move_detail::is_class + > + > + {}; + #define BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ { return FWD_FUNCTION(static_cast(x)); }\ @@ -59,26 +84,14 @@ \ template\ RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\ - typename ::boost::move_detail::enable_if_and\ - < ::boost::move_detail::nat \ - , ::boost::move_detail::is_same\ - , ::boost::move_detail::is_class\ - , ::boost::has_move_emulation_disabled\ - >::type* = 0)\ + typename boost_move_conversion_aware_catch_1< ::boost::move_detail::nat, BOOST_MOVE_TEMPL_PARAM, TYPE>::type* = 0)\ { return FWD_FUNCTION(u); }\ \ template\ RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\ - typename ::boost::move_detail::disable_if_or\ - < ::boost::move_detail::nat \ - , ::boost::move_detail::is_same \ - , ::boost::move_detail::and_ \ - < ::boost::move_detail::is_rv \ - , ::boost::move_detail::is_class \ - > \ - >::type* = 0)\ + typename boost_move_conversion_aware_catch_2< ::boost::move_detail::nat, BOOST_MOVE_TEMPL_PARAM, TYPE>::type* = 0)\ {\ - TYPE t(u);\ + TYPE t((u));\ return FWD_FUNCTION(::boost::move(t));\ }\ // @@ -87,27 +100,15 @@ BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ \ template\ - typename ::boost::move_detail::enable_if_and\ - < RETURN_VALUE \ - , ::boost::move_detail::is_same\ - , ::boost::move_detail::is_class\ - , ::boost::has_move_emulation_disabled\ - >::type\ + typename boost_move_conversion_aware_catch_1::type\ PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ { return FWD_FUNCTION(u); }\ \ template\ - typename ::boost::move_detail::disable_if_or\ - < RETURN_VALUE \ - , ::boost::move_detail::is_same \ - , ::boost::move_detail::and_ \ - < ::boost::move_detail::is_rv \ - , ::boost::move_detail::is_class \ - > \ - >::type\ + typename boost_move_conversion_aware_catch_2::type\ PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ {\ - TYPE t(u);\ + TYPE t((u));\ return FWD_FUNCTION(::boost::move(t));\ }\ // @@ -127,7 +128,7 @@ , RETURN_VALUE >::type\ PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ {\ - TYPE t(u);\ + TYPE t((u));\ return FWD_FUNCTION(::boost::move(t));\ }\ // @@ -151,6 +152,27 @@ //////////////////////////////////////// #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES + + template + struct boost_move_conversion_aware_catch_1arg_1 + : public ::boost::move_detail::enable_if_and + < RETURN_VALUE + , ::boost::move_detail::not_< ::boost::move_detail::is_same_or_convertible > + , ::boost::move_detail::is_same + , ::boost::has_move_emulation_disabled + > + {}; + + template + struct boost_move_conversion_aware_catch_1arg_2 + : public ::boost::move_detail::disable_if_or + < RETURN_VALUE + , ::boost::move_detail::is_same_or_convertible< BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO> + , ::boost::move_detail::is_rv_impl + , ::boost::move_detail::is_same + > + {}; + #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ { return FWD_FUNCTION(arg1, static_cast(x)); }\ @@ -167,23 +189,14 @@ \ template\ RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\ - typename ::boost::move_detail::enable_if_and\ - < ::boost::move_detail::nat \ - , ::boost::move_detail::is_same\ - , ::boost::has_move_emulation_disabled\ - >::type* = 0)\ + typename boost_move_conversion_aware_catch_1arg_1::type* = 0)\ { return FWD_FUNCTION(arg1, u); }\ \ template\ RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\ - typename ::boost::move_detail::disable_if_or\ - < void \ - , ::boost::move_detail::is_rv\ - , ::boost::move_detail::is_same\ - , ::boost::move_detail::is_convertible\ - >::type* = 0)\ + typename boost_move_conversion_aware_catch_1arg_2::type* = 0)\ {\ - TYPE t(u);\ + TYPE t((u));\ return FWD_FUNCTION(arg1, ::boost::move(t));\ }\ // @@ -192,24 +205,15 @@ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ \ template\ - typename ::boost::move_detail::enable_if_and\ - < RETURN_VALUE \ - , ::boost::move_detail::is_same\ - , ::boost::has_move_emulation_disabled\ - >::type\ + typename boost_move_conversion_aware_catch_1arg_1::type\ PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ { return FWD_FUNCTION(arg1, u); }\ \ template\ - typename ::boost::move_detail::disable_if_or\ - < RETURN_VALUE \ - , ::boost::move_detail::is_rv\ - , ::boost::move_detail::is_same\ - , ::boost::move_detail::is_convertible\ - >::type\ + typename boost_move_conversion_aware_catch_1arg_2::type\ PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ {\ - TYPE t(u);\ + TYPE t((u));\ return FWD_FUNCTION(arg1, ::boost::move(t));\ }\ // @@ -228,11 +232,11 @@ typename ::boost::move_detail::disable_if_or\ < RETURN_VALUE \ , ::boost::move_detail::is_same \ - , ::boost::move_detail::is_convertible \ + , ::boost::move_detail::is_same_or_convertible \ >::type\ PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ {\ - TYPE t(u);\ + TYPE t((u));\ return FWD_FUNCTION(arg1, ::boost::move(t));\ }\ //