std::errc make_error_condition

std::errc make_error_condition (오류 조건 생성)

std::errc 열거 값을 std::error_condition으로 변환하는 함수예요. 일반 오류 카테고리(generic_category)와 결합해요. C++11부터 있어요.

출처: cppreference

본문

<system_error> 헤더에 정의돼 있고, std::errc 값을 오류 조건으로 변환해요.

std::error_condition make_error_condition( std::errc e ) noexcept;

std::errc 열거 값 e에 대한 오류 조건을 만들어요. 다음과 동등해요.

std::error_condition(static_cast<int>(e), std::generic_category())

POSIX errno 도메인 값이므로 일반(포팅 가능) 카테고리가 사용돼요.

  • 매개변수 e: 오류 조건으로 만들 열거 값.
  • 반환 값: e에 대응하는 오류 조건.

이 함수는 std::errcstd::is_error_condition_enum 특수화에서 true로 표시됨에 따라, std::error_condition의 템플릿 생성자를 통해 자동으로 호출돼요. 만들어진 조건은 error_codedefault_error_condition() 등과 비교해 플랫폼 간 동일한 오류 의미를 판단하는 데 쓰여요.

#include <system_error>

std::error_condition cond = std::errc::broken_pipe;

더 알아보기 (Learn more)

cppreference