Namespaces
Variants
Actions

std::domain_error

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

Defines a type of object to be thrown as exception. It may be used by the implementation to report domain errors, that is, situations where the inputs are outside of the domain on which an operation is defined.

The standard library components do not throw this exception (mathematical functions report domain errors as specified in math_errhandling). Third-party libraries, however, use this. For example, boost.math throws std::domain_error if boost::math::policies::throw_on_error is enabled (the default setting).

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

However, std::domain_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/logic errorstd-domain error-inheritance.svg

Inheritance diagram

Contents