I extended a const function, and everytime that const function is called I have to create a map. As in
int foo() const {
map<int, int> bar;
// setup bar
...
return utility::eval(bar);
}
But declaring bar is very expensive. I can cut my CPU footprint in half by declaring bar is an instance variable, but doing so doesn’t respect constess. Is there a non-hacky way to get the best of both worlds?
Yes.
See also http://www.highprogrammer.com/alan/rants/mutable.html and triple check whether it makes sense for you to actually use
mutablehere.