Questions tagged «exception-safety»

1
在使用GCC的unordered_map :: insert KeyEqual异常期间发生内存泄漏-破坏了强有力的异常安全保证吗?
我正在使用GCC 7.3.1,但也在coliru(我相信它是9.2.0版)上进行了测试。使用以下内容进行构建: g++ -fsanitize=address -fno-omit-frame-pointer rai.cpp 这里是rai.cpp: #include <iostream> #include <unordered_map> int main() { try { struct MyComp { bool operator()(const std::string&, const std::string&) const { throw std::runtime_error("Nonono"); } }; std::unordered_map<std::string, std::string, std::hash<std::string>, MyComp> mymap; mymap.insert(std::make_pair("Hello", "There")); mymap.insert(std::make_pair("Hello", "There")); // Hash match forces compare } catch (const std::exception& e) { …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.