Namespaces
Variants

std:: iostream_category

From cppreference.net
< cpp ‎ | io
헤더 파일에 정의됨 <ios>
const std:: error_category & iostream_category ( ) noexcept ;
(C++11부터)

iostream 오류에 대한 정적 오류 범주 객체의 참조를 얻습니다. 해당 객체는 가상 함수 error_category :: name ( ) 를 재정의하여 문자열 "iostream" 에 대한 포인터를 반환해야 합니다. 이것은 std::ios_base::failure 타입의 예외에서 제공되는 오류 코드를 식별하는 데 사용됩니다.

목차

매개변수

(없음)

반환값

지정되지 않은 런타임 유형을 가진 정적 객체에 대한 참조로, std::error_category 에서 파생되었습니다.

예제

#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"
                  << "Error code: " << e.code().value() 
                  << " (" << e.code().message() << ")\n"
                  << "Error category: " << e.code().category().name() << '\n';
    }
}

가능한 출력:

Caught an ios_base::failure.
Error code: 1 (unspecified iostream_category error)
Error category: iostream

결함 보고서

다음 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2087 C++11 iostream_category 가 선언되지 않음 noexcept 선언됨 noexcept

참고 항목

스트림 예외
( std::ios_base 의 public member class)
(C++11)
IO 스트림 오류 코드
(열거형)