Namespaces
Variants
Views
Actions

std::error_code::operator=

From cppreference.com
< cpp‎ | error‎ | error code
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (C++20)
Dynamic memory management
Program utilities
Coroutine support (C++20)
Variadic functions
Debugging support
(C++26)
Three-way comparison
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)

 
 
 
template< class ErrorCodeEnum >
error_code& operator=( ErrorCodeEnum e ) noexcept;
(1) (since C++11)
error_code& operator=( const error_code& other ) = default;
(2) (since C++11)
(implicitly declared)
error_code& operator=( error_code&& other ) = default;
(3) (since C++11)
(implicitly declared)
1) Replaces the error code and corresponding category with those representing error code enum e.

Equivalent to *this = make_error_code(e), where make_error_code is only found by argument-dependent lookup.

This overload participates in overload resolution only if std::is_error_code_enum<ErrorCodeEnum>::value is true.
2,3) Implicitly defined copy-assignment operator and move-assignment operator assign the contents of other to *this.

Contents

[edit] Parameters

e - error code enum to construct
other - another error code to assign with

[edit] Return value

*this

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 3629 C++11 only std::make_error_code overloads were used ADL-found overloads are used

[edit] See also

assigns another error code
(public member function) [edit]