overflow_error 클래스

이 클래스는 산술 오버플로를 보고하기 위해 발생하는 모든 예외에 대한 기본 클래스로 사용됩니다.

구문

class overflow_error : public runtime_error {
public:
    explicit overflow_error(const string& message);

    explicit overflow_error(const char *message);

};

설명

반환되는 what() 값은 .의 message.data()복사본입니다. 자세한 내용은 whatdata를 참조하세요.

예시

// overflow_error.cpp
// compile with: /EHsc
#include <bitset>
#include <exception>
#include <iostream>
#include <typeinfo>
using namespace std;

int main()
{
   try
   {
      bitset<33> b;
      b[32] = 1;
      b[0] = 1;
      unsigned long x = b.to_ulong();
   }
   catch (const exception& e)
   {
      cerr << "Caught: " << e.what() << endl;
      cerr << "Type: " << typeid(e).name() << endl;
   }
}
/* Output:
Caught: bitset overflow
Type: class std::overflow_error
*/

요구 사항

헤더:<stdexcept>

네임스페이스: std

참고 항목

runtime_error 클래스
C++ 표준 라이브러리의 스레드 보안