Replace Boost.Move by std equivalents

This commit is contained in:
Alexander Grund 2020-07-05 17:29:44 +02:00
parent b86100a667
commit 9e664b52ab
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
15 changed files with 44 additions and 108 deletions

View file

@ -64,12 +64,6 @@
# endif
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_RVALUE_REFERENCES)
# ifndef MOCK_NO_RVALUE_REFERENCES
# define MOCK_RVALUE_REFERENCES
# endif
#endif
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
# ifndef MOCK_NO_HDR_FUNCTIONAL
# define MOCK_HDR_FUNCTIONAL

View file

@ -19,7 +19,6 @@
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum.hpp>
#include <boost/preprocessor/array.hpp>
#include <boost/move/move.hpp>
#include <boost/type_traits/decay.hpp>
namespace mock
@ -147,7 +146,7 @@ namespace detail
const mock::constraint< detail::Name > Name;
#define MOCK_CONSTRAINT_ASSIGN(z, n, d) \
expected##n( boost::forward< T##n >(e##n) )
expected##n( std::forward< T##n >(e##n) )
#define MOCK_CONSTRAINT_UNWRAP_REF(z, n, d) \
boost::unwrap_ref( expected##n )
@ -166,13 +165,13 @@ namespace detail
BOOST_PP_ARRAY_ELEM(n, Args)
#define MOCK_CONSTRAINT_ARG(z, n, Args) \
BOOST_FWD_REF(T##n) BOOST_PP_ARRAY_ELEM(n, Args)
T##n&& BOOST_PP_ARRAY_ELEM(n, Args)
#define MOCK_CONSTRAINT_ARGS(z, n, Args) \
BOOST_FWD_REF(T##n) e##n
T##n&& e##n
#define MOCK_CONSTRAINT_PARAM(z, n, Args) \
boost::forward< T##n >( BOOST_PP_ARRAY_ELEM(n, Args) )
std::forward< T##n >( BOOST_PP_ARRAY_ELEM(n, Args) )
#define MOCK_NARY_CONSTRAINT(Name, n, Args, Expr) \
namespace detail \

View file

@ -190,7 +190,7 @@ namespace detail
return true;
}
template< typename Actual >
bool operator()( BOOST_RV_REF(Actual) actual,
bool operator()( Actual&& actual,
typename boost::disable_if<
boost::is_convertible<
const Actual*,
@ -199,7 +199,7 @@ namespace detail
>
>::type* = 0 ) const
{
*expected_ = boost::move( actual );
*expected_ = std::move( actual );
return true;
}
template< typename Actual >
@ -276,9 +276,9 @@ namespace detail
}
template< typename T >
constraint< detail::equal< typename detail::forward_type< T >::type > > equal( BOOST_FWD_REF(T) t )
constraint< detail::equal< T > > equal( T&& t )
{
return detail::equal< typename detail::forward_type< T >::type >( boost::forward< T >( t ) );
return detail::equal< T >( std::forward< T >( t ) );
}
template< typename T >

View file

@ -14,7 +14,6 @@
#include <boost/type_traits/remove_const.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/move/move.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/ref.hpp>
@ -105,19 +104,19 @@ namespace detail
}
template< typename Value >
void moves( BOOST_RV_REF(Value) v )
void moves( Value&& v )
{
this->set(
boost::bind(
&move< typename boost::remove_reference< Value >::type >,
boost::ref( store( boost::move( v ) ) ) ) );
boost::ref( store( std::move( v ) ) ) ) );
}
private:
template< typename Value >
static BOOST_RV_REF(Value) move( Value& t )
static Value&& move( Value& t )
{
return boost::move( t );
return std::move( t );
}
struct value : boost::noncopyable
{
@ -134,8 +133,8 @@ namespace detail
>::type
>::type value_type;
value_imp( BOOST_RV_REF(value_type) t )
: t_( boost::move( t ) )
value_imp( value_type&& t )
: t_( std::move( t ) )
{}
value_imp( const value_type& t )
: t_( t )
@ -148,9 +147,9 @@ namespace detail
};
template< typename T >
T& store( BOOST_RV_REF(T) t )
T& store( T&& t )
{
v_.reset( new value_imp< T >( boost::move( t ) ) );
v_.reset( new value_imp< T >( std::move( t ) ) );
return static_cast< value_imp< T >& >( *v_ ).t_;
}
template< typename T >

