class
<stdexcept>
std::out_of_rangeOut-of-range exception
It is a standard exception that can be thrown by programs. Some components of the standard library, such as vector, deque, string and bitset also throw exceptions of this type to signal arguments out of range.
It is defined as:
1
2
3
4
class out_of_range : public logic_error {
public:
explicit out_of_range (const string& what_arg);
};
1
2
3
4
5
class out_of_range : public logic_error {
public:
explicit out_of_range (const string& what_arg);
explicit out_of_range (const char* what_arg);
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// out_of_range example
#include <iostream> // std::cerr
#include <stdexcept> // std::out_of_range
#include <vector> // std::vector
int main (void) {
std::vector<int> myvector(10);
try {
myvector.at(20)=100; // vector::at throws an out-of-range
}
catch (const std::out_of_range& oor) {
std::cerr << "Out of Range error: " << oor.what() << '\n';
}
return 0;
}
Out of Range error: vector::_M_range_check
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4