From 8cfe0661bf6cf9f5121935f6788f5ff530d0ee15 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 14 Feb 2024 12:08:07 +0000 Subject: [PATCH] provide alternative action constructor for ActionInterface objects already managed by shared_ptr --- googlemock/include/gmock/gmock-actions.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index fab99933..8d33fb4a 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -770,9 +770,13 @@ class Action { Init(::std::forward(fun), IsCompatibleFunctor()); } - // Constructs an Action from its implementation. + // Constructs an Action from shared pointer. + explicit Action(::std::shared_ptr> impl) + : fun_(ActionAdapter{impl}) {} + + // Constructs an Action from its implementation (now delegating). explicit Action(ActionInterface* impl) - : fun_(ActionAdapter{::std::shared_ptr>(impl)}) {} + : Action{::std::shared_ptr>(impl)} {} // This constructor allows us to turn an Action object into an // Action, as long as F's arguments can be implicitly converted