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

履歴 編集

customization point object
<execution>

std::get_stop_token(C++26)

namespace std {
  struct get_stop_token_t { unspecified };
  inline constexpr get_stop_token_t get_stop_token{};
}

概要

get_stop_tokenは、クエリ可能オブジェクトから停止トークンを取得するクエリオブジェクトである。

コア定数式forwarding_query(get_stop_token)true値を返す。

効果

呼び出し式get_stop_token(env)は下記と等価であり、stoppable_tokenを満たす型の値となる。

  • 引数envがconst修飾されたcenvを用いて、式cenv.query(get_stop_token)適格であればその値。
  • そうでなければ、never_stop_token{}

例外

投げない

カスタマイゼーションポイント

const修飾クエリ可能オブジェクトcenvに対して式cenv.query(get_stop_token)が呼び出される。 このとき、noexcept(cenv.query(get_stop_token)) == trueであること。

#include <concepts>
#include <stop_token>
#include <execution>
namespace ex = std::execution;

int main()
{
  // just Senderは停止トークンを持たない
  ex::sender auto sndr = ex::just(42);
  auto token = std::get_stop_token(ex::get_env(sndr));
  static_assert(std::same_as<decltype(token), std::never_stop_token>);
}

出力

バージョン

言語

  • C++26

処理系

関連項目

参照