OUString is mutable?
Noel Grandin
noel at peralex.com
Fri Sep 28 07:05:35 PDT 2012
On 2012-09-28 16:00, Caolán McNamara wrote:
> On Fri, 2012-09-28 at 14:17 +0200, Noel Grandin wrote:
>> you can do this:
>>
>> void f(OUString s) {
>> s = "2";
>> }
>>
>> OUString s = "1";
>> f(s);
>> cout << s; // will print "2"
> That will print "1" not "2".
>
> Maybe you meant
>
> void f(OUString& s) {
> s = "2";
> }
>
> OUString s = "1";
> f(s);
> cout << s; // will print "2"
>
> but that's perfectly reasonable.
>
> C.
>
Yeah, that's what I meant.
But that's also what I have a problem with.
It means that any OUString field or variable is effectively mutable,
which makes the difference between it and OUStringBuffer boil down to
the presence of the nCapacity field.
If you tell me that the saving from not having the nCapacity field is
the motivation, then I get understand, but then we should update the
docs to reflect that fact, rather than pretending that OUString is
immutable.
Disclaimer: http://www.peralex.com/disclaimer.html
More information about the LibreOffice
mailing list