【发布时间】:2023-04-04 17:14:05
【问题描述】:
std::vector::resize() 抛出std::bad_alloc 异常后,std::vector 对象中的原始数据是否仍然有效且可访问?
答案是否适用于其他分配器,例如如果boost::interprocess::allocator被用作分配器,boost::interprocess::bad_alloc被抛出?
【问题讨论】:
-
根据cppreference:如果抛出异常,这个函数没有任何作用(强异常保证)。(我让别人带一份标准回答问题)
-
我现在看到了一个可能的重复项(尽管答案措辞特定于
push_back和push_front):stackoverflow.com/questions/8899814/…
标签: c++ vector stl containers boost-interprocess