this String should be immutable. But some methods have to replace something in the String
So which one is it ? For me those two options are not compatible.
So I have to copy the immutable String to another Variable and this is indricate
Its quite straightforward :
QString str
= my_const_string;
// no copy made here, because of implicit sharing str.replace(a,b); // my_const_string is left untouched, str gets its own copy of data and alters it
QString str = my_const_string; // no copy made here, because of implicit sharing
str.replace(a,b); // my_const_string is left untouched, str gets its own copy of data and alters it
To copy to clipboard, switch view to plain text mode
Bookmarks