std::format_error
格式化函数 | ||||
(C++20)
|
||||
(C++20)
|
||||
(C++20)
|
||||
(C++20)
|
||||
(C++20)
|
||||
(C++20)
|
||||
格式化概念 | ||||
(C++23)
|
||||
格式化器 | ||||
(C++20)
|
||||
(C++23)
|
||||
(C++20)(C++20)(C++20)
|
||||
(C++20)(C++20)(C++20)
|
||||
(C++23)
|
||||
(C++23)
|
||||
格式化参数 | ||||
(C++20)
|
||||
(C++20)
|
||||
(C++20)(C++20)(C++20)
|
||||
(C++20)(C++20)(C++20)
|
||||
(C++20)
(C++26
中弃用)
|
||||
(C++20)(C++20)
|
||||
格式错误 | ||||
format_error
(C++20)
|
在标头
<format>
定义
|
||
class
format_error;
|
(C++20 起) | |
定义抛出以报告格式化库中错误的异常对象类型。
继承图
成员函数
(构造函数)
|
构造拥有给定消息的新 format_error 对象 (公开成员函数) |
operator=
|
替换 format_error 对象 (公开成员函数) |
std::format_error::format_error
format_error(
const
std::string&
what_arg );
|
(1) | |
format_error(
const
char*
what_arg );
|
(2) | |
format_error(
const
format_error&
other )
noexcept;
|
(3) | |
参数
what_arg | - | 解释字符串 |
other | - | 要复制的另一异常对象 |
异常
注解
因为不容许复制 std::format_error
抛出异常,通常将此消息在内部存储为分离分配的引用计数字符串。这也是构造函数不接收
std::string&&
参数的理由:无论如何它必须复制内容。
派生的标准异常类必须有一个公开可访问的复制构造函数。它可以隐式定义,只要分别在原对象和复制对象上通过
what()
获得的两个解释字符串相同。
std::format_error::operator=
format_error&
operator=(
const
format_error&
other )
noexcept;
|
||
将 other
的内容用于赋值。 如果 *this 与
other
的动态类型都是 std::format_error
,那么在赋值后 std::strcmp(what(), other.what()) == 0。
Parameters
other | - | 要赋值来的另一异常对象 |
Return value
*this
Notes
派生的标准异常类必须有一个公开可访问的复制赋值运算符。它可以隐式定义,只要分别在原对象和复制对象上通过
what()
获得的两个解释字符串相同。
继承自 std::exception
成员函数
[虚]
|
析构该异常对象 ( std::exception
的虚公开成员函数) |
[虚]
|
返回解释性字符串 ( std::exception
的虚公开成员函数) |
示例
本节未完成 原因:暂无示例 |