Hi, say I need to update the key of an entry in a btree_map. It's likely that the relative position doesn't change, so I would like to extract handle update the key and mapped value, then insert with a hint.
What is the correct way to do this?
I am doing something like this:
auto iter = map.find(key);
if (iter == map.end()) { .. }
auto hint = std::next(iter);
auto handle = map.extract(iter);
if (handle.empty()) return;
handle.mapped() = newEntry;
return *map.insert(hint, std::move(handle));
On small test cases this works fine, but with production scenarios, I get this assertion failing on the insert:
absl/container/internal/btree.h:1489 assert(i <= finish());
Any ideas what I'm doing wrong here? I am using the "Mon Dec 20 08:44:32 2021 -0800" export. Typically it doesn't show up until quite a few modifications of the map, but have not pinpointed a small example yet.
Thanks,
Chris