diff options
author | Abseil Team <absl-team@google.com> | 2019-01-12 20:41:51 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2019-01-14 22:02:03 (GMT) |
commit | 9acd065a905a145eaa0a5ccbc43d7fbfd1079faf (patch) | |
tree | 212d3ce673eb77f6446a7f43a4ff3d332b49edc0 /googletest/include/gtest/gtest-matchers.h | |
parent | 097407fd3cfb4d1e5f89ae242635b1f321b222bb (diff) | |
download | googletest-9acd065a905a145eaa0a5ccbc43d7fbfd1079faf.zip googletest-9acd065a905a145eaa0a5ccbc43d7fbfd1079faf.tar.gz googletest-9acd065a905a145eaa0a5ccbc43d7fbfd1079faf.tar.bz2 |
Googletest export
Add move-only argument support to almost all remaining matchers.
PiperOrigin-RevId: 229030728
Diffstat (limited to 'googletest/include/gtest/gtest-matchers.h')
-rw-r--r-- | googletest/include/gtest/gtest-matchers.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index 128fdb2..9a8841b 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -555,13 +555,12 @@ class PolymorphicMatcher { Impl impl_; }; -// Creates a matcher from its implementation. This is easier to use -// than the Matcher<T> constructor as it doesn't require you to -// explicitly write the template argument, e.g. +// Creates a matcher from its implementation. +// DEPRECATED: Especially in the generic code, prefer: +// Matcher<T>(new MyMatcherImpl<const T&>(...)); // -// MakeMatcher(foo); -// vs -// Matcher<const string&>(foo); +// MakeMatcher may create a Matcher that accepts its argument by value, which +// leads to unnecessary copies & lack of support for non-copyable types. template <typename T> inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) { return Matcher<T>(impl); @@ -596,7 +595,7 @@ class ComparisonBase { explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {} template <typename Lhs> operator Matcher<Lhs>() const { - return MakeMatcher(new Impl<Lhs>(rhs_)); + return Matcher<Lhs>(new Impl<const Lhs&>(rhs_)); } private: |