Replaced new with boost::make_shared

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@634 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2013-05-03 20:16:50 +00:00
parent 26540da771
commit 4ee2837dcd
7 changed files with 23 additions and 25 deletions

View file

@ -15,7 +15,7 @@
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/function.hpp>
#include <boost/ref.hpp>
@ -41,7 +41,7 @@ namespace detail
BOOST_DEDUCED_TYPENAME boost::enable_if<
boost::is_convertible< Value, result_type > >::type* = 0 )
{
r_.reset( new result_type( v ) );
r_ = boost::make_shared< result_type >( v );
f_ = lambda_type::make_val( boost::ref( *r_ ) );
}
template< typename Value >
@ -52,7 +52,7 @@ namespace detail
// if an error is generated by the line below it means a value
// passed to 'returns' was of the wrong type as it cannot be
// used to copy construct a Result
r_.reset( new Value( v ) );
r_ = boost::make_shared< Value >( v );
f_ = lambda_type::make_val( boost::ref( *r_ ) );
}
template< typename Y >

View file

@ -12,7 +12,7 @@
#include "../config.hpp"
#include "invocation.hpp"
#include "../sequence.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <vector>
namespace mock
@ -23,7 +23,7 @@ namespace detail
{
public:
expectation_base()
: i_( new unlimited() )
: i_( boost::make_shared< unlimited >() )
, file_( "unknown location" )
, line_( 0 )
{}
@ -73,11 +73,6 @@ namespace detail
(*it)->remove( this );
}
void expect( invocation* i )
{
i_.reset( i );
}
void add( boost::shared_ptr< sequence_impl > s )
{
s->add( this );

View file

@ -11,10 +11,12 @@
#define MOCK_EXPECTATION_INITIALIZE(z, n, d) \
BOOST_PP_COMMA_IF(n) c##n##_( \
new matcher< arg##n##_type, constraint< any > >( mock::any ) )
boost::make_shared< \
matcher< arg##n##_type, constraint< any > > >( mock::any ) )
#define MOCK_EXPECTATION_WITH(z, n, d) \
c##n##_.reset( new matcher< arg##n##_type, Constraint_##n >( c##n ) );
c##n##_ = boost::make_shared< \
matcher< arg##n##_type, Constraint_##n > >( c##n );
#define MOCK_EXPECTATION_MEMBER(z, n, d) \
boost::shared_ptr< matcher_base< arg##n##_type > > c##n##_;
@ -73,32 +75,32 @@ namespace detail
}
expectation& once()
{
expect( new detail::once() );
i_ = boost::make_shared< detail::once >();
return *this;
}
expectation& never()
{
expect( new detail::never() );
i_ = boost::make_shared< detail::never >();
return *this;
}
expectation& exactly( std::size_t count )
{
expect( new detail::exactly( count ) );
i_ = boost::make_shared< detail::exactly >( count );
return *this;
}
expectation& at_least( std::size_t min )
{
expect( new detail::at_least( min ) );
i_ = boost::make_shared< detail::exactly >( min );
return *this;
}
expectation& at_most( std::size_t max )
{
expect( new detail::at_most( max ) );
i_ = boost::make_shared< detail::exactly >( max );
return *this;
}
expectation& between( std::size_t min, std::size_t max )
{
expect( new detail::between( min, max ) );
i_ = boost::make_shared< detail::between >( min, max );
return *this;
}
@ -116,7 +118,8 @@ namespace detail
;
}
private:
BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_EXPECTATION_MEMBER, BOOST_PP_EMPTY)
BOOST_PP_REPEAT(
MOCK_NUM_ARGS, MOCK_EXPECTATION_MEMBER, BOOST_PP_EMPTY)
};
}
} // mock

View file

@ -36,7 +36,7 @@ namespace detail
public:
function()
: impl_( new impl_type() )
: impl_( boost::make_shared< impl_type >() )
{}
bool verify() const

View file

@ -16,7 +16,7 @@
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/optional.hpp>
namespace mock
@ -48,7 +48,7 @@ namespace detail
{
public:
object()
: impl_( new detail::object_impl() )
: impl_( boost::make_shared< detail::object_impl >() )
{}
protected:
~object()

View file

@ -11,7 +11,7 @@
#include "config.hpp"
#include "detail/sequence_impl.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
namespace mock
{
@ -19,7 +19,7 @@ namespace mock
{
public:
sequence()
: impl_( new detail::sequence_impl() )
: impl_( boost::make_shared< detail::sequence_impl >() )
{}
boost::shared_ptr< detail::sequence_impl > impl_;

View file

@ -68,7 +68,7 @@ namespace conversion
{
template< typename T >
any( const T& t )
: h_( new holder_imp< T >( t ) )
: h_( boost::make_shared< holder_imp< T > >( t ) )
{}
~any()
{