basic_ios::exceptions

스트림에서 throw 되는 예외를 나타냅니다.

iostate exceptions( ) const;
void exceptions(
    iostate _Newexcept
);
void exceptions(
    io_state _Newexcept
);

매개 변수

  • _Newexcept
    원하는 예외를 throw 하는 플래그입니다.

반환 값

현재 스트림에 대 한 예외가 지정 되는 플래그입니다.

설명

첫 번째 멤버 함수 저장된 예외 마스크를 반환합니다.두 번째 멤버 함수 저장소 _Except 예외 마스크 및 반환에 해당 이전 값이 저장 됩니다.참고 저장 하는 새 예외 마스크 호출에서와 마찬가지로 예외가 throw 될 수 있습니다 취소( rdstate ).

예제

// basic_ios_exceptions.cpp
// compile with: /EHsc /GR
#include <iostream>

int main( )
{
   using namespace std;

   cout << cout.exceptions( ) << endl;
   cout.exceptions( ios::eofbit );
   cout << cout.exceptions( ) << endl;
   try 
   {
      cout.clear( ios::eofbit );   // Force eofbit on
   }
   catch ( exception &e ) 
   {
      cout.clear( );
      cout << "Caught the exception." << endl;
      cout << "Exception class: " << typeid(e).name()  << endl;
      cout << "Exception description: " << e.what() << endl;
   }
}
  
  

요구 사항

헤더: <ios>

네임 스페이스: std

참고 항목

참조

basic_ios Class

iostream 프로그래밍

iostreams 규칙