Skip to content

Commit d728ebf

Browse files
committed
add missing deduction guide for inplace_stop_callback
[stopcallback.inplace.general] declares a deduction guide so that `inplace_stop_callback cb{token, fn};` deduces the callback type. stdexec did not provide it, so class template argument deduction failed. Add the guide and a test. Fixes #1420
1 parent ead186b commit d728ebf

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎include/stdexec/stop_token.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ STDEXEC_P2300_NAMESPACE_BEGIN()
259259
STDEXEC_ATTRIBUTE(no_unique_address) _Fun __fun_;
260260
};
261261

262+
template <class _Fun>
263+
inplace_stop_callback(inplace_stop_token, _Fun) -> inplace_stop_callback<_Fun>;
264+
262265
inline inplace_stop_source::~inplace_stop_source()
263266
{
264267
STDEXEC_ASSERT((__state_.load(STDEXEC::__std::memory_order_relaxed) & __locked_flag_) == 0);

‎test/stdexec/concepts/test_concepts_stop_tokens.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,11 @@ namespace
5050
std::stop_callback<on_stop_request>>);
5151
#endif
5252
}
53+
54+
TEST_CASE("inplace_stop_callback supports class template argument deduction", "[stop_token]")
55+
{
56+
::STDEXEC::inplace_stop_source source;
57+
::STDEXEC::inplace_stop_callback cb{source.get_token(), on_stop_request{}};
58+
STATIC_REQUIRE(std::is_same_v<decltype(cb), ::STDEXEC::inplace_stop_callback<on_stop_request>>);
59+
}
5360
} // namespace

0 commit comments

Comments
 (0)