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

Konstantin Ritt ritt.ks at gmail.com
Sun May 26 10:51:57 CEST 2019

сб, 25 мая 2019 г., 20:42 Mutz, Marc via Development <
development at qt-project.org>:

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

Sure we should force a no-op default ctor where possible, and provide some
helper code that returns a valid default/specialized value of that type
where {0} isn't enough or non-intuitive (i.e. QQuaternion::identity(),
QRect::empty(), QSize::invalid()).

There could more exceptions when we're talking about non-trivial types, at
least some of them could be resolved by providing convenience/helper

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190526/24d45a88/attachment.html>

More information about the Development mailing list