命名空间
变体
操作

std::exception::operator=

来自 cppreference.cn
< cpp‎ | error‎ | exception
 
 
 
 
 
exception& operator=( const exception& other ) throw();
(直到 C++11)
exception& operator=( const exception& other ) noexcept;
(自 C++11 起)
(constexpr 自 C++26 起)

复制赋值运算符。赋值 other 的内容。

如果 *thisother 均具有动态类型 std::exception,则赋值后 std::strcmp(what(), other.what()) == 0

[编辑] 参数

other - 要赋值其内容的另一个异常

[编辑] 缺陷报告

以下行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。

DR 应用于 已发布行为 正确行为
LWG 471 C++98 调用 what() 后的效果
赋值是实现定义的
如果动态类型相同,则需要与原始 what() 相同
what() 如果动态类型相同