std::error_code::operator=(3)
π NAME π
Bestie, welcome to the std::error_code::operator=(3) page from the C++ Standard Libary manual πβ¨. The NAME line is literally std::error_code::operator= - std::error_code::operator=, and honestly? Iconic repetitive queen behavior π
.
β¨ Synopsis β¨
template< class ErrorCodeEnum > (1) (since C++11)
error_code& operator=( ErrorCodeEnum e ) noexcept;
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)
Okay so here's the tea, overload by overload π«:
- This one replaces the error code and corresponding category with those representing error code enum
eπ.
It's equivalent to *this = make_error_code(e), where make_error_code is only found by argument-dependent lookup β yes, ADL is the main character here π.
Lowkey important: this overload participates in overload resolution only ifstd::is_error_code_enum<ErrorCodeEnum>::valueistrueπ¨.
- This is the implicitly defined copy-assignment operator, and it assigns the contents of
otherto*thisπ. - This is the implicitly defined move-assignment operator, and it also assigns the contents of
otherto*thisπ¦.
π Parameters π
eβ error code enum to construct πΈotherβ another error code to assign with π
π« Return value π«
*this β that's the return value, periodt π
β¨
π©Ή Defect reports π©Ή
The following behavior-changing defect reports were applied retroactively to previously published C++ standards π:
- LWG 3629, applied to C++11 β behavior as published: only
std::make_error_codeoverloads were used. Correct behavior: ADL-found overloads are used π₯
π See also π
assignβ assigns another error code (public member function) π
With love, zero cap, and full main-character energy: source/version http://cppreference.com, date 2024.06.10, page std::error_code::operator=(3) ππ
π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms