Skip to content

Latest commit

 

History

History
79 lines (58 loc) · 2.2 KB

File metadata and controls

79 lines (58 loc) · 2.2 KB

get_stop_token

  • execution[meta header]
  • cpo[meta id-type]
  • std[meta namespace]
  • cpp26[meta cpp]
namespace std {
  struct get_stop_token_t { unspecified };
  inline constexpr get_stop_token_t get_stop_token{};
}
  • unspecified[italic]

概要

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>);
}
  • std::get_stop_token[color ff0000]
  • ex::sender[link execution/sender.md]
  • ex::just[link execution/just.md]
  • ex::get_env[link execution/get_env.md]
  • std::never_stop_token[link /reference/stop_token/never_stop_token.md]

出力

バージョン

言語

  • C++26

処理系

関連項目

参照