overflow_error class — Arithmetic overflow
class overflow_error : public runtime_error { public: explicit overflow_error(const string& what_arg); };
The overflow_error
class
can be used for arithmetic overflow. For example, bitset::to_ulong
throws overflow_error
if the arithmetic value of
the bitset
exceeds the maximum
value of an unsigned
long
.
Note that overflow in most arithmetic expressions has
undefined behavior; an implementation might throw overflow_error
, but there is no guarantee
that it will throw this or any other exception.