mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Use make_* functions instead of new
This commit is contained in:
parent
558e1ca135
commit
f3d6564d2b
3 changed files with 12 additions and 18 deletions
|
|
@ -124,19 +124,19 @@ namespace detail
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T& store( T&& 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_;
|
return static_cast< value_imp< T >& >( *v_ ).t_;
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T& store( const T& 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_;
|
return static_cast< value_imp< T >& >( *v_ ).t_;
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
std::remove_reference_t< Result >& store( T* 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_;
|
return static_cast< value_imp< Result >& >( *v_ ).t_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -178,22 +178,22 @@ namespace detail
|
||||||
expectation& with(
|
expectation& with(
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
|
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
|
||||||
{
|
{
|
||||||
matcher_.reset(
|
matcher_ = std::make_shared<
|
||||||
new single_matcher<
|
single_matcher<
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
#if MOCK_NUM_ARGS > 1
|
#if MOCK_NUM_ARGS > 1
|
||||||
template< typename Constraint >
|
template< typename Constraint >
|
||||||
expectation& with( const Constraint& c )
|
expectation& with( const Constraint& c )
|
||||||
{
|
{
|
||||||
matcher_.reset(
|
matcher_ = std::make_shared<
|
||||||
new multi_matcher<
|
multi_matcher<
|
||||||
Constraint,
|
Constraint,
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
>( c ) );
|
>>( c );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#define MOCK_STREAM_HPP_INCLUDED
|
#define MOCK_STREAM_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
|
|
@ -69,16 +70,9 @@ namespace conversion
|
||||||
struct any
|
struct any
|
||||||
{
|
{
|
||||||
template< typename T >
|
template< typename T >
|
||||||
any( const T& t )
|
any( const T& t ): h_( std::make_unique< holder_imp<T> >( t ) )
|
||||||
: h_( new holder_imp< T >( t ) )
|
|
||||||
{}
|
{}
|
||||||
any(const any&) = delete;
|
std::unique_ptr<holder> h_;
|
||||||
any& operator=(const any&) = delete;
|
|
||||||
~any()
|
|
||||||
{
|
|
||||||
delete h_;
|
|
||||||
}
|
|
||||||
holder* h_;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue