mirror of
https://github.com/boostorg/move.git
synced 2025-08-02 05:44:25 +02:00
Fixes for clang + cleanup
[SVN r74123]
This commit is contained in:
@@ -15,14 +15,28 @@
|
||||
#ifndef BOOST_MOVE_MOVE_HPP
|
||||
#define BOOST_MOVE_MOVE_HPP
|
||||
|
||||
/// @cond
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#pragma warning (push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#include <algorithm> //copy, copy_backward
|
||||
#include <memory> //uninitialized_copy
|
||||
#include <iterator> //std::iterator
|
||||
|
||||
#define BOOST_MOVE_AVOID_BOOST_DEPENDENCIES
|
||||
|
||||
#ifndef BOOST_MOVE_AVOID_BOOST_DEPENDENCIES
|
||||
//If boost dependencies are avoided include all machinery
|
||||
#if !defined(BOOST_MOVE_AVOID_BOOST_DEPENDENCIES)
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
@@ -31,21 +45,18 @@
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#endif //#ifdef BOOST_MOVE_AVOID_BOOST_DEPENDENCIES
|
||||
/// @cond
|
||||
|
||||
#ifdef BOOST_MOVE_AVOID_BOOST_DEPENDENCIES
|
||||
#define BOOST_MOVE_MPL_NS ::boost::move_detail
|
||||
#define BOOST_MOVE_BOOST_NS ::boost::move_detail
|
||||
#else
|
||||
#define BOOST_MOVE_MPL_NS ::boost::mpl
|
||||
#define BOOST_MOVE_BOOST_NS ::boost
|
||||
#endif
|
||||
#else
|
||||
#define BOOST_MOVE_MPL_NS ::boost::move_detail
|
||||
#define BOOST_MOVE_BOOST_NS ::boost::move_detail
|
||||
#endif //#ifdef BOOST_MOVE_AVOID_BOOST_DEPENDENCIES
|
||||
|
||||
//Small meta-typetraits to support move
|
||||
#ifdef BOOST_MOVE_AVOID_BOOST_DEPENDENCIES
|
||||
|
||||
namespace boost {
|
||||
@@ -172,59 +183,32 @@ template<class T> T * addressof( T & v )
|
||||
( ::boost::move_detail::addr_impl_ref<T>( v ), 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
typedef char one;
|
||||
struct two {one _[2];};
|
||||
|
||||
template <typename B, typename D>
|
||||
struct is_base_of_host
|
||||
{
|
||||
operator B*() const;
|
||||
operator D*();
|
||||
};
|
||||
|
||||
template <typename B, typename D>
|
||||
struct is_base_of
|
||||
{
|
||||
typedef char yes;
|
||||
class no { char dummy[2]; };
|
||||
|
||||
template <typename T>
|
||||
static yes check(D*, T);
|
||||
static no check(B*, int);
|
||||
|
||||
static const bool value = sizeof(check(is_base_of_host<B,D>(), int())) == sizeof(yes);
|
||||
};
|
||||
*/
|
||||
|
||||
} //namespace move_detail {
|
||||
} //namespace boost {
|
||||
|
||||
#endif //BOOST_MOVE_AVOID_BOOST_DEPENDENCIES
|
||||
|
||||
/// @endcond
|
||||
|
||||
//Compiler workaround detection
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5)
|
||||
|
||||
#ifndef BOOST_CLANG
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5) && !defined(__clang__)
|
||||
//Pre-standard rvalue binding rules
|
||||
#define BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER == 1600)
|
||||
#elif defined(_MSC_VER) && (_MSC_VER == 1600)
|
||||
//Standard rvalue binding rules but with some bugs
|
||||
#define BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG
|
||||
//Use standard library for MSVC to avoid namespace issues as
|
||||
//some move calls in the STL are not fully qualified.
|
||||
//#define BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/// @endcond
|
||||
|
||||
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||
|
||||
//Move emulation rv breaks standard aliasing rules so add workarounds for some compilers
|
||||
#ifdef __GNUC__
|
||||
#define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__))
|
||||
#else
|
||||
@@ -421,24 +405,40 @@ typename BOOST_MOVE_BOOST_NS::disable_if< ::boost::move_detail::is_rv<T>, const
|
||||
|
||||
#else //BOOST_NO_RVALUE_REFERENCES
|
||||
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
//! By default this traits returns false. Classes with non-thworing move construction
|
||||
//! By default this traits returns false. Classes with non-throwing move constructor
|
||||
//! and assignment should specialize this trait to obtain some performance improvements.
|
||||
template <class T>
|
||||
struct has_nothrow_move
|
||||
: public BOOST_MOVE_MPL_NS::integral_constant<bool, false>
|
||||
{};
|
||||
|
||||
} // namespace boost{
|
||||
|
||||
#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
|
||||
#include <utility>
|
||||
|
||||
namespace boost{
|
||||
|
||||
using ::std::move;
|
||||
using ::std::forward;
|
||||
using ::std::move_backward;
|
||||
|
||||
} //namespace boost
|
||||
|
||||
#else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
|
||||
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// move
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||
//! This function provides a way to convert a reference into a rvalue reference
|
||||
//! in compilers with rvalue references. For other compilers converts T & into
|
||||
@@ -446,9 +446,7 @@ struct has_nothrow_move
|
||||
template <class T> inline
|
||||
rvalue_reference move (input_reference);
|
||||
|
||||
#else //BOOST_MOVE_DOXYGEN_INVOKED
|
||||
|
||||
#if defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
|
||||
#elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
|
||||
|
||||
//Old move approach, lvalues could bind to rvalue references
|
||||
template <class T> inline
|
||||
@@ -463,9 +461,6 @@ typename remove_reference<T>::type && move(T&& t)
|
||||
|
||||
#endif //Old move
|
||||
|
||||
#endif //BOOST_MOVE_DOXYGEN_INVOKED
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// forward
|
||||
@@ -486,10 +481,7 @@ typename remove_reference<T>::type && move(T&& t)
|
||||
//!
|
||||
//! * Else, input_reference is equal to output_reference is equal to input_reference.
|
||||
template <class T> inline output_reference forward(input_reference);
|
||||
|
||||
#else
|
||||
|
||||
#if defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
|
||||
#elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
|
||||
|
||||
//Old move approach, lvalues could bind to rvalue references
|
||||
|
||||
@@ -510,10 +502,12 @@ inline T&& forward(U&& t
|
||||
<typename remove_reference<U>::type*, typename remove_reference<T>::type*>::value>::type * = 0*/)
|
||||
{ return static_cast<T&&>(t); }
|
||||
|
||||
#endif //Old move
|
||||
|
||||
#endif //BOOST_MOVE_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace boost {
|
||||
|
||||
#endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BOOST_ENABLE_MOVE_EMULATION
|
||||
@@ -597,8 +591,6 @@ inline T&& forward(U&& t
|
||||
|
||||
/// @endcond
|
||||
|
||||
} //namespace boost {
|
||||
|
||||
#endif //BOOST_NO_RVALUE_REFERENCES
|
||||
|
||||
namespace boost {
|
||||
@@ -866,6 +858,7 @@ inline move_insert_iterator<C> move_inserter(C& x, typename C::iterator it)
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
|
||||
|
||||
//! <b>Effects</b>: Moves elements in the range [first,last) into the range [result,result + (last -
|
||||
//! first)) starting from first and proceeding to last. For each non-negative integer n < (last-first),
|
||||
@@ -914,6 +907,8 @@ O move_backward(I f, I l, O result)
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif //!defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// uninitialized_move
|
||||
@@ -956,6 +951,7 @@ F uninitialized_move(I f, I l, F r,
|
||||
return std::uninitialized_copy(f, l, r);
|
||||
}
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// uninitialized_copy_or_move
|
||||
@@ -1098,4 +1094,13 @@ struct has_trivial_destructor_after_move
|
||||
|
||||
} //namespace boost {
|
||||
|
||||
#if defined BOOST_MSVC
|
||||
#pragma warning (pop)
|
||||
#ifdef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE
|
||||
#undef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE
|
||||
#undef _CRT_SECURE_NO_DEPRECATE
|
||||
#undef _SCL_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif //#ifndef BOOST_MOVE_MOVE_HPP
|
||||
|
Reference in New Issue
Block a user