diff --git a/turtle/detail/action.hpp b/turtle/detail/action.hpp index 4e45c59..ddfde74 100644 --- a/turtle/detail/action.hpp +++ b/turtle/detail/action.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -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 > diff --git a/turtle/detail/expectation_base.hpp b/turtle/detail/expectation_base.hpp index c4c11d2..ba77849 100644 --- a/turtle/detail/expectation_base.hpp +++ b/turtle/detail/expectation_base.hpp @@ -12,7 +12,7 @@ #include "../config.hpp" #include "invocation.hpp" #include "../sequence.hpp" -#include +#include #include 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 ); diff --git a/turtle/detail/expectation_template.hpp b/turtle/detail/expectation_template.hpp index a1ca5e6..3d6f0bb 100644 --- a/turtle/detail/expectation_template.hpp +++ b/turtle/detail/expectation_template.hpp @@ -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 diff --git a/turtle/detail/function_template.hpp b/turtle/detail/function_template.hpp index 4adc71e..ac6d61a 100644 --- a/turtle/detail/function_template.hpp +++ b/turtle/detail/function_template.hpp @@ -36,7 +36,7 @@ namespace detail public: function() - : impl_( new impl_type() ) + : impl_( boost::make_shared< impl_type >() ) {} bool verify() const diff --git a/turtle/object.hpp b/turtle/object.hpp index 5969bd2..4df21fb 100644 --- a/turtle/object.hpp +++ b/turtle/object.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include namespace mock @@ -48,7 +48,7 @@ namespace detail { public: object() - : impl_( new detail::object_impl() ) + : impl_( boost::make_shared< detail::object_impl >() ) {} protected: ~object() diff --git a/turtle/sequence.hpp b/turtle/sequence.hpp index 247a816..9ba933b 100644 --- a/turtle/sequence.hpp +++ b/turtle/sequence.hpp @@ -11,7 +11,7 @@ #include "config.hpp" #include "detail/sequence_impl.hpp" -#include +#include 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_; diff --git a/turtle/stream.hpp b/turtle/stream.hpp index 89ac224..357eca5 100644 --- a/turtle/stream.hpp +++ b/turtle/stream.hpp @@ -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() {