aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock/include/gmock
diff options
context:
space:
mode:
authorvslashg <gfalcon@google.com>2019-10-29 16:51:12 -0400
committervslashg <gfalcon@google.com>2019-10-29 16:51:12 -0400
commitb5fb5ba05cb6144f17be58b9dba8a35ba022876a (patch)
tree20bfbd56efb93852cd5fccc102f6bc7ddaa2f7e5 /googlemock/include/gmock
parenta1f71dd56df487ed755cdf6a6a2908a64207285a (diff)
parent208c2f6b6076c7386faed78ee570cca87c6d3964 (diff)
downloadgoogletest-b5fb5ba05cb6144f17be58b9dba8a35ba022876a.tar.gz
googletest-b5fb5ba05cb6144f17be58b9dba8a35ba022876a.tar.bz2
googletest-b5fb5ba05cb6144f17be58b9dba8a35ba022876a.zip
Merge pull request #2527 from PiotrNycz:gmock_prevent_return_ref_to_store_temporaries_2
PiperOrigin-RevId: 277061341
Diffstat (limited to 'googlemock/include/gmock')
-rw-r--r--googlemock/include/gmock/gmock-actions.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index 91abcd35..2fe7574a 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -1052,6 +1052,10 @@ inline internal::ReturnRefAction<R> ReturnRef(R& x) { // NOLINT
return internal::ReturnRefAction<R>(x);
}
+// Prevent using ReturnRef on reference to temporary.
+template <typename R, R* = nullptr>
+internal::ReturnRefAction<R> ReturnRef(R&&) = delete;
+
// Creates an action that returns the reference to a copy of the
// argument. The copy is created when the action is constructed and
// lives as long as the action.