Merge pull request #2527 from PiotrNycz:gmock_prevent_return_ref_to_store_temporaries_2

PiperOrigin-RevId: 277061341
This commit is contained in:
vslashg
2019-10-29 16:51:12 -04:00
2 changed files with 40 additions and 0 deletions

View File

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