gnuradio / pmt

pmt
GNU Lesser General Public License v3.0
11 stars 11 forks source link

map: make [] operator const #44

Closed mormj closed 2 years ago

mormj commented 2 years ago

Signed-off-by: Josh Morman jmorman@gnuradio.org

jsallay commented 2 years ago

I'm guessing that you ran into an issue where you tried to called operator[] on a const map and the compiler complained. This is what happens with regular stl maps. The solution there is to use the at function, which works the same as operator[] except it throws an error is the key doesn't exist rather than creating a new element.

I could also be okay with creating a const version of operator[] that calls at on the underlying map.