Namespaces
Variants

std::system_error::operator=

cppreference.net에서
 
 
유틸리티 라이브러리
일반 유틸리티
관계 연산자 (C++20에서 비권장됨)
정수 비교 함수
(C++20)(C++20)(C++20)    
(C++20)
스왑 및 타입 연산
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
공통 어휘 타입
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
 
 
system_error& operator=( const system_error& other ) noexcept;
(C++11부터)

other의 내용으로 내용을 할당합니다. *this과(와) other이(가) 모두 동적 타입 std::system_error을(를) 가지면 할당 후 std::strcmp(what(), other.what()) == 0입니다.

매개변수

other - 할당할 다른 system_error 객체

반환값

* this

예제

#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);
}

가능한 출력:

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]