map/fixed: add a const index operator
This commit is contained in:
parent
37f5d77622
commit
50f38c21af
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user