map with const keys but non const values?

后端 未结 5 661
半阙折子戏
半阙折子戏 2021-01-12 18:00

I have a situation, where I would like to have a map that does not allow to add/remove keys after initialization, but the values are allowed to change (thus I cannot simply

5条回答
  •  醉话见心
    2021-01-12 19:03

    Containers from the standard library are classes optimized for one usage that are expected to be used as is or included in higher level classes.

    Here your requirement (keys fixed after initialization) is not covered by the standart library containers, so you will have to build your own implementation. As it will not be a std::map, you can just implement the operations you need, probably nothing more that operator []...

提交回复
热议问题