Namespaces
Variants

std:: error_condition

From cppreference.net
Utilities library
헤더에 정의됨 <system_error>
class error_condition ;
(C++11부터)

std::error_condition 는 플랫폼 독립적인 값을 보유하며 오류 조건을 식별합니다. std::error_code 와 마찬가지로 정수 값과 std::error_category 에 의해 고유하게 식별되지만, std::error_code 와 달리 값은 플랫폼에 의존하지 않습니다.

일반적인 구현은 하나의 정수 데이터 멤버(값)와 std::error_category 에 대한 포인터를 보유합니다.

목차

멤버 함수

error_condition 을 생성합니다
(public member function)
내용을 대체합니다
(public member function)
내용을 대체합니다
(public member function)
error_condition generic_category 에서 0 값으로 설정합니다
(public member function)
error_condition 의 값을 얻습니다
(public member function)
error_condition 에 대한 error_category 를 얻습니다
(public member function)
설명 문자열을 얻습니다
(public member function)
값이 0이 아닌지 확인합니다
(public member function)

비멤버 함수

(C++20에서 제거됨) (C++20에서 제거됨) (C++20)
error_condition error_code 를 비교합니다
(함수)

헬퍼 클래스

열거형을 std::error_condition 으로 식별합니다
(클래스 템플릿)
std::error_condition 에 대한 해시 지원
(클래스 템플릿 특수화)

참고 사항

비교 std::error_code std::error_condition 사이의 에러 카테고리에 의해 정의됩니다. 특히, std::generic_category 의 에러 조건은 동일한 종류의 에러를 나타낼 경우 특정 카테고리(예: std::system_category )의 에러 코드와 동등하게 비교될 수 있습니다.

std::errc 값은 std::error_condition 으로의 암시적 변환을 통해 에러 코드와 비교될 수 있습니다.

#include <cerrno>
#include <iostream>
#include <system_error>
#include <Windows.h>
int main()
{
    std::error_code ec{ERROR_FILE_EXISTS, std::system_category()};
    std::error_condition econd{EEXIST, std::generic_category()};
    std::cout.setf(std::ios::boolalpha);
    std::cout << (ec == econd) << '\n'; // 일반적으로 true
    std::cout << (ec == std::errc::file_exists) << '\n'; // 동일
    std::cout << (ec == make_error_code(std::errc::file_exists)) << '\n'; // false:
                                                                     // 다른 카테고리
}

가능한 출력:

true
true
false

참고 항목

(C++11)
플랫폼 종속 에러 코드를 보유함
(class)
에러 카테고리의 기본 클래스
(class)
errc 값에 대한 에러 조건을 생성함 e
(function)