다음을 통해 공유


out_of_range 클래스

The class serves as the base class for all exceptions thrown to report an argument that is out of its valid range.

class out_of_range : public logic_error {
public:
    explicit out_of_range(const string& message);
    explicit out_of_range(const char *message);
};

설명

The value returned by exception 클래스 is a copy of message.data.

예제

// out_of_range.cpp
// compile with: /EHsc
#include <string>
#include <iostream>

using namespace std;

int main() {
// out_of_range
   try {
      string str( "Micro" );
      string rstr( "soft" );
      str.append( rstr, 5, 3 );
      cout << str << endl;
   }
   catch ( exception &e ) {
      cerr << "Caught: " << e.what( ) << endl;
   };
}

Output

Caught: invalid string position

요구 사항

Header: <stdexcept>

네임스페이스: std

참고 항목

참조

logic_error 클래스

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