std::error_condition::operator=

来自cppreference.com
< cpp‎ | error‎ | error condition
2023年12月1日 (五) 21:10Lynnboy讨论 | 贡献的版本

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
 
 
 
 
 
template< class ErrorConditionEnum >
error_condition& operator=( ErrorConditionEnum e ) noexcept;
(1) (C++11 起)
error_condition& operator=( const error_condition& other ) = default;
(2) (C++11 起)
(隐式声明)
error_condition& operator=( error_condition&& other ) = default;
(3) (C++11 起)
(隐式声明)

赋值内容给错误条件。

1) 将枚举 e 赋值给错误条件。实际上对 e 调用仅由实参依赖查找找到的 make_error_condition 然后再以结果替换 *this。此重载只有在 std::is_error_condition_enum<ErrorConditionEnum>::valuetrue 时才会参与重载决议。
2,3) 隐式定义的复制赋值运算符与移动赋值运算符将 other 的内容赋值给 *this

[编辑] 参数

e - 错误条件枚举
other - 用以赋值的另一错误条件

[编辑] 返回值

*this

[编辑] 缺陷报告

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

缺陷报告 应用于 出版时的行为 正确行为
LWG 3629 C++11 仅使用 std::make_error_condition 重载 使用 ADL 所找到的重载