Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 1.38 KB

File metadata and controls

65 lines (49 loc) · 1.38 KB

error

  • expected[meta header]
  • function[meta id-type]
  • std[meta namespace]
  • unexpected[meta class]
  • cpp23[meta cpp]
constexpr const E& error() const & noexcept;   // (1)
constexpr E& error() & noexcept;               // (2)
constexpr const E&& error() const && noexcept; // (3)
constexpr E&& error() && noexcept;             // (4)

概要

エラー値を取得する。

戻り値

動作説明用のメンバ変数として、エラー値を保持するunexを導入する。

例外

投げない

#include <cassert>
#include <expected>
#include <iostream>
#include <string>

int main()
{
  std::unexpected<std::string> x{"ERR"};
  std::cout << x.error() << std::endl;
}
  • error()[color ff0000]
  • std::unexpected[link ../unexpected.md]

出力

ERR

バージョン

言語

  • C++23

処理系

参照