std::exception::operator=

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

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

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

[编辑] 参数

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

[编辑] 返回值

*this

[编辑] 缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告 应用于 出版时的行为 正确行为
LWG 471 C++98 赋值后调用 what() 的效果由实现定义 在动态类型相同时需要与原来的 what() 一致