From b57c703963be1ca9749b902c49083beac56648aa Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 24 Oct 2018 22:04:43 -0400 Subject: Googletest export Remove linked_ptr and use std::shared_ptr instead PiperOrigin-RevId: 218618184 --- googlemock/include/gmock/gmock-actions.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'googlemock/include/gmock/gmock-actions.h') diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index e4af9d2d..d4af9490 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -42,7 +42,6 @@ #endif #include -#include #include #include @@ -347,7 +346,9 @@ class ActionInterface { // An Action is a copyable and IMMUTABLE (except by assignment) // object that represents an action to be taken when a mock function // of type F is called. The implementation of Action is just a -// std::shared_ptr to const ActionInterface. Don't inherit from Action! +// linked_ptr to const ActionInterface, so copying is fairly cheap. +// Don't inherit from Action! +// // You can view an object implementing ActionInterface as a // concrete action (including its current state), and an Action // object as a handle to it. @@ -424,7 +425,7 @@ class Action { #if GTEST_LANG_CXX11 ::std::function fun_; #endif - std::shared_ptr> impl_; + internal::linked_ptr > impl_; }; // The PolymorphicAction class template makes it easy to implement a @@ -518,7 +519,7 @@ class ActionAdaptor : public ActionInterface { } private: - const std::shared_ptr> impl_; + const internal::linked_ptr > impl_; GTEST_DISALLOW_ASSIGN_(ActionAdaptor); }; @@ -600,7 +601,7 @@ class ReturnAction { // Result to call. ImplicitCast_ forces the compiler to convert R to // Result without considering explicit constructors, thus resolving the // ambiguity. value_ is then initialized using its copy constructor. - explicit Impl(const std::shared_ptr& value) + explicit Impl(const linked_ptr& value) : value_before_cast_(*value), value_(ImplicitCast_(value_before_cast_)) {} @@ -625,7 +626,7 @@ class ReturnAction { typedef typename Function::Result Result; typedef typename Function::ArgumentTuple ArgumentTuple; - explicit Impl(const std::shared_ptr& wrapper) + explicit Impl(const linked_ptr& wrapper) : performed_(false), wrapper_(wrapper) {} virtual Result Perform(const ArgumentTuple&) { @@ -637,12 +638,12 @@ class ReturnAction { private: bool performed_; - const std::shared_ptr wrapper_; + const linked_ptr wrapper_; GTEST_DISALLOW_ASSIGN_(Impl); }; - const std::shared_ptr value_; + const linked_ptr value_; GTEST_DISALLOW_ASSIGN_(ReturnAction); }; @@ -865,7 +866,7 @@ class SetArgumentPointeeAction { } private: - const std::shared_ptr proto_; + const internal::linked_ptr proto_; GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction); }; @@ -930,7 +931,7 @@ class InvokeCallbackWithoutArgsAction { Result Perform(const ArgumentTuple&) const { return callback_->Run(); } private: - const std::shared_ptr callback_; + const internal::linked_ptr callback_; GTEST_DISALLOW_ASSIGN_(InvokeCallbackWithoutArgsAction); }; -- cgit v1.2.3