diff options
author | misterg <misterg@google.com> | 2018-10-24 21:02:11 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2018-10-26 18:19:51 (GMT) |
commit | a50e4f05b3d84c6a014c59a24263328242cc8236 (patch) | |
tree | 6b262d5156f04387467abbc48b4e5e98ec94e382 /googlemock/include/gmock/gmock-matchers.h | |
parent | 8ec8ce1c8a51076950bfa7a7886d95f4c8aed11b (diff) | |
download | googletest-a50e4f05b3d84c6a014c59a24263328242cc8236.zip googletest-a50e4f05b3d84c6a014c59a24263328242cc8236.tar.gz googletest-a50e4f05b3d84c6a014c59a24263328242cc8236.tar.bz2 |
Googletest export
Remove linked_ptr and use std::shared_ptr instead
PiperOrigin-RevId: 218571466
Diffstat (limited to 'googlemock/include/gmock/gmock-matchers.h')
-rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 6e8bc03..95bc22c 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -43,14 +43,15 @@ #include <algorithm> #include <iterator> #include <limits> +#include <memory> #include <ostream> // NOLINT #include <sstream> #include <string> #include <utility> #include <vector> -#include "gtest/gtest.h" #include "gmock/internal/gmock-internal-utils.h" #include "gmock/internal/gmock-port.h" +#include "gtest/gtest.h" #if GTEST_HAS_STD_INITIALIZER_LIST_ # include <initializer_list> // NOLINT -- must be after gtest.h @@ -338,29 +339,15 @@ class MatcherBase { virtual ~MatcherBase() {} private: - // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar - // interfaces. The former dynamically allocates a chunk of memory - // to hold the reference count, while the latter tracks all - // references using a circular linked list without allocating - // memory. It has been observed that linked_ptr performs better in - // typical scenarios. However, shared_ptr can out-perform - // linked_ptr when there are many more uses of the copy constructor - // than the default constructor. - // - // If performance becomes a problem, we should see if using - // shared_ptr helps. - ::testing::internal::linked_ptr< - const MatcherInterface<GTEST_REFERENCE_TO_CONST_(T)> > - impl_; + std::shared_ptr<const MatcherInterface<GTEST_REFERENCE_TO_CONST_(T)>> impl_; }; } // namespace internal // A Matcher<T> is a copyable and IMMUTABLE (except by assignment) // object that can check whether a value of type T matches. The -// implementation of Matcher<T> is just a linked_ptr to const -// MatcherInterface<T>, so copying is fairly cheap. Don't inherit -// from Matcher! +// implementation of Matcher<T> is just a std::shared_ptr to const +// MatcherInterface<T>. Don't inherit from Matcher! template <typename T> class Matcher : public internal::MatcherBase<T> { public: @@ -1586,7 +1573,7 @@ class MatchesRegexMatcher { } private: - const internal::linked_ptr<const RE> regex_; + const std::shared_ptr<const RE> regex_; const bool full_match_; GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher); |