From ec9be15bf8f4789c6d847806e0e8778da67bc216 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 20 Aug 2020 10:50:35 -0400 Subject: [PATCH] Googletest export Workaround static assert in early versions libc++ The error is "Attempted to construct a reference element in a tuple with an rvalue". We can fix this by putting everything into a non temporary tuple_args and implitly convert to the other tuple types. This avoids binding an rvalue reference to an lvalue reference inside the tuple. PiperOrigin-RevId: 327624990 --- googlemock/include/gmock/gmock-actions.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 3aba9ec0..02356a40 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -1050,10 +1050,11 @@ struct DoAllAction { std::vector...)>> converted; Action last; R operator()(Args... args) const { + auto tuple_args = std::forward_as_tuple(std::forward(args)...); for (auto& a : converted) { - a.Perform(std::forward_as_tuple(std::forward(args)...)); + a.Perform(tuple_args); } - return last.Perform(std::forward_as_tuple(std::forward(args)...)); + return last.Perform(std::move(tuple_args)); } }; return Op{Convert...)>>(