53 changes: 30 additions & 23 deletions include/boost/move/detail/move_helpers.hpp
Expand Up @@ -48,20 +48,24 @@
{ return FWD_FUNCTION(const_cast<const TYPE &>(x)); }\
\
template<class BOOST_MOVE_TEMPL_PARAM>\
typename ::boost::move_detail::enable_if_c\
< ::boost::move_detail::is_class_or_union<TYPE>::value &&\
::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value &&\
!::boost::has_move_emulation_enabled<BOOST_MOVE_TEMPL_PARAM>::value\
, RETURN_VALUE >::type\
typename ::boost::move_detail::enable_if_and\
< RETURN_VALUE \
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>\
, ::boost::move_detail::is_class_or_union<TYPE>\
, ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>\
>::type\
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
{ return FWD_FUNCTION(u); }\
\
template<class BOOST_MOVE_TEMPL_PARAM>\
typename ::boost::move_detail::enable_if_c\
< (!::boost::move_detail::is_class_or_union<BOOST_MOVE_TEMPL_PARAM>::value || \
!::boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value) && \
!::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value \
, RETURN_VALUE >::type\
typename ::boost::move_detail::disable_if_or\
< RETURN_VALUE \
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM> \
, ::boost::move_detail::and_ \
< ::boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM> \
, ::boost::move_detail::is_class_or_union<BOOST_MOVE_TEMPL_PARAM> \
> \
>::type\
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
{\
TYPE t(u);\
Expand Down Expand Up @@ -115,19 +119,21 @@
{ return FWD_FUNCTION(arg1, const_cast<const TYPE &>(x)); }\
\
template<class BOOST_MOVE_TEMPL_PARAM>\
typename ::boost::move_detail::enable_if_c<\
::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value &&\
!::boost::has_move_emulation_enabled<BOOST_MOVE_TEMPL_PARAM>::value\
, RETURN_VALUE >::type\
typename ::boost::move_detail::enable_if_and\
< RETURN_VALUE \
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>\
, ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>\
>::type\
PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
{ return FWD_FUNCTION(arg1, u); }\
\
template<class BOOST_MOVE_TEMPL_PARAM>\
typename ::boost::move_detail::enable_if_c<\
!::boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>::value && \
!::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value && \
!::boost::move_detail::is_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO>::value \
, RETURN_VALUE >::type\
typename ::boost::move_detail::disable_if_or\
< RETURN_VALUE \
, ::boost::move_detail::is_rv<BOOST_MOVE_TEMPL_PARAM>\
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>\
, ::boost::move_detail::is_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO>\
>::type\
PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
{\
TYPE t(u);\
Expand All @@ -145,10 +151,11 @@
{ return FWD_FUNCTION(arg1, ::boost::move(x)); }\
\
template<class BOOST_MOVE_TEMPL_PARAM>\
typename ::boost::move_detail::enable_if_c\
< !::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>::value && \
!::boost::move_detail::is_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO>::value \
, RETURN_VALUE >::type\
typename ::boost::move_detail::disable_if_or\
< RETURN_VALUE \
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM> \
, ::boost::move_detail::is_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO> \
>::type\
PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
{\
TYPE t(u);\
Expand Down
32 changes: 17 additions & 15 deletions include/boost/move/detail/type_traits.hpp
Expand Up @@ -341,23 +341,17 @@ struct is_pointer<T*>
{ static const bool value = true; };

//////////////////////////
// add_reference
// unvoid_ref
//////////////////////////
template <typename T>
struct add_reference
{ typedef T& type; };

template<class T>
struct add_reference<T&>
{ typedef T& type; };
template <typename T> struct unvoid_ref : add_lvalue_reference<T>{};
template <> struct unvoid_ref<void> { typedef unvoid_ref & type; };
template <> struct unvoid_ref<const void> { typedef unvoid_ref & type; };
template <> struct unvoid_ref<volatile void> { typedef unvoid_ref & type; };
template <> struct unvoid_ref<const volatile void> { typedef unvoid_ref & type; };

template<>
struct add_reference<void>
{ typedef nat &type; };

template<>
struct add_reference<const void>
{ typedef const nat &type; };
template <typename T>
struct add_reference : add_lvalue_reference<T>
{};

//////////////////////////
// add_const_reference
Expand All @@ -370,6 +364,14 @@ template <class T>
struct add_const_reference<T&>
{ typedef T& type; };

//////////////////////////
// add_const_if_c
//////////////////////////
template<class T, bool Add>
struct add_const_if_c
: if_c<Add, typename add_const<T>::type, T>
{};

//////////////////////////
// remove_const
//////////////////////////
Expand Down
76 changes: 48 additions & 28 deletions include/boost/move/utility_core.hpp
Expand Up @@ -47,24 +47,33 @@
//////////////////////////////////////////////////////////////////////////////

template <class T>
inline typename ::boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && !has_move_emulation_enabled<T>::value, T&>::type
inline typename ::boost::move_detail::enable_if_and
< T &
, enable_move_utility_emulation<T>
, has_move_emulation_disabled<T>
>::type
move(T& x) BOOST_NOEXCEPT
{
return x;
}

template <class T>
inline typename ::boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value, rv<T>&>::type
inline typename ::boost::move_detail::enable_if_and
< rv<T>&
, enable_move_utility_emulation<T>
, has_move_emulation_enabled<T>
>::type
move(T& x) BOOST_NOEXCEPT
{
return *static_cast<rv<T>* >(::boost::move_detail::addressof(x));
return *BOOST_MOVE_TO_RV_CAST(::boost::rv<T>*, ::boost::move_detail::addressof(x) );
}

template <class T>
inline typename ::boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value, rv<T>&>::type
inline typename ::boost::move_detail::enable_if_and
< rv<T>&
, enable_move_utility_emulation<T>
, has_move_emulation_enabled<T>
>::type
move(rv<T>& x) BOOST_NOEXCEPT
{
return x;
Expand All @@ -77,17 +86,23 @@
//////////////////////////////////////////////////////////////////////////////

template <class T>
inline typename ::boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && ::boost::move_detail::is_rv<T>::value, T &>::type
inline typename ::boost::move_detail::enable_if_and
< T &
, enable_move_utility_emulation<T>
, ::boost::move_detail::is_rv<T>
>::type
forward(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT
{
return const_cast<T&>(x);
}

template <class T>
inline typename ::boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && !::boost::move_detail::is_rv<T>::value, const T &>::type
forward(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT
inline typename ::boost::move_detail::enable_if_and
< const T &
, enable_move_utility_emulation<T>
, ::boost::move_detail::is_not_rv<T>
>::type
forward(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT
{
return x;
}
Expand All @@ -99,35 +114,40 @@
//////////////////////////////////////////////////////////////////////////////

template <class T>
inline typename ::boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value &&
::boost::move_detail::is_rv<T>::value
, T &>::type
inline typename ::boost::move_detail::enable_if_and
< T &
, enable_move_utility_emulation<T>
, ::boost::move_detail::is_rv<T>
>::type
move_if_not_lvalue_reference(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT
{
return const_cast<T&>(x);
}

template <class T>
inline typename ::boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value &&
!::boost::move_detail::is_rv<T>::value &&
(::boost::move_detail::is_lvalue_reference<T>::value ||
!has_move_emulation_enabled<T>::value)
, typename ::boost::move_detail::add_lvalue_reference<T>::type
inline typename ::boost::move_detail::enable_if_and
< typename ::boost::move_detail::add_lvalue_reference<T>::type
, enable_move_utility_emulation<T>
, ::boost::move_detail::is_not_rv<T>
, ::boost::move_detail::or_
< ::boost::move_detail::is_lvalue_reference<T>
, has_move_emulation_disabled<T>
>
>::type
move_if_not_lvalue_reference(typename ::boost::move_detail::remove_reference<T>::type &x) BOOST_NOEXCEPT
{
return x;
}

template <class T>
inline typename ::boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value &&
!::boost::move_detail::is_rv<T>::value &&
(!::boost::move_detail::is_lvalue_reference<T>::value &&
has_move_emulation_enabled<T>::value)
, rv<T>&
inline typename ::boost::move_detail::enable_if_and
< rv<T>&
, enable_move_utility_emulation<T>
, ::boost::move_detail::is_not_rv<T>
, ::boost::move_detail::and_
< ::boost::move_detail::not_< ::boost::move_detail::is_lvalue_reference<T> >
, has_move_emulation_enabled<T>
>
>::type
move_if_not_lvalue_reference(typename ::boost::move_detail::remove_reference<T>::type &x) BOOST_NOEXCEPT
{
Expand Down