std::system_error::operator=
From cppreference.com
< cpp | error | system error
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Utilities library
Type support (basic types, RTTI)
Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
Coroutine support (C++20)
Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Relational operators (deprecated in C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
(C++20)
Swap and type operations
Common vocabulary types
Diagnostics library
(until C++20*)
(C++17)(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Exception handling failures
(C++11)
(until C++17*)
(until C++17*)
(until C++17*)
(until C++17*)
(TM TS)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++26)
(C++26)
(C++26)
std::system_error
Member functions
system_error::operator=
system_error& operator=( const system_error& other ) noexcept;
(since C++11)
Assigns the contents with those of other. If *this and other both have dynamic type std::system_error
then std::strcmp (what(), other.what()) == 0 after assignment.
[edit] Parameters
other
-
another
system_error
object to assign with
[edit] Return value
*this
[edit] Example
Run this code
#include <cassert> #include <cstring> #include <iostream> #include <system_error> void print(const std::system_error & e) { std::cout << "code: [" << e.code() << "]\n" "message: [" << e.code().message() << "]\n" "what: [" << e.what() << "]\n\n"; } int main() { std::system_error e1(EDOM, std::generic_category (), "Error info #1"); print(e1); std::system_error e2(EIO, std::system_category (), "Error info #2"); print(e2); e1 = e2; assert (std::strcmp (e1.what(), e2.what()) == 0); print(e1); }
Possible output:
code: [generic:33] message: [Numerical argument out of domain] what: [Error info #1: Numerical argument out of domain] code: [system:5] message: [Input/output error] what: [Error info #2: Input/output error] code: [system:5] message: [Input/output error] what: [Error info #2: Input/output error]