map/fixed: add a const index operator

This commit is contained in:
Danny Robson 2019-05-17 10:50:09 +10:00
parent 37f5d77622
commit 50f38c21af

View File

@ -112,6 +112,17 @@ namespace cruft::map {
}
//---------------------------------------------------------------------
mapped_type const& operator[] (KeyT const &key) const
{
ComparatorT cmp {};
for (auto &i: *this)
if (cmp (i.first, key))
return i.second;
throw std::out_of_range ("Invalid key");
}
//---------------------------------------------------------------------
mapped_type& operator[] (KeyT const &key)
{