Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On 10/03/2012 07:00 PM, Markus Mohrhard wrote:
after I got tinderbox mail complaining about ambiguous overload for
rtl::OUStringBuffer::append(bool) I wanted to ask if we could add a
rtl::OUStringBuffer::append(bool) method or if there are reasons
against it. From what I can see it could in the end even share the
implementation with the sal_Bool variant just needs an own method in
rtl::OUStringBuffer.

the overloads of OUStringBuffer::append are pretty horrible already
(e.g. append(sal_Bool) vs. append(char) or append(sal_Unicode) which is
always accidentally invoked when you pass a short);  but adding
append(bool) won't make that any worse than it is.

Seems like append(bool) is not possible without adjusting a lot of
places. The commit seems to have caused some test failures and
crashes. I reverted it for now.

...which only goes to show what a horrible mess C++ is in practice. bool is rather special, but you easily forget to consider all the consequences of that. Turns out that code like

  aBuf.append( pElementType->pTypeName );

(typelib_static_sequence_type_init, cppu/source/typelib/static_types.cxx), where pElementType->pTypeName is of type rtl_uString*, now chooses for overload resolution the standard boolean conversion from rtl_uString* to bool (yielding true, so appending "true" to aBuf) rather than the user-defined conversion by constructor from rtl_uString* to rtl::OUString.

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.