std::expected<T,E>::error

< cpp‎ | utility‎ | expected
constexpr const E& error() const& noexcept;
(1) (C++23 起)
constexpr E& error() & noexcept;
(2) (C++23 起)
constexpr const E&& error() const&& noexcept;
(3) (C++23 起)
constexpr E&& error() && noexcept;
(4) (C++23 起)

访问 *this 中含有的不期待的值。

this->has_value()true 则行为未定义。

参数

(无)

返回值

*this 中含有的不期待的值的引用。

示例

参阅

返回期待的值
(公开成员函数)
返回期待的值
(公开成员函数)
检查对象是否含有期待的值
(公开成员函数)