std::domain_error_C++中文网
定义作为异常抛出的对象类型。实现可用它报告定义域错误,即输入在操作有定义的定义域外的情形。
标准库组件不抛此异常(数学函数报告以指定于 math_errhandling 的方式定义域错误)。然而,第三方库使用它。例如,若启用 boost::math::policies::throw_on_error (默认设置)则 boost.math 抛出 std::domain_error 。
继承图
成员函数
std::domain_error::domain_error
| explicit domain_error( const std::string& what_arg ); |
(1) | |
| explicit domain_error( const char* what_arg ); |
(2) | (C++11 起) |
以 what_arg 为解释字符串构造异常对象,能通过 what() 访问它。
因为不容许复制 std::domain_error 抛出异常,通常将此消息在内部存储为分离分配的引用计数字符串。这也是构造函数不接收 std::string&& 参数的理由:无论如何它必须复制内容。
参数
异常
可能抛出 std::bad_alloc