namespace std::execution {
struct upon_stopped_t { unspecified };
inline constexpr upon_stopped_t upon_stopped{};
}
概要
upon_stoppedは、入力Senderの停止完了操作の継続として関数呼び出しをアタッチし、戻り値データを正常完了として送信するSenderアダプタである。
upon_stoppedはパイプ可能Senderアダプタオブジェクトであり、パイプライン記法をサポートする。
Senderアルゴリズムupon_stoppedの仕様は、thenページを参照のこと。
例
#include <print>
#include <execution>
namespace ex = std::execution;
int main()
{
{ // 関数呼び出し
ex::sender auto snd0 = ex::just_stopped();
ex::sender auto snd1 = ex::upon_stopped(snd0, []() {
return 42;
});
auto [v] = std::this_thread::sync_wait(snd1).value();
std::println("{}", v);
}
{ // パイプライン記法
ex::sender auto sndr = ex::just_stopped()
| ex::upon_stopped([]() {
return 42;
});
auto [v] = std::this_thread::sync_wait(sndr).value();
std::println("{}", v);
}
}
出力
42
42
バージョン
言語
- C++26
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??