Use make_* functions instead of new

This commit is contained in:
Alexander Grund 2020-07-14 19:33:00 +02:00
parent 558e1ca135
commit f3d6564d2b
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
3 changed files with 12 additions and 18 deletions

View file

@ -124,19 +124,19 @@ namespace detail
template< typename T >
T& store( T&& t )
{
v_.reset( new value_imp< T >( std::move( t ) ) );
v_ = std::make_shared< value_imp<T> >( std::move( t ) );
return static_cast< value_imp< T >& >( *v_ ).t_;
}
template< typename T >
T& store( const T& t )
{
v_.reset( new value_imp< T >( t ) );
v_ = std::make_shared< value_imp<T> >( t );
return static_cast< value_imp< T >& >( *v_ ).t_;
}
template< typename T >
std::remove_reference_t< Result >& store( T* t )
{
v_.reset( new value_imp< Result >( t ) );
v_ = std::make_shared< value_imp<Result> >( t );
return static_cast< value_imp< Result >& >( *v_ ).t_;
}

View file

@ -178,22 +178,22 @@ namespace detail
expectation& with(
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
{
matcher_.reset(
new single_matcher<
matcher_ = std::make_shared<
single_matcher<
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
>( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) ) );
>>( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) );
return *this;
}
#if MOCK_NUM_ARGS > 1
template< typename Constraint >
expectation& with( const Constraint& c )
{
matcher_.reset(
new multi_matcher<
matcher_ = std::make_shared<
multi_matcher<
Constraint,
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
>( c ) );
>>( c );
return *this;
}
#endif

View file

@ -10,6 +10,7 @@
#define MOCK_STREAM_HPP_INCLUDED
#include "config.hpp"
#include <memory>
#include <ostream>
namespace mock
@ -69,16 +70,9 @@ namespace conversion
struct any
{
template< typename T >
any( const T& t )
: h_( new holder_imp< T >( t ) )
any( const T& t ): h_( std::make_unique< holder_imp<T> >( t ) )
{}
any(const any&) = delete;
any& operator=(const any&) = delete;
~any()
{
delete h_;
}
holder* h_;
std::unique_ptr<holder> h_;
};
}
}