std::overflow_error
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   定义于头文件  <stdexcept>
  | 
||
|   class overflow_error;  | 
||
定义作为异常抛出的对象类型。它能用于报告算术上溢错误(即计算结果对目标类型过大的情形)。
仅有的抛此异常的标准库组件是 std::bitset::to_ulong 和 std::bitset::to_ullong 。
标准库组件的数学函数不抛此异常(数学函数按指定于 math_errhandling 的方式报告上溢错误)。然而第三方库使用它。例如,若启用 boost::math::policies::throw_on_error (默认设置),则 boost.math 抛出 std::overflow_error 。
继承图
成员函数
|    (构造函数)  | 
  构造拥有给定消息的新 overflow_error 对象 (公开成员函数)  | 
|    operator=  | 
   替换 overflow_error 对象 (公开成员函数)  | 
|    what  | 
   返回解释字符串  (公开成员函数)  | 
std::overflow_error::overflow_error
|   overflow_error( const std::string& what_arg );  | 
(1) | |
|   overflow_error( const char* what_arg );  | 
(2) | (C++11 起) | 
| (3) | ||
|   overflow_error( const overflow_error& other );  | 
(C++11 前) | |
|   overflow_error( const overflow_error& other ) noexcept;  | 
(C++11 起) | |
3) 复制构造函数。若 
*this 与 other 均拥有动态类型 std::overflow_error 则 std::strcmp(what(), other.what()) == 0 。 (C++11 起)参数
| what_arg | - | 解释字符串 | 
| other | - | 要复制的另一异常对象 | 
异常
1-2) 可能抛出 std::bad_alloc
注解
因为不容许复制 std::overflow_error 抛出异常,通常将此消息在内部存储为分离分配的引用计数字符串。这也是构造函数不接收 std::string&& 参数的理由:无论如何它必须复制内容。
std::overflow_error::operator=
|   overflow_error& operator=( const overflow_error& other );  | 
(C++11 前) | |
|   overflow_error& operator=( const overflow_error& other ) noexcept;  | 
(C++11 起) | |
以 other 的内容赋值。若 *this 与 other 均拥有动态类型 std::overflow_error 则赋值后 std::strcmp(what(), other.what()) == 0 。 (C++11 起)
参数
| other | - | 用以赋值的另一异常对象 | 
返回值
*this
std::overflow_error::what
|   virtual const char* what() const throw();  | 
(C++11 前) | |
|   virtual const char* what() const noexcept;  | 
(C++11 起) | |
返回解释字符串。
参数
(无)
返回值
指向有解释信息的空终止字符串的指针。该字符串适合转换并显示为 std::wstring 。保证该指针至少到获得它来源的异常对象被销毁,或在该异常对象上调用非 const 成员函数(例如复制赋值运算符)为止合法。
注解
允许但不要求实现覆写 what() 。
继承自 std::exception
成员函数
|    [虚]  | 
  析构该异常对象  ( std::exception 的虚公开成员函数)  | 
|    [虚]  | 
   返回解释性字符串  ( std::exception 的虚公开成员函数)  |