std::bad_expected_access
来自cppreference.com
| 在标头 <expected> 定义
|
||
| template< class E > class bad_expected_access : public std::bad_expected_access<void> |
(1) | (C++23 起) |
| template<> class bad_expected_access<void> : public std::exception |
(2) | (C++23 起) |
2)
bad_expected_access<void> 是所有其他 bad_expected_access 特化的基类。| 本节未完成 原因:inheritance diagram |
主模板的成员
| (构造函数) |
构造 bad_expected_access 对象 (公开成员函数) |
| error |
返回储存的值 (公开成员函数) |
| what |
返回用于解释的字符串 (公开成员函数) |
std::bad_expected_access::bad_expected_access
| explicit bad_expected_access( E e ); |
||
构造一个新的 bad_expected_access<E> 对象。用 std::move(e) 初始化存储的值。
std::bad_expected_access::error
| const E& error() const & noexcept; E& error() & noexcept; |
||
返回到储存的值的引用。
std::bad_expected_access::what
| const char* what() const noexcept override; |
||
返回用于解释的字符串。
参数
(无)
返回值
指向一个包含解释性信息的空终止字符串。该字符串可以转换和显示为 std::wstring。该指针保证在至少从其获得的异常对象被销毁之前,或者在异常对象上调用一个非 const 成员函数(例如复制赋值运算符)之前,是有效的。
注解
实现允许但是不需要重写 what()。
bad_expected_access<void> 特化的成员
| (构造函数) |
构造 bad_expected_access<void> 对象 (受保护成员函数) |
| (析构函数) |
销毁 bad_expected_access<void> 对象 (受保护成员函数) |
| operator= |
替换 bad_expected_access<void> 对象 (受保护成员函数) |
| what |
返回用于解释的字符串 (公开成员函数) |
bad_expected_access<void> 特化的成员函数是受保护的,它们只能在派生类中调用。
示例
| 本节未完成 原因:暂无示例 |