<div dir="auto"><div data-smartmail="gmail_signature" dir="auto"><br></div><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">сб, 25 мая 2019 г., 20:42 Mutz, Marc via Development <<a href="mailto:development@qt-project.org" target="_blank" rel="noreferrer">development@qt-project.org</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2019-05-25 17:24, Konstantin Ritt wrote:<br>
> сб, 25 мая 2019 г., 12:30 Mutz, Marc via Development<br>
>> Repeat after me: default ctors do _not_ establish a valid value.<br>
> <br>
> Perhaps you mean "trivial type's default ctors do _not_ establish a<br>
> valid value"?<br>
<br>
No, I actually meant default ctor. What should the default value be? <br>
_Obviously_ zero-initialisation. But oh, no, QSize is different. So <br>
maybe it's not _quite_ so obvious what the default value is. Why is <br>
pen's default value a black solid line instead of NoPen? Why is QBrush's <br>
default ctor not solid black, but NoBrush? See? It's just nonsense to <br>
try to pick a default value, so this is to say: Don't try.<br>
<br>
There's exactly one exception: containers. _Clearly_ no-one would _ever_ <br>
expect a container to start out anything but empty.</blockquote></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">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()).</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">There could more exceptions when we're talking about non-trivial types, at least some of them could be resolved by providing convenience/helper initializers.</span><br></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">Konstantin</span><br></div><div class="gmail_quote" dir="auto"></div></div>