We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc94b87 commit 947913fCopy full SHA for 947913f
src/limitedmap.h
@@ -66,8 +66,11 @@ class limitedmap
66
}
67
void update(const_iterator itIn, const mapped_type& v)
68
{
69
- // TODO: When we switch to C++11, use map.erase(itIn, itIn) to get the non-const iterator.
70
- iterator itTarget = map.find(itIn->first);
+ // Using map::erase() with empty range instead of map::find() to get a non-const iterator,
+ // since it is a constant time operation in C++11. For more details, see
71
+ // https://stackoverflow.com/questions/765148/how-to-remove-constness-of-const-iterator
72
+ iterator itTarget = map.erase(itIn, itIn);
73
+
74
if (itTarget == map.end())
75
return;
76
std::pair<rmap_iterator, rmap_iterator> itPair = rmap.equal_range(itTarget->second);
0 commit comments