вт, 21 мая 2019 г., 11:32 Mutz, Marc via Development <
development@qt-project.org>:

> And while the partially-formed
> state can be extended to non-pimpled classes easily:
>
>      class QRect {
>         int x, y, w, h;
>      public:
>         QRect() = default;
>      };
>      QRect r; // partially-formed
>      r.x();   // compilers _already_ warn about this
>      QRect r = {}; // zero-initialized
>
> That
> should be modelled by optional<QRect>, not by QRect itself.
>

Whilst the statement feels reasonable, this will require tons of API
changes and double checks on the user side:

optional<QRect> Item::childrenRect() const
{
    if (hasChildren()) {
        QRect r = {};
        for (auto *child : children())
            r.unite(child->boundingRect().value_or({});
        return r;
    }
    return nullopt;
}

QRect r = item->boundingRect().value_or({});
if (!r.isEmpty())
    ~~~


Note that I'm ok with that, but should we enforce such a huge efforts all
over Qt API just for making the default-constructible QRect a no-op?



Konstantin
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to