std::vector::at throws a std::out_of_range if the requested value is not in range of the container.
The constructor for std::out_of_range requires a string, which can be accessed through .what() when catching the exception.
But I have never seen anything written about what must actually be in that message. This can be useful to know for at least two reasons:
- I might want to display this message to a user, for example when running with debug options enabled. Then it is good to know if there are any limits on the length, language, character set, etc.
- I might want to use
std::out_of_rangein my own class if it is similar enough to a standard container, and return a message that is in line with the format used in the standard library.
Is this defined in the standard? If not, is it defined to not be defined?