std::error_code::operator=

来自cppreference.com
< cpp‎ | error‎ | error code
 
 
 
 
 
template<class ErrorCodeEnum >
error_code& operator=( ErrorCodeEnum e )noexcept;
(1) (C++11 起)
error_code& operator=(const error_code& other )=default;
(2) (C++11 起)
(隐式声明)
error_code& operator=( error_code&& other )=default;
(3) (C++11 起)
(隐式声明)
1) 以表示错误码枚举 e 者替换错误码和对应类别。

等价于 *this = make_error_code(e),其中 make_error_code 仅由实参依赖查找找到。

此重载只有在 std::is_error_code_enum<ErrorCodeEnum>::valuetrue 时才会参与重载决议。
2,3) 隐式定义的复制赋值运算符与移动赋值运算符将 other 的内容赋值给 *this

目录

[编辑]参数

e - 要构造的错误码枚举
other - 用以赋值的另一错误码

[编辑]返回值

*this

[编辑]缺陷报告

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

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

[编辑]参阅

赋值为另一错误码
(公开成员函数)[编辑]
close