std::underflow_error

定义于头文件 <stdexcept>
class underflow_error;

定义作为异常抛出的类型。它可用于报告算术下溢错误(即计算结果是非正规浮点值的情形)。

标准库组建不抛此异常(数学函数按指定于 math_errhandling 的方式报告下溢错误)。然而第三方库使用它。例如,若启用了 boost::math::policies::throw_on_error (默认设置),则 boost.math 抛出 std::underflow_error

cpp/error/exceptioncpp/error/runtime errorstd-underflow error-inheritance.svg
关于这幅图像

继承图

目录

成员函数

(构造函数)
构造异常对象
(公开成员函数)

std::underflow_error::underflow_error

explicit underflow_error( const std::string& what_arg );
(1)
explicit underflow_error( const char* what_arg );
(2) (C++11 起)

what_arg 为解释性字符串构造异常对象,它能通过 what() 访问。

因为不允许 std::exception 的复制抛出异常,此信息典型地在内部作为分离分配的引用计数字符串存储。这也是构造函数不采用 std::string&& 参数的理由:无论如何它必须复制内容。

参数

what_arg - 解释性字符串

异常

可能抛出 std::bad_alloc

继承自 std::exception

成员函数

析构该异常对象
(std::exception 的虚公开成员函数)
[虚]
返回解释性字符串
(std::exception 的虚公开成员函数)

版本历史

  • (当前 | 先前 2017年8月26日 (六) 23:16Fruderica讨论 | 贡献. . (919字节) (-152). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 09:06P12bot讨论 | 贡献 . . (1,071字节) (-25). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 14:50P12bot讨论 | 贡献 . . (1,096字节) (+265). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 11:37P12讨论 | 贡献 . . (831字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 07:00TranslationBot讨论 | 贡献. . (831字节) (-12). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 14:25P12讨论 | 贡献 . . (843字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 13:00TranslationBot讨论 | 贡献. . (843字节) (+843). . (Translated from the English version using Google Translate)