I have a const function provided by my framework (QT) from where I call to a non const function.
As might be expected, I have the tipycal error ( .... discard cualifiers)
All can be fixed making some elements mutable, is there any other solution?
And what I have to expect, in terms of performance, of a (in example) mutable vector ? Making an element mutable converts it slower ?
Thanks
just don't do it. It will trick the user of that function (likely yourself).
But... if you have a pointer you can modify the content of the object pointed to (but not the pointer itself)
if you want access an element of a std::map then you can call the 'find(key)' function of the map. You get an iterator where you can tell whether the entry exists or not.