std::runtime_error
来自cppreference.com
在标头 <stdexcept> 定义
|
||
class runtime_error; |
||
定义作为异常抛出的对象类型。它报告源于程序范围之外,且无法轻易预测到的错误。
std::runtime_error 的全部成员函数均为 constexpr:在常量表达式求值中创建并使用 std::runtime_error 对象是可能的。然而, |
(C++26 起) |
下列标准库组件会抛出 std::runtime_error
类型异常:
(C++20 起) |
另外,以下标准异常类型派生自 std::runtime_error
:
(C++11 起) |
(C++17 起) |
(C++20 起) |
目录 |
[编辑] 成员函数
(构造函数) |
构造拥有给定消息的新 runtime_error 对象 (公开成员函数) |
operator= |
替换 runtime_error 对象 (公开成员函数) |
std::runtime_error::runtime_error
runtime_error( const std::string& what_arg ); |
(1) | (C++26 起为 constexpr) |
runtime_error( const char* what_arg ); |
(2) | (C++26 起为 constexpr) |
runtime_error( const runtime_error& other ); |
(3) | (C++11 起为 noexcept) (C++26 起为 constexpr) |
3) 复制构造函数。如果 *this 与 other 的动态类型都是
std::runtime_error
,那么