std::is_error_condition_enum

std::is_error_condition_enum (오류 조건 열거 특성)

어떤 타입이 오류 조건 열거(ErrorConditionEnum)로 취급될 수 있는지를 판정하는 형질이에요. 기본값은 false이고, 특수화로 true를 표시해 열거를 error_condition에 자동 변환하게 해요. C++11부터 있어요.

출처: cppreference

본문

<system_error> 헤더에 정의돼 있고, 오류 조건 열거 판정 형질이에요.

template< class T >
struct is_error_condition_enum : std::false_type {};

std::error_condition의 템플릿 생성자는 std::is_error_condition_enum<T>::valuetrue일 때만 오버로드 해석에 참여해요. 그래서 이 형질을 true로 특수화하면 해당 열거 타입을 std::error_condition에 암시적으로 변환할 수 있어요.

표준 라이브러리는 std::errc에 대해 이 형질을 특수화해요 (POSIX 오류 도메인). std::is_error_code_enum과 달리 이쪽은 열거가 "조건"으로 쓰일 수 있음을 나타내요.

이 형질이 true인 열거 값은 std::error_condition cond = enum_value; 처럼 자동으로 조건으로 변환돼요. 사용자 정의 오류 조건 열거도 이 형질을 특수화하고 make_error_condition 오버로드를 제공해 확장할 수 있어요.

#include <system_error>

std::error_condition cond = std::errc::operation_canceled; // std::errc가 true

더 알아보기 (Learn more)

cppreference