std::length_error_C++中文网
定义作为异常抛出的对象类型。它报告试图超出一些对象的实现定义长度极限所导致的错误。
此异常为 std::basic_string 的成员函数和 std::vector::reserve 所抛出。
继承图
成员函数
std::length_error::length_error
| explicit length_error( const std::string& what_arg ); |
(1) | |
| explicit length_error( const char* what_arg ); |
(2) | (C++11 起) |
以 what_arg 为解释字符串构造异常对象,能通过 what() 访问它。
因为不容许复制 std::length_error 抛出异常,通常将此消息在内部存储为分离分配的引用计数字符串。这也是构造函数不接收 std::string&& 参数的理由:无论如何它必须复制内容。
参数
异常
可能抛出 std::bad_alloc
参阅
| 更改存储的字符数 ( std::basic_string<CharT,Traits,Allocator> 的公开成员函数) |