[Development] What's the status of a moved-from object?

Mutz, Marc marc at kdab.com
Sat May 25 19:42:21 CEST 2019


On 2019-05-25 17:24, Konstantin Ritt wrote:
> сб, 25 мая 2019 г., 12:30 Mutz, Marc via Development
>> Repeat after me: default ctors do _not_ establish a valid value.
> 
> Perhaps you mean "trivial type's default ctors do _not_ establish a
> valid value"?

No, I actually meant default ctor. What should the default value be? 
_Obviously_ zero-initialisation. But oh, no, QSize is different. So 
maybe it's not _quite_ so obvious what the default value is. Why is 
pen's default value a black solid line instead of NoPen? Why is QBrush's 
default ctor not solid black, but NoBrush? See? It's just nonsense to 
try to pick a default value, so this is to say: Don't try.

There's exactly one exception: containers. _Clearly_ no-one would _ever_ 
expect a container to start out anything but empty.

Thanks,
Marc



More information about the Development mailing list