Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 1.31 KB

unexpect_t.md

File metadata and controls

61 lines (46 loc) · 1.31 KB

unexpect_t

  • expected[meta header]
  • class[meta id-type]
  • std[meta namespace]
  • cpp23[meta cpp]
namespace std {
  struct unexpect_t {
    explicit unexpect_t() = default;
  };

  inline constexpr unexpect_t unexpect{};
}

概要

unexpected_tは、expectedコンストラクタにおいて、エラー値型のコンストラクタ引数を受け取って構築するためのタグ型である。

unexpected_t型の定数unexpectが提供される。

#include <cassert>
#include <expected>
#include <system_error>

int main()
{
  std::expected<int, std::error_code> x{std::unexpect, ETIMEDOUT, std::system_category()};
  assert(not x.has_value());
  assert(x.error().value() == ETIMEDOUT);
  assert(x.error().category() == std::system_category());
}
  • std::unexpect[color ff0000]
  • ETIMEDOUT[link /reference/system_error/errc.md]

出力

バージョン

言語

  • C++23

処理系

関連項目

参照