forked from boostorg/move
-> Added new meta-utils that were duplicated in Container & Intrusive.
-> Use some of them to avoid SFINAE instantiation errors in some old compilers. -> Added a macro to static_cast or reinterpret_cast to rv<T> so in the future we can avoid some sanitizer errors when using static_cast
This commit is contained in:
1 parent
0ebc3f4682
commit
4f9c2b62fb
6 files changed
+335
-88
No files matched your search
@@ -53,6 +53,12 @@
|
||||
|
||||
#include <boost/move/detail/type_traits.hpp>
|
||||
|
||||
#if 1
|
||||
#define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) static_cast<RV_TYPE>(ARG)
|
||||
#else
|
||||
#define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) reinterpret_cast<RV_TYPE>(ARG)
|
||||
#endif
|
||||
|
||||
//Move emulation rv breaks standard aliasing rules so add workarounds for some compilers
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4) && \
|
||||
(\
|
||||
@@ -101,6 +107,12 @@
|
||||
: integral_constant<bool, ::boost::move_detail::is_rv_impl<T>::value >
|
||||
{};
|
||||
|
||||
template <class T>
|
||||
struct is_not_rv
|
||||
{
|
||||
static const bool value = !is_rv<T>::value;
|
||||
};
|
||||
|
||||
} //namespace move_detail {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -113,6 +125,12 @@
|
||||
: ::boost::move_detail::has_move_emulation_enabled_impl<T>
|
||||
{};
|
||||
|
||||
template<class T>
|
||||
struct has_move_emulation_disabled
|
||||
{
|
||||
static const bool value = !::boost::move_detail::has_move_emulation_enabled_impl<T>::value;
|
||||
};
|
||||
|
||||
} //namespace boost {
|
||||
|
||||
#define BOOST_RV_REF(TYPE)\
|
||||
@@ -183,7 +201,7 @@
|
||||
, ::boost::rv<T>&>::type
|
||||
move_return(T& x) BOOST_NOEXCEPT
|
||||
{
|
||||
return *static_cast< ::boost::rv<T>* >(::boost::move_detail::addressof(x));
|
||||
return *BOOST_MOVE_TO_RV_CAST(::boost::rv<T>*, ::boost::move_detail::addressof(x));
|
||||
}
|
||||
|
||||
template <class Ret, class T>
|
||||
@@ -216,9 +234,9 @@
|
||||
BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE)\
|
||||
public:\
|
||||
operator ::boost::rv<TYPE>&() \
|
||||
{ return *static_cast< ::boost::rv<TYPE>* >(this); }\
|
||||
{ return *BOOST_MOVE_TO_RV_CAST(::boost::rv<TYPE>*, this); }\
|
||||
operator const ::boost::rv<TYPE>&() const \
|
||||
{ return *static_cast<const ::boost::rv<TYPE>* >(this); }\
|
||||
{ return *BOOST_MOVE_TO_RV_CAST(const ::boost::rv<TYPE>*, this); }\
|
||||
private:\
|
||||
//
|
||||
|
||||
@@ -231,21 +249,21 @@
|
||||
#define BOOST_COPYABLE_AND_MOVABLE(TYPE)\
|
||||
public:\
|
||||
TYPE& operator=(TYPE &t)\
|
||||
{ this->operator=(static_cast<const ::boost::rv<TYPE> &>(const_cast<const TYPE &>(t))); return *this;}\
|
||||
{ this->operator=(const_cast<const TYPE &>(t)); return *this;}\
|
||||
public:\
|
||||
operator ::boost::rv<TYPE>&() \
|
||||
{ return *static_cast< ::boost::rv<TYPE>* >(this); }\
|
||||
{ return *BOOST_MOVE_TO_RV_CAST(::boost::rv<TYPE>*, this); }\
|
||||
operator const ::boost::rv<TYPE>&() const \
|
||||
{ return *static_cast<const ::boost::rv<TYPE>* >(this); }\
|
||||
{ return *BOOST_MOVE_TO_RV_CAST(const ::boost::rv<TYPE>*, this); }\
|
||||
private:\
|
||||
//
|
||||
|
||||
#define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\
|
||||
public:\
|
||||
operator ::boost::rv<TYPE>&() \
|
||||
{ return *static_cast< ::boost::rv<TYPE>* >(this); }\
|
||||
{ return *BOOST_MOVE_TO_RV_CAST(::boost::rv<TYPE>*, this); }\
|
||||
operator const ::boost::rv<TYPE>&() const \
|
||||
{ return *static_cast<const ::boost::rv<TYPE>* >(this); }\
|
||||
{ return *BOOST_MOVE_TO_RV_CAST(const ::boost::rv<TYPE>*, this); }\
|
||||
private:\
|
||||
//
|
||||
|
||||
@@ -295,6 +313,12 @@
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct has_move_emulation_disabled
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
} //namespace boost{
|
||||
|
||||
//!This macro is used to achieve portable syntax in move
|
||||
|
||||
Reference in new issue
Block a user