[Development] parented_ptr
André Somers
andre at familiesomers.nl
Wed Oct 29 17:06:55 CET 2025
Hi,
On 29-10-2025 16:27, André Somers via Development wrote:
>
>> · Add a QObject::addChild(std::unique_ptr<QObject *> child)
>
> Start simple, I would suggest. Do you really think that this will
> bring a lot of value? Introduce the basic version, see how it actually
> impacts your code base and collect feedback, and then see if an
> overload like this really would bring value. One problem I see is
> that, AFAIK, a std::unique_ptr<QObject> is a distinct type from a
> std::unique_ptr<SomethingDerivedFromQObject>, so the signature above
> won't work. Something _like_ this can of course be done, using a
> template and casting, but it won't be as pretty.
>
Actually, let me correct myself: this actually _does_ seem to compile,
to my surprise. Though from my quick experimentation on godbolt the
results on MSVC look weird, so maybe support for this isn't something
one can depend on.
Cheers,
André
More information about the Development
mailing list