最終更新日時(UTC):
が更新

履歴 編集

customization point object
<execution>

std::execution::let_stopped(C++26)

namespace std::execution {
  struct let_stopped_t { unspecified };
  inline constexpr let_stopped_t let_stopped{};
}

概要

let_stoppedは、新しいSenderを返す関数呼び出し可能なオブジェクトに引き渡すことで、入力Sender停止完了結果から入れ子の非同期操作へと変換するSenderアダプタである。

let_stoppedパイプ可能Senderアダプタオブジェクトであり、パイプライン記法をサポートする。

Senderアルゴリズムlet_stoppedの仕様は、let_valueページを参照のこと。

#include <print>
#include <execution>
namespace ex = std::execution;

int main()
{
  { // 関数呼び出し
    ex::sender auto snd0 = ex::just_stopped();
    ex::sender auto snd1 = ex::let_stopped(
      snd0,
      []() -> ex::sender auto {
        return ex::just(42);
      });
    auto [val] = std::this_thread::sync_wait(snd1).value();
    std::println("{}", val);
  }

  { // パイプライン記法
    ex::sender auto sndr = ex::just_stopped()
      | ex::let_stopped(
          []() -> ex::sender auto {
            return ex::just(42);
          });
    auto [val] = std::this_thread::sync_wait(sndr).value();
    std::println("{}", val);
  }
}

出力

42
42

バージョン

言語

  • C++26

処理系

関連項目

参照