From 097407fd3cfb4d1e5f89ae242635b1f321b222bb Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Sat, 12 Jan 2019 12:26:37 -0500 Subject: Googletest export Deduplicate testing::ReferenceWrapper with std::reference_wrapper. Minor cleanups in matchers_test. PiperOrigin-RevId: 229022872 --- googlemock/include/gmock/gmock-actions.h | 34 +++++--------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'googlemock/include/gmock/gmock-actions.h') diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 28141257..df49fbc9 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -936,33 +936,6 @@ class IgnoreResultAction { GTEST_DISALLOW_ASSIGN_(IgnoreResultAction); }; -// A ReferenceWrapper object represents a reference to type T, -// which can be either const or not. It can be explicitly converted -// from, and implicitly converted to, a T&. Unlike a reference, -// ReferenceWrapper can be copied and can survive template type -// inference. This is used to support by-reference arguments in the -// InvokeArgument(...) action. The idea was from "reference -// wrappers" in tr1, which we don't have in our source tree yet. -template -class ReferenceWrapper { - public: - // Constructs a ReferenceWrapper object from a T&. - explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {} // NOLINT - - // Allows a ReferenceWrapper object to be implicitly converted to - // a T&. - operator T&() const { return *pointer_; } - private: - T* pointer_; -}; - -// Allows the expression ByRef(x) to be printed as a reference to x. -template -void PrintTo(const ReferenceWrapper& ref, ::std::ostream* os) { - T& value = ref; - UniversalPrinter::Print(value, os); -} - template struct WithArgsAction { InnerAction action; @@ -1219,9 +1192,12 @@ inline internal::IgnoreResultAction IgnoreResult(const A& an_action) { // where Base is a base class of Derived, just write: // // ByRef(derived) +// +// N.B. ByRef is redundant with std::ref, std::cref and std::reference_wrapper. +// However, it may still be used for consistency with ByMove(). template -inline internal::ReferenceWrapper ByRef(T& l_value) { // NOLINT - return internal::ReferenceWrapper(l_value); +inline ::std::reference_wrapper ByRef(T& l_value) { // NOLINT + return ::std::reference_wrapper(l_value); } } // namespace testing -- cgit v1.2.3