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.
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