mirror of
https://github.com/boostorg/move.git
synced 2025-08-02 13:44:28 +02:00
Cleanup BOOST_MOVE_CONVERSION_AWARE_CATCH macros with is_same_or_convertible, which allows compatibility with more compilers and input iterators
This commit is contained in:
@@ -312,6 +312,17 @@ class is_convertible
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template <class T, class U, bool IsSame = is_same<T, U>::value>
|
||||||
|
struct is_same_or_convertible
|
||||||
|
: is_convertible<T, U>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
struct is_same_or_convertible<T, U, true>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
template<
|
template<
|
||||||
bool C
|
bool C
|
||||||
, typename F1
|
, typename F1
|
||||||
@@ -345,6 +356,16 @@ struct disable_if_convertible
|
|||||||
: disable_if< is_convertible<T, U>, R>
|
: disable_if< is_convertible<T, U>, R>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
template<class T, class U, class R = void>
|
||||||
|
struct enable_if_same_or_convertible
|
||||||
|
: enable_if< is_same_or_convertible<T, U>, R>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<class T, class U, class R = void>
|
||||||
|
struct disable_if_same_or_convertible
|
||||||
|
: disable_if< is_same_or_convertible<T, U>, R>
|
||||||
|
{};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// and_
|
// and_
|
||||||
|
@@ -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.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@@ -20,8 +20,9 @@
|
|||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/move/core.hpp>
|
||||||
#include <boost/move/utility_core.hpp>
|
#include <boost/move/utility_core.hpp>
|
||||||
#include <boost/move/detail/meta_utils.hpp>
|
#include <boost/move/detail/type_traits.hpp>
|
||||||
|
|
||||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
|
|
||||||
@@ -43,6 +44,30 @@
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
template<class RETURN_VALUE, class BOOST_MOVE_TEMPL_PARAM, class TYPE>
|
||||||
|
struct boost_move_conversion_aware_catch_1
|
||||||
|
: public ::boost::move_detail::enable_if_and
|
||||||
|
< RETURN_VALUE
|
||||||
|
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
, ::boost::move_detail::is_class<TYPE>
|
||||||
|
, ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<class RETURN_VALUE, class BOOST_MOVE_TEMPL_PARAM, class TYPE>
|
||||||
|
struct boost_move_conversion_aware_catch_2
|
||||||
|
: public ::boost::move_detail::disable_if_or
|
||||||
|
< RETURN_VALUE
|
||||||
|
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
, ::boost::move_detail::is_rv_impl<BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
, ::boost::move_detail::and_
|
||||||
|
< ::boost::move_detail::is_rv_impl<BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
, ::boost::move_detail::is_class<BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
>
|
||||||
|
>
|
||||||
|
{};
|
||||||
|
|
||||||
#define BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
|
#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_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
|
||||||
{ return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\
|
{ return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\
|
||||||
@@ -59,26 +84,14 @@
|
|||||||
\
|
\
|
||||||
template<class BOOST_MOVE_TEMPL_PARAM>\
|
template<class BOOST_MOVE_TEMPL_PARAM>\
|
||||||
RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\
|
RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\
|
||||||
typename ::boost::move_detail::enable_if_and\
|
typename boost_move_conversion_aware_catch_1< ::boost::move_detail::nat, BOOST_MOVE_TEMPL_PARAM, TYPE>::type* = 0)\
|
||||||
< ::boost::move_detail::nat \
|
|
||||||
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>\
|
|
||||||
, ::boost::move_detail::is_class<TYPE>\
|
|
||||||
, ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>\
|
|
||||||
>::type* = 0)\
|
|
||||||
{ return FWD_FUNCTION(u); }\
|
{ return FWD_FUNCTION(u); }\
|
||||||
\
|
\
|
||||||
template<class BOOST_MOVE_TEMPL_PARAM>\
|
template<class BOOST_MOVE_TEMPL_PARAM>\
|
||||||
RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\
|
RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\
|
||||||
typename ::boost::move_detail::disable_if_or\
|
typename boost_move_conversion_aware_catch_2< ::boost::move_detail::nat, BOOST_MOVE_TEMPL_PARAM, TYPE>::type* = 0)\
|
||||||
< ::boost::move_detail::nat \
|
|
||||||
, ::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<BOOST_MOVE_TEMPL_PARAM> \
|
|
||||||
> \
|
|
||||||
>::type* = 0)\
|
|
||||||
{\
|
{\
|
||||||
TYPE t(u);\
|
TYPE t((u));\
|
||||||
return FWD_FUNCTION(::boost::move(t));\
|
return FWD_FUNCTION(::boost::move(t));\
|
||||||
}\
|
}\
|
||||||
//
|
//
|
||||||
@@ -87,27 +100,15 @@
|
|||||||
BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
|
BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\
|
||||||
\
|
\
|
||||||
template<class BOOST_MOVE_TEMPL_PARAM>\
|
template<class BOOST_MOVE_TEMPL_PARAM>\
|
||||||
typename ::boost::move_detail::enable_if_and\
|
typename boost_move_conversion_aware_catch_1<RETURN_VALUE, BOOST_MOVE_TEMPL_PARAM, TYPE>::type\
|
||||||
< RETURN_VALUE \
|
|
||||||
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>\
|
|
||||||
, ::boost::move_detail::is_class<TYPE>\
|
|
||||||
, ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>\
|
|
||||||
>::type\
|
|
||||||
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
||||||
{ return FWD_FUNCTION(u); }\
|
{ return FWD_FUNCTION(u); }\
|
||||||
\
|
\
|
||||||
template<class BOOST_MOVE_TEMPL_PARAM>\
|
template<class BOOST_MOVE_TEMPL_PARAM>\
|
||||||
typename ::boost::move_detail::disable_if_or\
|
typename boost_move_conversion_aware_catch_2<RETURN_VALUE, BOOST_MOVE_TEMPL_PARAM, TYPE>::type\
|
||||||
< 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<BOOST_MOVE_TEMPL_PARAM> \
|
|
||||||
> \
|
|
||||||
>::type\
|
|
||||||
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
||||||
{\
|
{\
|
||||||
TYPE t(u);\
|
TYPE t((u));\
|
||||||
return FWD_FUNCTION(::boost::move(t));\
|
return FWD_FUNCTION(::boost::move(t));\
|
||||||
}\
|
}\
|
||||||
//
|
//
|
||||||
@@ -127,7 +128,7 @@
|
|||||||
, RETURN_VALUE >::type\
|
, RETURN_VALUE >::type\
|
||||||
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
|
||||||
{\
|
{\
|
||||||
TYPE t(u);\
|
TYPE t((u));\
|
||||||
return FWD_FUNCTION(::boost::move(t));\
|
return FWD_FUNCTION(::boost::move(t));\
|
||||||
}\
|
}\
|
||||||
//
|
//
|
||||||
@@ -151,6 +152,27 @@
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
template<class RETURN_VALUE, class BOOST_MOVE_TEMPL_PARAM, class UNLESS_CONVERTIBLE_TO, class TYPE>
|
||||||
|
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_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO> >
|
||||||
|
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
, ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<class RETURN_VALUE, class BOOST_MOVE_TEMPL_PARAM, class UNLESS_CONVERTIBLE_TO, class TYPE>
|
||||||
|
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_TEMPL_PARAM>
|
||||||
|
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>
|
||||||
|
>
|
||||||
|
{};
|
||||||
|
|
||||||
#define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
|
#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_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\
|
||||||
{ return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\
|
{ return FWD_FUNCTION(arg1, static_cast<const TYPE&>(x)); }\
|
||||||
@@ -167,23 +189,14 @@
|
|||||||
\
|
\
|
||||||
template<class BOOST_MOVE_TEMPL_PARAM>\
|
template<class BOOST_MOVE_TEMPL_PARAM>\
|
||||||
RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\
|
RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\
|
||||||
typename ::boost::move_detail::enable_if_and\
|
typename boost_move_conversion_aware_catch_1arg_1<void, BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO, TYPE>::type* = 0)\
|
||||||
< ::boost::move_detail::nat \
|
|
||||||
, ::boost::move_detail::is_same<TYPE, BOOST_MOVE_TEMPL_PARAM>\
|
|
||||||
, ::boost::has_move_emulation_disabled<BOOST_MOVE_TEMPL_PARAM>\
|
|
||||||
>::type* = 0)\
|
|
||||||
{ return FWD_FUNCTION(arg1, u); }\
|
{ return FWD_FUNCTION(arg1, u); }\
|
||||||
\
|
\
|
||||||
template<class BOOST_MOVE_TEMPL_PARAM>\
|
template<class BOOST_MOVE_TEMPL_PARAM>\
|
||||||
RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\
|
RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\
|
||||||
typename ::boost::move_detail::disable_if_or\
|
typename boost_move_conversion_aware_catch_1arg_2<void, BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO, TYPE>::type* = 0)\
|
||||||
< void \
|
|
||||||
, ::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* = 0)\
|
|
||||||
{\
|
{\
|
||||||
TYPE t(u);\
|
TYPE t((u));\
|
||||||
return FWD_FUNCTION(arg1, ::boost::move(t));\
|
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)\
|
BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\
|
||||||
\
|
\
|
||||||
template<class BOOST_MOVE_TEMPL_PARAM>\
|
template<class BOOST_MOVE_TEMPL_PARAM>\
|
||||||
typename ::boost::move_detail::enable_if_and\
|
typename boost_move_conversion_aware_catch_1arg_1<RETURN_VALUE, BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO, TYPE>::type\
|
||||||
< 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)\
|
PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
|
||||||
{ return FWD_FUNCTION(arg1, u); }\
|
{ return FWD_FUNCTION(arg1, u); }\
|
||||||
\
|
\
|
||||||
template<class BOOST_MOVE_TEMPL_PARAM>\
|
template<class BOOST_MOVE_TEMPL_PARAM>\
|
||||||
typename ::boost::move_detail::disable_if_or\
|
typename boost_move_conversion_aware_catch_1arg_2<RETURN_VALUE, BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO, TYPE>::type\
|
||||||
< 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)\
|
PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
|
||||||
{\
|
{\
|
||||||
TYPE t(u);\
|
TYPE t((u));\
|
||||||
return FWD_FUNCTION(arg1, ::boost::move(t));\
|
return FWD_FUNCTION(arg1, ::boost::move(t));\
|
||||||
}\
|
}\
|
||||||
//
|
//
|
||||||
@@ -228,11 +232,11 @@
|
|||||||
typename ::boost::move_detail::disable_if_or\
|
typename ::boost::move_detail::disable_if_or\
|
||||||
< RETURN_VALUE \
|
< RETURN_VALUE \
|
||||||
, ::boost::move_detail::is_same<TYPE, 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> \
|
, ::boost::move_detail::is_same_or_convertible<BOOST_MOVE_TEMPL_PARAM, UNLESS_CONVERTIBLE_TO> \
|
||||||
>::type\
|
>::type\
|
||||||
PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
|
PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\
|
||||||
{\
|
{\
|
||||||
TYPE t(u);\
|
TYPE t((u));\
|
||||||
return FWD_FUNCTION(arg1, ::boost::move(t));\
|
return FWD_FUNCTION(arg1, ::boost::move(t));\
|
||||||
}\
|
}\
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user