Name

overflow_error class — Arithmetic overflow

Synopsis

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.

image with no caption

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.

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.