Set up inlining for InvokeWithoutArgs when passed a functor.

Actions can now be implicitly constructed from zero-argument callables. There is no need to create wrapper objects using InvokeWithoutArgs().

PiperOrigin-RevId: 949656497
Change-Id: Ida2bc38e446e7b33aaf185ec593caf2a1959138e
This commit is contained in:
Abseil Team
2026-07-17 10:58:22 -07:00
committed by Copybara-Service
parent 4141c384aa
commit fa005b296f
3 changed files with 10 additions and 25 deletions
+3 -3
View File
@@ -1223,15 +1223,15 @@ class Foo {
// Tests InvokeWithoutArgs(function).
TEST(InvokeWithoutArgsTest, Function) {
// As an action that takes one argument.
Action<int(int)> a = InvokeWithoutArgs(Nullary); // NOLINT
Action<int(int)> a = Nullary; // NOLINT
EXPECT_EQ(1, a.Perform(std::make_tuple(2)));
// As an action that takes two arguments.
Action<int(int, double)> a2 = InvokeWithoutArgs(Nullary); // NOLINT
Action<int(int, double)> a2 = Nullary; // NOLINT
EXPECT_EQ(1, a2.Perform(std::make_tuple(2, 3.5)));
// As an action that returns void.
Action<void(int)> a3 = InvokeWithoutArgs(VoidNullary); // NOLINT
Action<void(int)> a3 = VoidNullary; // NOLINT
g_done = false;
a3.Perform(std::make_tuple(1));
EXPECT_TRUE(g_done);