From f3d6564d2bab37aa1475b7bd270d508b7e736c32 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Jul 2020 19:33:00 +0200 Subject: [PATCH] Use make_* functions instead of new --- include/turtle/detail/action.hpp | 6 +++--- include/turtle/detail/expectation_template.hpp | 12 ++++++------ include/turtle/stream.hpp | 12 +++--------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/include/turtle/detail/action.hpp b/include/turtle/detail/action.hpp index ac886a4..204b4f2 100644 --- a/include/turtle/detail/action.hpp +++ b/include/turtle/detail/action.hpp @@ -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 >( 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 ); 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 >( t ); return static_cast< value_imp< Result >& >( *v_ ).t_; } diff --git a/include/turtle/detail/expectation_template.hpp b/include/turtle/detail/expectation_template.hpp index 4424847..ea2926a 100644 --- a/include/turtle/detail/expectation_template.hpp +++ b/include/turtle/detail/expectation_template.hpp @@ -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 diff --git a/include/turtle/stream.hpp b/include/turtle/stream.hpp index 3ea47db..9f5b0a1 100644 --- a/include/turtle/stream.hpp +++ b/include/turtle/stream.hpp @@ -10,6 +10,7 @@ #define MOCK_STREAM_HPP_INCLUDED #include "config.hpp" +#include #include 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 ) ) {} - any(const any&) = delete; - any& operator=(const any&) = delete; - ~any() - { - delete h_; - } - holder* h_; + std::unique_ptr h_; }; } }