summaryrefslogtreecommitdiffstats
path: root/googlemock/include/gmock/gmock-actions.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-10-25 02:04:43 (GMT)
committerGennadiy Civil <misterg@google.com>2018-10-26 18:19:59 (GMT)
commitb57c703963be1ca9749b902c49083beac56648aa (patch)
treeb7f5433fce3803d121c9963dc69bcdeec4d35f7c /googlemock/include/gmock/gmock-actions.h
parenta50e4f05b3d84c6a014c59a24263328242cc8236 (diff)
downloadgoogletest-b57c703963be1ca9749b902c49083beac56648aa.zip
googletest-b57c703963be1ca9749b902c49083beac56648aa.tar.gz
googletest-b57c703963be1ca9749b902c49083beac56648aa.tar.bz2
Googletest export
Remove linked_ptr and use std::shared_ptr instead PiperOrigin-RevId: 218618184
Diffstat (limited to 'googlemock/include/gmock/gmock-actions.h')
-rw-r--r--googlemock/include/gmock/gmock-actions.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index e4af9d2..d4af949 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -42,7 +42,6 @@
#endif
#include <algorithm>
-#include <memory>
#include <string>
#include <utility>
@@ -347,7 +346,9 @@ class ActionInterface {
// An Action<F> 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<T> is just a
-// std::shared_ptr to const ActionInterface<T>. Don't inherit from Action!
+// linked_ptr to const ActionInterface<T>, so copying is fairly cheap.
+// Don't inherit from Action!
+//
// You can view an object implementing ActionInterface<F> as a
// concrete action (including its current state), and an Action<F>
// object as a handle to it.
@@ -424,7 +425,7 @@ class Action {
#if GTEST_LANG_CXX11
::std::function<F> fun_;
#endif
- std::shared_ptr<ActionInterface<F>> impl_;
+ internal::linked_ptr<ActionInterface<F> > impl_;
};
// The PolymorphicAction class template makes it easy to implement a
@@ -518,7 +519,7 @@ class ActionAdaptor : public ActionInterface<F1> {
}
private:
- const std::shared_ptr<ActionInterface<F2>> impl_;
+ const internal::linked_ptr<ActionInterface<F2> > 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<R>& value)
+ explicit Impl(const linked_ptr<R>& value)
: value_before_cast_(*value),
value_(ImplicitCast_<Result>(value_before_cast_)) {}
@@ -625,7 +626,7 @@ class ReturnAction {
typedef typename Function<F>::Result Result;
typedef typename Function<F>::ArgumentTuple ArgumentTuple;
- explicit Impl(const std::shared_ptr<R>& wrapper)
+ explicit Impl(const linked_ptr<R>& wrapper)
: performed_(false), wrapper_(wrapper) {}
virtual Result Perform(const ArgumentTuple&) {
@@ -637,12 +638,12 @@ class ReturnAction {
private:
bool performed_;
- const std::shared_ptr<R> wrapper_;
+ const linked_ptr<R> wrapper_;
GTEST_DISALLOW_ASSIGN_(Impl);
};
- const std::shared_ptr<R> value_;
+ const linked_ptr<R> value_;
GTEST_DISALLOW_ASSIGN_(ReturnAction);
};
@@ -865,7 +866,7 @@ class SetArgumentPointeeAction<N, Proto, true> {
}
private:
- const std::shared_ptr<Proto> proto_;
+ const internal::linked_ptr<Proto> proto_;
GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
};
@@ -930,7 +931,7 @@ class InvokeCallbackWithoutArgsAction {
Result Perform(const ArgumentTuple&) const { return callback_->Run(); }
private:
- const std::shared_ptr<CallbackType> callback_;
+ const internal::linked_ptr<CallbackType> callback_;
GTEST_DISALLOW_ASSIGN_(InvokeCallbackWithoutArgsAction);
};