std::error_code::operator=
来自cppreference.com
< cpp | error | error code
工具库
诊断库
|
|
std::error_code
成员函数 | ||||
error_code::operator=
|
||||
修改器 | ||||
观察器 | ||||
非成员函数 | ||||
(C++20
前)(C++20
前)(C++20)
|
||||
辅助类 | ||||
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) 以表示错误码枚举
等价于 *this = make_error_code(e) ,其中
e
者替换错误码和对应类别。等价于 *this = make_error_code(e) ,其中
make_error_code
仅由实参依赖查找找到。此重载只有在 std::is_error_code_enum<ErrorCodeEnum>::value 为 true 时才会参与重载决议。
2,3) 隐式定义的复制赋值运算符与移动赋值运算符将
other
的内容赋值给 *this 。参数
e | - | 要构造的错误码枚举 |
other | - | 用以赋值的另一错误码 |
返回值
*this
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
---|---|---|---|
LWG 3629 | C++11 | 仅使用 std::make_error_code 重载
|
使用 ADL 所找到的重载 |
参阅
赋值为另一 error_code (公开成员函数) |