首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::logic_error

Defined in header <stdexcept>

class logic_error;

定义要作为异常抛出的对象类型。它报告程序中错误逻辑的结果,例如违反逻辑先决条件或类不变量,并且可能是可以预防的。

没有标准库组件直接抛出此异常,但异常类型std::invalid_argument,,,std::domain_error,,,std::length_error,,,std::out_of_range,,,std::future_error,和std::experimental::bad_optional_access派生自std::logic_error...

二次

二次

继承图

成员函数

(constructor)

constructs the exception object (public member function)

STD:逻辑[医]错误::逻辑[医]误差

explicit logic_error( const std::string& what_arg );

(1)

explicit logic_error( const char* what_arg );

(2)

(since C++11)

构造异常对象what_arg作为解释性字符串,可以通过what()...

因为复制std::exception不允许抛出异常,此消息通常作为单独分配的引用计数字符串存储在内部。这也是为什么没有构造函数std::string&&::无论如何,它必须复制内容。

参数

what_arg

-

explanatory string

例外

可抛std::bad_alloc...

继承自STD:例外

成员函数

(destructor) virtual

destructs the exception object (virtual public member function of std::exception)

what virtual

returns an explanatory string (virtual public member function of std::exception)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券