std::stop_c...top_callback(3)
π NAME π
std::stop_callback::stop_callback - std::stop_callback::stop_callback
okay bestie, this page is from the C++ Standard Libary manual (yes, spelled exactly like that in the header, no cap), and the header title is std::stop_c...top_callback(3). It's the constructor page for std::stop_callback, and it's lowkey iconic π
β¨ SYNOPSIS β¨
template< class C >
explicit stop_callback( const std::stop_token& st, C&& cb )
(1) (since C++20)
noexcept(/*see below*/);
template< class C >
explicit stop_callback( std::stop_token&& st, C&& cb )
(2) (since C++20)
noexcept(/*see below*/);
stop_callback( const stop_callback& ) = delete;
(3) (since C++20)
stop_callback( stop_callback&& ) = delete;
(4) (since C++20)
okay so what's the vibe? Constructs a new stop_callback object, saving and registering the cb callback function into the given std::stop_token's associated stop-state, for later invocation if stop is requested on the associated std::stop_source. it's giving "hold my callback, I might need it later" energy π
1)Constructs astop_callbackfor the givenststd::stop_token(copied), with the given invocable callback functioncb.2)Constructs astop_callbackfor the givenststd::stop_token(moved), with the given invocable callback functioncb.3,4)stop_callbackis neitherCopyConstructiblenorMoveConstructible. periodt, it does not copy, it does not move π
Both constructors participate in overload resolution only if Callback and C satisfy constructible_from of std::constructible_from<Callback, C>. and if Callback and C satisfy the concept but fail to satisfy its semantic requirement? bestie, that's undefined behavior π
π PARAMETERS π
stβ astd::stop_tokenobject to register thisstop_callbackobject withcbβ the type to invoke if stop is requested
π EXCEPTIONS π
1,2) here's the noexcept specification:
noexcept(std::is_nothrow_constructible_v<Callback, C>)
Any exception thrown by constructor-initializing the given callback into the stop_callback object β that's the exception situation, fr fr.
π NOTES π
If st.stop_requested() == true for the passed-in std::stop_token, then the callback function is invoked in the current thread before the constructor returns. so yeah, it can run right there on the spot before the constructor is even done β main character energy π«Ά
π CATEGORY π
conditionally noexcept
that's the whole page, bestie π«Ά source/version: http://cppreference.com; date: 2024.06.10; page: std::stop_c...top_callback(3). go off and register those callbacks responsibly π
β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms