aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock/include/gmock/gmock-spec-builders.h
diff options
context:
space:
mode:
Diffstat (limited to 'googlemock/include/gmock/gmock-spec-builders.h')
-rw-r--r--googlemock/include/gmock/gmock-spec-builders.h31
1 files changed, 11 insertions, 20 deletions
diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h
index 5d4b73ba..7759cb35 100644
--- a/googlemock/include/gmock/gmock-spec-builders.h
+++ b/googlemock/include/gmock/gmock-spec-builders.h
@@ -62,6 +62,7 @@
#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#include <map>
+#include <memory>
#include <set>
#include <sstream>
#include <string>
@@ -219,8 +220,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
protected:
typedef std::vector<const void*> UntypedOnCallSpecs;
- typedef std::vector<internal::linked_ptr<ExpectationBase> >
- UntypedExpectations;
+ using UntypedExpectations = std::vector<std::shared_ptr<ExpectationBase>>;
// Returns an Expectation object that references and co-owns exp,
// which must be an expectation on this mock function.
@@ -498,12 +498,7 @@ class GTEST_API_ Mock {
// - Constness is shallow: a const Expectation object itself cannot
// be modified, but the mutable methods of the ExpectationBase
// object it references can be called via expectation_base().
-// - The constructors and destructor are defined out-of-line because
-// the Symbian WINSCW compiler wants to otherwise instantiate them
-// when it sees this class definition, at which point it doesn't have
-// ExpectationBase available yet, leading to incorrect destruction
-// in the linked_ptr (or compilation errors if using a checking
-// linked_ptr).
+
class GTEST_API_ Expectation {
public:
// Constructs a null object that doesn't reference any expectation.
@@ -555,16 +550,15 @@ class GTEST_API_ Expectation {
typedef ::std::set<Expectation, Less> Set;
Expectation(
- const internal::linked_ptr<internal::ExpectationBase>& expectation_base);
+ const std::shared_ptr<internal::ExpectationBase>& expectation_base);
// Returns the expectation this object references.
- const internal::linked_ptr<internal::ExpectationBase>&
- expectation_base() const {
+ const std::shared_ptr<internal::ExpectationBase>& expectation_base() const {
return expectation_base_;
}
- // A linked_ptr that co-owns the expectation this handle references.
- internal::linked_ptr<internal::ExpectationBase> expectation_base_;
+ // A shared_ptr that co-owns the expectation this handle references.
+ std::shared_ptr<internal::ExpectationBase> expectation_base_;
};
// A set of expectation handles. Useful in the .After() clause of
@@ -646,11 +640,8 @@ class GTEST_API_ Sequence {
void AddExpectation(const Expectation& expectation) const;
private:
- // The last expectation in this sequence. We use a linked_ptr here
- // because Sequence objects are copyable and we want the copies to
- // be aliases. The linked_ptr allows the copies to co-own and share
- // the same Expectation object.
- internal::linked_ptr<Expectation> last_expectation_;
+ // The last expectation in this sequence.
+ std::shared_ptr<Expectation> last_expectation_;
}; // class Sequence
// An object of this type causes all EXPECT_CALL() statements
@@ -873,7 +864,7 @@ class GTEST_API_ ExpectationBase {
Cardinality cardinality_; // The cardinality of the expectation.
// The immediate pre-requisites (i.e. expectations that must be
// satisfied before this expectation can be matched) of this
- // expectation. We use linked_ptr in the set because we want an
+ // expectation. We use std::shared_ptr in the set because we want an
// Expectation object to be co-owned by its FunctionMocker and its
// successors. This allows multiple mock objects to be deleted at
// different times.
@@ -1631,7 +1622,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
TypedExpectation<F>* const expectation =
new TypedExpectation<F>(this, file, line, source_text, m);
- const linked_ptr<ExpectationBase> untyped_expectation(expectation);
+ const std::shared_ptr<ExpectationBase> untyped_expectation(expectation);
// See the definition of untyped_expectations_ for why access to
// it is unprotected here.
untyped_expectations_.push_back(untyped_expectation);