aboutsummaryrefslogtreecommitdiff
path: root/src/limitedmap.h
diff options
context:
space:
mode:
authorwhythat <yuri.zhykin@gmail.com>2016-07-18 12:23:42 +0300
committerwhythat <yuri.zhykin@gmail.com>2016-08-09 03:11:28 +0300
commit947913fc54325bea88dd52ea219ea2c69e334c97 (patch)
tree77f60d410fd0d67a1a557d8b44dee8baa64ed395 /src/limitedmap.h
parentbc94b87487824c6fba45788facf96faba97a4aa6 (diff)
use std::map::erase(const_iterator, const_iterator) to get non-constant iterator
Diffstat (limited to 'src/limitedmap.h')
-rw-r--r--src/limitedmap.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/limitedmap.h b/src/limitedmap.h
index 4d9bb4fa21..7841d7f4a4 100644
--- a/src/limitedmap.h
+++ b/src/limitedmap.h
@@ -66,8 +66,11 @@ public:
}
void update(const_iterator itIn, const mapped_type& v)
{
- // TODO: When we switch to C++11, use map.erase(itIn, itIn) to get the non-const iterator.
- 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
+ // https://stackoverflow.com/questions/765148/how-to-remove-constness-of-const-iterator
+ iterator itTarget = map.erase(itIn, itIn);
+
if (itTarget == map.end())
return;
std::pair<rmap_iterator, rmap_iterator> itPair = rmap.equal_range(itTarget->second);