For what I know, C++ defines map<a,b>::value_type as pair<const a,b>
What will happen if I use a pointer type as key type in map, i.e., is
std::map<const char*,int>::value_type::first_type = const char*
as I would expect from definition above or
std::map<const char*,int>::value_type::first_type = const char* const
as would be more logical (since otherwise i would be allowed to change key value from a map iterator)?
Your reasoning is correct,
value_type::firstwould bechar const * const.There is a common source of confusion in thinking that
const TwhenTis atype *isconst type *, but that is not so. Unlike macros,typedefs are not text substitution, nor are template arguments. When you doconst T, ifTis atypedefor template argument, you are adding aconstto the type as a whole.That is the one reason why I like to write my
consts at the right of the type, as it causes less confusion:T const *, add an extra const, getT const * const.