incubator-ooo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Le Grand <>
Subject Re: Build fails in main/drawinglayer/source/texture/texture3d.cxx
Date Wed, 17 Oct 2012 12:43:35 GMT
	Hi Herbert,

On 17.10.2012 13:48, Herbert Duerr wrote:
> On 17.10.2012 10:29, Armin Le Grand wrote:
>> I made some changes, got no errors on win (what means nothing as we
>> know). It's strange since ColorData is just a typedef (to sal_Int32) and
>> I see no way to auto-convert BitmapColor to it, so 'operator Color()' in
>> class Color should be used.
> BitmapColor has implicit conversion operators for both
>      BitmapColor::operator Color()
> and
>      BitmapColor::operator sal_uInt8()
> Since Color has a constructor for an unsigned integer
>      Color( sal_uInt32 nColor)
> the conversion is ambiguous, even if the second alternative needs an
> extra type conversion from sal_uInt8 to sal_uInt32.

Ah! That's the implicit one I've missed. That's really dangerous...

> This shows again that implicit conversions are very tricky even for
> experienced developers. So I suggest to prefer explicit constructors
> over implicit ones. Unfortunately explicit conversion operators are only
> available since C++11.
> Things like e.g. the implicit conversion from BitmapColor to sal_uInt8
> are too slick for my taste anyway and they should IMHO be made explicit
> by replacing their uses by something like GetIndex(), so the C++11
> feature of explicit conversion operators can be dispensed with.
> Herbert


View raw message