std::meta::exception
来自 zh.cppreference.net
| 在头文件 <meta>
|
||
class exception : public std::exception
|
中定义 (C++26 起) | |
定义一个类型的对象,当反射函数失败时抛出。
std::meta::exception 类型的对象只能在常量求值中创建和访问。
成员函数
(构造函数) |
构造一个 meta::exception 对象 (公开成员函数) |
what |
返回解释字符串 (公开成员函数) |
u8what |
返回解释字符串作为 std::u8string_view (公开成员函数) |
from |
返回关联的 std::meta::info 对象 (公开成员函数) |
where |
返回关联的 std::source_location (公开成员函数) |
std::meta::exception::exception
consteval exception( std::u8string_view u8what_arg, std::meta::info from,
std::source_location where = std::source_location::current() ) noexcept;
|
(1) | |
consteval exception( std::string_view what_arg, std::meta::info from,
std::source_location where = std::source_location::current() ) noexcept;
|
(2) | |
consteval exception( const exception& ) = default;
|
(3) | |
consteval exception( exception&& ) = default;
|
(4) | |
构造一个新的 std::meta::info 对象。用对应的参数初始化存储的值。
1) 如果
u8what_arg 可以用普通字面量编码表示,则由 what() 返回的解释字符串是 u8what_arg 从 UTF-8 转码到普通字面量编码的;否则,调用 what() 不是常量表达式。2)
what_arg 必须可以用 UTF-8 表示。3) 复制构造函数是默认的。
4) 移动构造函数是默认的。
std::meta::exception::what
constexpr const char* what() const noexcept override;
|
||
返回构造时传递的解释字符串,可能从 UTF-8 转码到普通字面量编码。
std::meta::exception::u8what
consteval std::u8string_view u8what() const noexcept;
|
||
返回构造时传递的解释字符串,可能从普通字面量编码转码到 UTF-8。
std::meta::exception::from
consteval std::meta::info from() const noexcept;
|
||
返回构造时传递的 std::meta::info 值。
std::meta::exception::where
consteval std::source_location where() const noexcept;
|
||
返回构造时传递的 std::source_location 值。
示例
| 此部分不完整 原因:无示例 |