Skip to content

Commit ede4ba2

Browse files
committed
Do not deduce factories as references
Add a test proving that @ericniebler's suggestion to deduce `function`'s factory argument as a value is necessary to accept lvalue factories, and then take the suggestion to make the test pass.
1 parent afe2eb8 commit ede4ba2

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

include/exec/function.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ namespace experimental::execution
194194
&& STDEXEC::__std::constructible_from<Factory> //
195195
&& STDEXEC::__callable<Factory, Args...>
196196
&& STDEXEC::sender_to<STDEXEC::__invoke_result_t<Factory, Args...>, _receiver_t>
197-
constexpr explicit _func_impl(Args &&...args, Factory &&factory)
197+
constexpr explicit _func_impl(Args &&...args, Factory factory)
198198
noexcept(STDEXEC::__nothrow_move_constructible<Args...>)
199199
: args_(std::forward<Args>(args)...)
200200
{

test/exec/test_function.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,13 @@ namespace
171171

172172
REQUIRE(ret == 42);
173173
}
174+
175+
TEST_CASE("exec::function accepts lvalue callables", "[types][function]")
176+
{
177+
exec::function<int(int) noexcept> sndr(42, ex::just);
178+
179+
auto [ret] = ex::sync_wait(sndr).value();
180+
181+
REQUIRE(ret == 42);
182+
}
174183
} // namespace

0 commit comments

Comments
 (0)