Namespaces
Variants

std:: is_error_code_enum <std::io_errc>

From cppreference.net
< cpp ‎ | io ‎ | io errc
std::io_errc
Non-member functions
Helper classes
is_error_code_enum <std::io_errc>
(C++11)
헤더에 정의됨 <ios>
template <>
struct is_error_code_enum < std:: io_errc > : public std:: true_type { } ;
(C++11부터)

std::is_error_code_enum 특수화는 std::io_errc 타입의 값들이 에러 코드를 보유하는 열거형임을 다른 라이브러리 구성 요소에 알려주며, 이로 인해 해당 값들이 std::error_code 타입의 객체로 암시적으로 변환 및 할당 가능하게 됩니다.

목차

std:: integral_constant 에서 상속됨

멤버 상수

value
[static]
true
(public static member constant)

멤버 함수

operator bool
객체를 bool 로 변환, value 반환
(public member function)
operator()
(C++14)
value 반환
(public member function)

멤버 타입

타입 정의
value_type bool
type std:: integral_constant < bool , value >

예제

e. code ( ) std::io_errc::stream 사이의 비교가 컴파일되는 이유는 std:: is_error_code_enum < std:: io_errc > :: value == true 이기 때문입니다.

#include <fstream>
#include <iostream>
int main()
{
    std::ifstream f("doesn't exist");
    try
    {
        f.exceptions(f.failbit);
    }
    catch (const std::ios_base::failure& e)
    {
        std::cout << "Caught an ios_base::failure.\n";
        if (e.code() == std::io_errc::stream)
            std::cout << "The error code is std::io_errc::stream\n";
    }
}

출력:

Caught an ios_base::failure.
The error code is std::io_errc::stream

참고 항목

클래스를 error_code 열거형으로 식별함
(클래스 템플릿)
(C++11)
플랫폼 종속 에러 코드를 보유함
(클래스)
(C++11)
IO 스트림 에러 코드들
(열거형)