googletest/googlemock/test
Abseil Team 28a96d1834 Googletest export
Fix matcher comparisons for std::reference_wrapper.

The googletest docs indicate that std::reference_wrapper should be used to for
objects that should not be copied by the matcher (in fact, the ByRef() function
is basically the same as a call to std::cref).

However, for many types (such as std::string), the overloaded operator== will
not resolve correctly. Specifically, this is problematic if operator== depends
on template argument deduction, where the same type is named on LHS and RHS.

Because template argument deduction happens before any implict conversions for
purposes of overload resolution, attempting to compare T with
std::reference_wrapper<T> simply looks like a comparison of unlike types.

For exapmle, std::reference_wrapper<std::string> is implicitly convertible to
'const std::string&', which would be able to choose an overload specialization
of operator==. However, the implicit conversion can only happen after template
argument deduction for operator==, so a specialization that would other be an
applicable overload is never considered.

Note also that this change only affects matchers. There are good reasons that
matchers may need to transparently hold a std::reference_wrapper. Other
comparisons (like EXPECT_EQ, et. al.) don't need to capture a reference: they
don't need to defer evaluation (as in googlemock), and they don't need to avoid
copies (as the call chain of matchers does).

PiperOrigin-RevId: 232499175
2019-02-12 13:20:14 -05:00
..
BUILD.bazel Googletest export 2018-11-07 14:37:18 -05:00
gmock_all_test.cc Googletest export 2019-01-08 11:50:56 -05:00
gmock_ex_test.cc Comments changes, no functionality changes 2018-08-14 14:04:07 -04:00
gmock_leak_test_.cc Comments changes, no functionality changes 2018-08-14 14:04:07 -04:00
gmock_leak_test.py Comments changes, no functionality changes. 2018-08-14 15:04:11 -04:00
gmock_link2_test.cc Comments changes, no functionality changes 2018-08-14 14:04:07 -04:00
gmock_link_test.cc Comments changes, no functionality changes 2018-08-14 14:04:07 -04:00
gmock_link_test.h Replaced all NULLs with nullptr in googlemock 2018-10-28 03:27:51 +03:00
gmock_output_test_.cc Comments changes, no functionality changes 2018-08-14 14:04:07 -04:00
gmock_output_test_golden.txt Googletest export 2018-12-13 16:00:11 -05:00
gmock_output_test.py Comments changes, no functionality changes. 2018-08-14 15:04:11 -04:00
gmock_stress_test.cc Googletest export 2018-10-29 13:46:16 -04:00
gmock_test_utils.py Comments changes, no functionality changes. 2018-08-14 15:04:11 -04:00
gmock_test.cc Apply clang-tidy modernize-use-nullptr to googletest. 2018-10-05 12:54:14 -04:00
gmock-actions_test.cc Googletest export 2019-01-17 14:41:08 -05:00
gmock-cardinalities_test.cc Googletest export 2018-12-03 12:54:11 -05:00
gmock-function-mocker_nc_test.py Googletest export 2018-11-20 13:29:40 -05:00
gmock-function-mocker_nc.cc Googletest export 2018-11-20 13:29:40 -05:00
gmock-function-mocker_test.cc Googletest export 2019-01-18 14:06:03 -05:00
gmock-generated-actions_test.cc Googletest export 2018-12-17 17:57:39 -05:00
gmock-generated-function-mockers_test.cc Googletest export 2019-01-18 14:06:03 -05:00
gmock-generated-matchers_test.cc Googletest export 2019-02-01 12:52:31 -05:00
gmock-internal-utils_test.cc Googletest export 2019-01-08 11:50:56 -05:00
gmock-matchers_test.cc Googletest export 2019-02-12 13:20:14 -05:00
gmock-more-actions_test.cc Googletest export 2018-10-29 13:46:16 -04:00
gmock-nice-strict_test.cc Googletest export 2019-01-02 16:51:33 -05:00
gmock-port_test.cc Comments changes, no functionality changes 2018-08-14 14:04:07 -04:00
gmock-pp_test.cc Googletest export 2018-11-15 16:11:19 -05:00
gmock-pp-string_test.cc Googletest export 2018-11-20 13:30:24 -05:00
gmock-spec-builders_test.cc Googletest export 2019-01-17 14:41:08 -05:00