Googletest export

Add move-only argument support to almost all remaining matchers.

PiperOrigin-RevId: 229030728
This commit is contained in:
Abseil Team
2019-01-12 15:41:51 -05:00
committed by Gennadiy Civil
parent 097407fd3c
commit 9acd065a90
3 changed files with 98 additions and 34 deletions

View File

@@ -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: