mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Use std smart pointers in code
This commit is contained in:
parent
2f72d5639e
commit
35fa6e63e6
15 changed files with 53 additions and 55 deletions
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
#include "../config.hpp"
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mock
|
||||
|
|
@ -154,7 +154,7 @@ namespace detail
|
|||
return static_cast< value_imp< Result >& >( *v_ ).t_;
|
||||
}
|
||||
|
||||
boost::shared_ptr< value > v_;
|
||||
std::shared_ptr< value > v_;
|
||||
};
|
||||
|
||||
template< typename Signature >
|
||||
|
|
|
|||
|
|
@ -133,9 +133,9 @@ namespace detail
|
|||
{
|
||||
public:
|
||||
expectation()
|
||||
: invocation_( boost::make_shared< unlimited >() )
|
||||
: invocation_( std::make_shared< unlimited >() )
|
||||
, matcher_(
|
||||
boost::make_shared<
|
||||
std::make_shared<
|
||||
default_matcher<
|
||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||
>
|
||||
|
|
@ -144,9 +144,9 @@ namespace detail
|
|||
, line_( 0 )
|
||||
{}
|
||||
expectation( const char* file, int line )
|
||||
: invocation_( boost::make_shared< unlimited >() )
|
||||
: invocation_( std::make_shared< unlimited >() )
|
||||
, matcher_(
|
||||
boost::make_shared<
|
||||
std::make_shared<
|
||||
default_matcher<
|
||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||
>
|
||||
|
|
@ -167,7 +167,7 @@ namespace detail
|
|||
(*it)->remove( this );
|
||||
}
|
||||
|
||||
void invoke( const boost::shared_ptr< invocation >& i )
|
||||
void invoke( const std::shared_ptr< invocation >& i )
|
||||
{
|
||||
invocation_ = i;
|
||||
}
|
||||
|
|
@ -253,12 +253,12 @@ namespace detail
|
|||
|
||||
private:
|
||||
typedef std::vector<
|
||||
boost::shared_ptr< sequence_impl >
|
||||
std::shared_ptr< sequence_impl >
|
||||
> sequences_type;
|
||||
typedef sequences_type::const_iterator sequences_cit;
|
||||
|
||||
boost::shared_ptr< invocation > invocation_;
|
||||
boost::shared_ptr<
|
||||
std::shared_ptr< invocation > invocation_;
|
||||
std::shared_ptr<
|
||||
matcher_base<
|
||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||
>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
#include <boost/test/utils/lazy_ostream.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <ostream>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace detail
|
|||
template< typename R
|
||||
BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
|
||||
class function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
||||
: public verifiable, public boost::enable_shared_from_this<
|
||||
: public verifiable, public std::enable_shared_from_this<
|
||||
function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )> >
|
||||
{
|
||||
public:
|
||||
|
|
@ -47,7 +47,7 @@ namespace detail
|
|||
: context_( 0 )
|
||||
, valid_( true )
|
||||
, exceptions_( exceptions() )
|
||||
, mutex_( boost::make_shared< mutex >() )
|
||||
, mutex_( std::make_shared< mutex >() )
|
||||
{}
|
||||
virtual ~function_impl()
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@ namespace detail
|
|||
{
|
||||
lock _( mutex_ );
|
||||
valid_ = true;
|
||||
boost::shared_ptr< function_impl > guard =
|
||||
std::shared_ptr< function_impl > guard =
|
||||
this->shared_from_this();
|
||||
expectations_.clear();
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ namespace detail
|
|||
typedef wrapper_base< R, expectation_type > base_type;
|
||||
|
||||
public:
|
||||
wrapper( const boost::shared_ptr< mutex >& m, expectation_type& e )
|
||||
wrapper( const std::shared_ptr< mutex >& m, expectation_type& e )
|
||||
: base_type( e )
|
||||
, lock_( m )
|
||||
{}
|
||||
|
|
@ -119,36 +119,36 @@ namespace detail
|
|||
}
|
||||
wrapper& once()
|
||||
{
|
||||
this->e_->invoke( boost::make_shared< detail::once >() );
|
||||
this->e_->invoke( std::make_shared< detail::once >() );
|
||||
return *this;
|
||||
}
|
||||
wrapper& never()
|
||||
{
|
||||
this->e_->invoke( boost::make_shared< detail::never >() );
|
||||
this->e_->invoke( std::make_shared< detail::never >() );
|
||||
return *this;
|
||||
}
|
||||
wrapper& exactly( std::size_t count )
|
||||
{
|
||||
this->e_->invoke(
|
||||
boost::make_shared< detail::exactly >( count ) );
|
||||
std::make_shared< detail::exactly >( count ) );
|
||||
return *this;
|
||||
}
|
||||
wrapper& at_least( std::size_t min )
|
||||
{
|
||||
this->e_->invoke(
|
||||
boost::make_shared< detail::at_least >( min ) );
|
||||
std::make_shared< detail::at_least >( min ) );
|
||||
return *this;
|
||||
}
|
||||
wrapper& at_most( std::size_t max )
|
||||
{
|
||||
this->e_->invoke(
|
||||
boost::make_shared< detail::at_most >( max ) );
|
||||
std::make_shared< detail::at_most >( max ) );
|
||||
return *this;
|
||||
}
|
||||
wrapper& between( std::size_t min, std::size_t max )
|
||||
{
|
||||
this->e_->invoke(
|
||||
boost::make_shared< detail::between >( min, max ) );
|
||||
std::make_shared< detail::between >( min, max ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ namespace detail
|
|||
context* context_;
|
||||
mutable bool valid_;
|
||||
const int exceptions_;
|
||||
const boost::shared_ptr< mutex > mutex_;
|
||||
const std::shared_ptr< mutex > mutex_;
|
||||
};
|
||||
}
|
||||
} // mock
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace detail
|
|||
|
||||
public:
|
||||
function()
|
||||
: impl_( boost::make_shared< impl_type >() )
|
||||
: impl_( std::make_shared< impl_type >() )
|
||||
{}
|
||||
|
||||
bool verify() const
|
||||
|
|
@ -98,7 +98,7 @@ namespace detail
|
|||
}
|
||||
|
||||
private:
|
||||
boost::shared_ptr< impl_type > impl_;
|
||||
std::shared_ptr< impl_type > impl_;
|
||||
};
|
||||
}
|
||||
} // mock
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "../config.hpp"
|
||||
#include "singleton.hpp"
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <memory>
|
||||
|
||||
#ifdef MOCK_THREAD_SAFE
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ namespace detail
|
|||
struct lock
|
||||
{
|
||||
public:
|
||||
lock( const boost::shared_ptr< mutex >& m )
|
||||
lock( const std::shared_ptr< mutex >& m )
|
||||
: m_( m )
|
||||
{
|
||||
m_->lock();
|
||||
|
|
@ -64,7 +64,7 @@ namespace detail
|
|||
}
|
||||
|
||||
private:
|
||||
boost::shared_ptr< mutex > m_;
|
||||
std::shared_ptr< mutex > m_;
|
||||
};
|
||||
}
|
||||
} // mock
|
||||
|
|
@ -94,7 +94,7 @@ namespace detail
|
|||
class lock
|
||||
{
|
||||
public:
|
||||
lock( const boost::shared_ptr< mutex >& )
|
||||
lock( const std::shared_ptr< mutex >& )
|
||||
{}
|
||||
~lock()
|
||||
{}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
#include "child.hpp"
|
||||
#include "mutex.hpp"
|
||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace mock
|
||||
|
|
@ -26,11 +24,11 @@ namespace mock
|
|||
namespace detail
|
||||
{
|
||||
class object_impl : public context, public verifiable,
|
||||
public boost::enable_shared_from_this< object_impl >
|
||||
public std::enable_shared_from_this< object_impl >
|
||||
{
|
||||
public:
|
||||
object_impl()
|
||||
: mutex_( boost::make_shared< mutex >() )
|
||||
: mutex_( std::make_shared< mutex >() )
|
||||
{}
|
||||
|
||||
virtual void add( const void* /*p*/, verifiable& v,
|
||||
|
|
@ -75,7 +73,7 @@ namespace detail
|
|||
virtual void reset()
|
||||
{
|
||||
lock _( mutex_ );
|
||||
boost::shared_ptr< object_impl > guard = shared_from_this();
|
||||
std::shared_ptr< object_impl > guard = shared_from_this();
|
||||
group_.reset();
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +84,7 @@ namespace detail
|
|||
group group_;
|
||||
parent parent_;
|
||||
children_t children_;
|
||||
const boost::shared_ptr< mutex > mutex_;
|
||||
const std::shared_ptr< mutex > mutex_;
|
||||
};
|
||||
}
|
||||
} // mock
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
#include "../config.hpp"
|
||||
#include "mutex.hpp"
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace mock
|
||||
|
|
@ -24,7 +24,7 @@ namespace detail
|
|||
{
|
||||
public:
|
||||
sequence_impl()
|
||||
: mutex_( boost::make_shared< mutex >() )
|
||||
: mutex_( std::make_shared< mutex >() )
|
||||
{}
|
||||
|
||||
void add( void* e )
|
||||
|
|
@ -59,7 +59,7 @@ namespace detail
|
|||
typedef std::vector< void* > elements_type;
|
||||
|
||||
elements_type elements_;
|
||||
const boost::shared_ptr< mutex > mutex_;
|
||||
const std::shared_ptr< mutex > mutex_;
|
||||
};
|
||||
}
|
||||
} // mock
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
# define MOCK_TYPEID( t ) BOOST_SP_TYPEID(t)
|
||||
# define MOCK_TYPEINFO boost::detail::sp_typeinfo
|
||||
#endif
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <stdexcept>
|
||||
#include <memory>
|
||||
#include <typeinfo>
|
||||
#include <ostream>
|
||||
#ifdef __GNUC__
|
||||
|
|
@ -57,7 +57,7 @@ namespace detail
|
|||
const char* name = info.name();
|
||||
#ifdef __GNUC__
|
||||
int status = 0;
|
||||
boost::shared_ptr< char > demangled(
|
||||
std::shared_ptr< char > demangled(
|
||||
abi::__cxa_demangle( name, 0, 0, &status ),
|
||||
&std::free );
|
||||
if( ! status && demangled )
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
#include "detail/type_name.hpp"
|
||||
#include "detail/object_impl.hpp"
|
||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mock
|
||||
|
|
@ -45,13 +45,13 @@ namespace detail
|
|||
{
|
||||
public:
|
||||
object()
|
||||
: impl_( boost::make_shared< detail::object_impl >() )
|
||||
: impl_( std::make_shared< detail::object_impl >() )
|
||||
{}
|
||||
protected:
|
||||
~object()
|
||||
{}
|
||||
public:
|
||||
boost::shared_ptr< detail::object_impl > impl_;
|
||||
std::shared_ptr< detail::object_impl > impl_;
|
||||
};
|
||||
|
||||
namespace detail
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "config.hpp"
|
||||
#include "detail/sequence_impl.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace mock
|
||||
{
|
||||
|
|
@ -18,10 +19,10 @@ namespace mock
|
|||
{
|
||||
public:
|
||||
sequence()
|
||||
: impl_( boost::make_shared< detail::sequence_impl >() )
|
||||
: impl_( std::make_shared< detail::sequence_impl >() )
|
||||
{}
|
||||
|
||||
boost::shared_ptr< detail::sequence_impl > impl_;
|
||||
std::shared_ptr< detail::sequence_impl > impl_;
|
||||
};
|
||||
} // mock
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue