Apr 14, 2011 at 1:37pm UTC
I have a map<int<map<int,char> > variable.
It is declared at the private section of my .h file :
map<unsigned int,std::map<unsigned int,char> > map__type;
I also have :
vector<string> vecHheader;
I use it in this function with sufix const keyword
myfunction (bla bla) const
Ok I can return vector information but not map ???
( I have the const error : ... bla bla bla dicard qualifiers.)
Whats happen ? I can not use map into a const functions ? I want only to returning information !
Any idea ? Thanks .
Apr 14, 2011 at 1:41pm UTC
Hm, I guess it's about the [] operator of map (map__type[3] or so). No, you can't use it when 'map__type' is const since the [] operator creates the field if it doesn't exists. You need to use 'find()' in that situation.
Apr 14, 2011 at 3:25pm UTC
And if I make my map mutable?
What can I expect about the perfomance of mymap or const function?
Thanks
Apr 15, 2011 at 6:50am UTC
If you do so at least two things can happen:
1. The map gets filled with unwanted data
2. You can't find a 'free' index
You have to answer the questen: What will happen when someone asks for data and the data is not present?