View file

@ -15,7 +15,7 @@
matcher< T##n, Constraint_##n > c##n##_;
#define MOCK_EXPECTATION_IS_VALID(z, n, d) \
BOOST_PP_IF(n, &&,) c##n##_( mock::detail::move_if_not_lvalue_reference< T##n >( a##n ) )
BOOST_PP_IF(n, &&,) c##n##_( std::forward< T##n >( a##n ) )
#define MOCK_EXPECTATION_SERIALIZE(z, n, d) \
BOOST_PP_IF(n, << ", " <<,) c##n##_
@ -24,7 +24,7 @@
BOOST_PP_IF(n, << ", " <<,) "any"
#define MOCK_EXPECTATION_PARAM(z, n, Args) \
mock::detail::move_if_not_lvalue_reference< T##n >( a##n )
std::forward< T##n >( a##n )
#define MOCK_REF_ARG(z, n, d) \
typename ref_arg< T##n >::type a##n

View file

@ -34,7 +34,6 @@
#include <boost/call_traits.hpp>
#include <boost/make_shared.hpp>
#include <boost/noncopyable.hpp>
#include <boost/move/move.hpp>
#include <boost/optional.hpp>
#include <ostream>
#include <vector>

View file

@ -25,7 +25,7 @@
<< lazy_expectations( this )
#define MOCK_MOVE(z, n, d) \
mock::detail::move_if_not_lvalue_reference< T##n >( t##n )
std::forward< T##n >( t##n )
namespace mock
{
@ -99,21 +99,22 @@ namespace detail
{
private:
typedef wrapper_base< R, expectation_type > base_type;
BOOST_MOVABLE_BUT_NOT_COPYABLE(wrapper)
public:
wrapper( const boost::shared_ptr< mutex >& m, expectation_type& e )
: base_type( e )
, lock_( m )
{}
wrapper( BOOST_RV_REF( wrapper ) x )
wrapper(const wrapper&) = delete;
wrapper( wrapper&& x )
: base_type( x )
, lock_( boost::move( x.lock_) )
, lock_( std::move( x.lock_) )
{}
wrapper& operator=( BOOST_RV_REF( wrapper ) x )
wrapper& operator=(const wrapper&) = delete;
wrapper& operator=( wrapper&& x )
{
static_cast< base_type& >( *this ) = x;
lock_ = boost::move( x.lock_ );
lock_ = std::move( x.lock_ );
return *this;
}
wrapper& once()
@ -200,9 +201,9 @@ namespace detail
this->e_->throws( t );
}
template< typename TT >
void moves( BOOST_RV_REF(TT) t )
void moves( TT&& t )
{
this->e_->moves( boost::move( t ) );
this->e_->moves( std::move( t ) );
}
lock lock_;

View file

@ -9,7 +9,7 @@
#include "function_impl_template.hpp"
#define MOCK_MOVE(z, n, d) \
mock::detail::move_if_not_lvalue_reference< T##n >( t##n )
std::forward< T##n >( t##n )
namespace mock
{

View file

@ -9,24 +9,14 @@
#ifndef MOCK_MOVE_HELPER_HPP_INCLUDED
#define MOCK_MOVE_HELPER_HPP_INCLUDED
#include "../config.hpp"
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_rvalue_reference.hpp>
#include <boost/type_traits/decay.hpp>
namespace mock
{
namespace detail
{
#ifdef MOCK_RVALUE_REFERENCES
template< typename T >
struct forward_type
{
typedef T type;
};
template< typename T >
struct ref_arg
{
@ -35,43 +25,6 @@ namespace detail
T,
typename boost::add_rvalue_reference< T >::type >::type type;
};
template< typename T >
inline T&& move_if_not_lvalue_reference(typename boost::remove_reference< T >::type& t)
{
return static_cast< T&& >(t);
}
template< typename T >
inline T&& move_if_not_lvalue_reference(typename boost::remove_reference< T >::type&& t)
{
return static_cast< T&& >(t);
}
#else
template< typename T >
struct forward_type
{
typedef typename boost::decay< const T >::type type;
};
template< class T>
struct forward_type< boost::rv< T > >
{
typedef T type;
};
template< typename T >
struct ref_arg
{
typedef typename boost::conditional<
boost::is_reference< T >::value,
T,
const typename boost::add_reference< T >::type >::type type;
};
template< typename T >
inline typename boost::remove_reference< T >::type& move_if_not_lvalue_reference(typename boost::remove_reference< T >::type& t)
{
return t;
}
#endif
}
}

View file

@ -11,7 +11,6 @@
#include "../config.hpp"
#include "singleton.hpp"
#include <boost/move/move.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
@ -38,9 +37,6 @@ namespace detail
struct lock
{
private:
BOOST_MOVABLE_BUT_NOT_COPYABLE(lock)
public:
lock( const boost::shared_ptr< mutex >& m )
: m_( m )
@ -52,13 +48,15 @@ namespace detail
if( m_ )
m_->unlock();
}
lock( BOOST_RV_REF( lock ) x )
lock( const lock& ) = delete;
lock( lock&& x )
: m_( x.m_ )
{
// Explicit reset to avoid unlock in destructor
x.m_.reset();
}
lock& operator=( BOOST_RV_REF( lock ) x )
lock& operator=( const lock& ) = delete;
lock& operator=( lock&& x )
{
m_ = x.m_;
x.m_.reset();
@ -86,29 +84,24 @@ namespace detail
};
// Dummy lock classes.
// Constructor + Destructor make it RAII classes for compilers and avoid unused variable warnings
struct scoped_lock : boost::noncopyable
struct scoped_lock
{
scoped_lock( mutex& )
{}
~scoped_lock()
{}
};
class lock : boost::noncopyable
class lock
{
private:
BOOST_MOVABLE_BUT_NOT_COPYABLE(lock)
public:
lock( const boost::shared_ptr< mutex >& )
{}
~lock()
{}
lock( BOOST_RV_REF( lock ) )
{}
lock& operator=( BOOST_RV_REF( lock ) )
{
return *this;
}
lock(const lock&) = delete;
lock( lock&& ) = default;
lock& operator=( const lock& ) = delete;
lock& operator=( lock&& ) = default;
};
}
} // mock

