Namespaces
Variants
Actions

std::range_error

From cppreference.com
< cpp‎ | error
 
 
 
Defined in header <stdexcept>
class range_error;

Defines a type of object to be thrown as exception. It can be used to report range errors (that is, situations where a result of a computation cannot be represented by the destination type).

The only standard library components that throw this exception are std::wstring_convert::from_bytes and std::wstring_convert::to_bytes.

The mathematical functions in the standard library components do not throw this exception (mathematical functions report range errors as specified in math_errhandling).

All member functions of std::range_error are constexpr: it is possible to create and use std::range_error objects in the evaluation of a constant expression.

However, std::range_error objects generally cannot be constexpr, because any dynamically allocated storage must be released in the same evaluation of constant expression.

(since C++26)
cpp/error/exceptioncpp/error/runtime errorstd-range error-inheritance.svg

Inheritance diagram

Contents