std::bad_expected_access
来自 zh.cppreference.net
| 定义于头文件 <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 特化版本的基类。| 本节内容不完整 原因:继承图 |
主模板的成员
|
(constructor)
|
构造
bad_expected_access
对象
(公开成员函数) |
|
error
|
返回存储的值
(公开成员函数) |
|
what
|
返回说明性字符串
(公开成员函数) |
std::bad_expected_access:: bad_expected_access
|
explicit
bad_expected_access
(
E e
)
;
|
(since C++23)
(constexpr since C++26) |
|
构造一个新的
bad_expected_access<E>
对象。使用
std::move(e)
初始化存储的值。
std::bad_expected_access:: error
|
const
E
&
error
(
)
const
&
noexcept
;
|
(1) |
(since C++23)
(constexpr since C++26) |
|
E
&
error
(
)
&
noexcept
;
|
(2) |
(since C++23)
(constexpr since C++26) |
|
const
E
&&
error
(
)
const
&&
noexcept
;
|
(3) |
(since C++23)
(constexpr since C++26) |
|
E
&&
error
(
)
&&
noexcept
;
|
(4) |
(since C++23)
(constexpr since C++26) |
返回对存储值的引用。
std::bad_expected_access:: what
|
const
char
*
what
(
)
const
noexcept
override
;
|
(since C++23)
(constexpr since C++26) |
|
返回解释性字符串。
参数
(无)
返回值
指向以空字符结尾的解释性信息字符串的指针。该字符串适合转换并显示为 std::wstring 。该指针保证至少在获取它的异常对象被销毁之前,或在调用异常对象的非const成员函数(例如拷贝赋值运算符)之前保持有效。
|
在常量求值期间,返回的字符串使用普通字面量编码进行编码。 |
(since C++26) |
注解
允许但不要求实现重写
what()
。
bad_expected_access < void > 特化的成员
|
(constructor)
|
构造
bad_expected_access
<
void
>
对象
(受保护成员函数) |
|
(destructor)
|
销毁
bad_expected_access
<
void
>
对象
(受保护成员函数) |
|
operator=
|
替换
bad_expected_access
<
void
>
对象
(受保护成员函数) |
|
what
|
返回说明性字符串
(公开成员函数) |
bad_expected_access < void > 的特殊成员函数均为受保护。它们只能被派生类调用。
示例
|
本节内容不完整
原因:缺少示例 |