View file

@ -71,7 +71,7 @@ namespace mock
{}
bool operator()( typename detail::ref_arg< Actual >::type actual )
{
return c_( mock::detail::move_if_not_lvalue_reference< typename detail::ref_arg< Actual >::type >( actual ) );
return c_( std::forward< typename detail::ref_arg< Actual >::type >( actual ) );
}
friend std::ostream& operator<<(
std::ostream& s, const matcher& m )
@ -95,7 +95,7 @@ namespace mock
{}
bool operator()( typename detail::ref_arg< Actual >::type actual )
{
return c_( mock::detail::move_if_not_lvalue_reference< typename detail::ref_arg< Actual >::type >( actual ) );
return c_( std::forward< typename detail::ref_arg< Actual >::type >( actual ) );
}
friend std::ostream& operator<<(
std::ostream& s, const matcher& m )

View file

@ -87,7 +87,7 @@
BOOST_PP_COMMA_IF(n) d, n >::type >( p##n )
#define MOCK_FORWARD_PARAMS(n, S, tpn) \
BOOST_PP_REPEAT(n, MOCK_FORWARD_PARAM, \
mock::detail::move_if_not_lvalue_reference< MOCK_PARAM(S, tpn))
std::forward< MOCK_PARAM(S, tpn))
#define MOCK_METHOD_AUX(M, n, S, t, c, tpn) \
MOCK_DECL(M, n, S, c, tpn) \
{ \