Closed portsip closed 1 year ago
"Iterator invalidation behaves in a way closer to std::vector and std::deque (see API for details)", see the https://github.com/Tessil/ordered-map#differences-compared-to-stdunordered_map section.
Your iterator is thus invalidated during the erasure, you can't increment it.
Hi, the below codes cause the application to crash:
tsl::ordered_map<std::string, int32_t> m; m["ABC"] = 1; m["ccc"] = 2;
auto it = m.begin; for (; it != m.end();) { m.erase(it++); // crashe // it = m.erase(it); // this works fine }
Doesn't ordered_map support the m.erase(it++); as well as the std::map?