The declaration for the [] operator on a std::map is this:
T& operator[] ( const key_type& x );
Is there a reason it isn't this?
T& operator[] ( const key_type& x );
const T& operator[] const ( const key_type& x );
Because that would be incredibly useful any time you need to access a member map in a const method.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…