[Development] unique_ptr and Qt, Take 2

Marco Bubke Marco.Bubke at qt.io
Thu Jun 13 09:03:00 CEST 2019


On June 12, 2019 23:13:14 Matthew Woehlke <mwoehlke.floss at gmail.com> wrote:
>> me here. I think Daniel is on to something and we really should explore
>> having smart pointers in Qt 6, but at this point I'm not convinced
>> std::unique_ptr alone is it. I'd like to see what we could achieve with a
>> QObject-specific smart pointer that understood ownership-taking functions
>> (setParent, addWidget, etc.) and observing-only API (like connect()).
>
> Idea: make this hypothetical pointer be a QObject that initially "owns"
> the object to which it points. If the object is reparented, the pointer
> will stop "owning" it but will still have the reference.
Can you implement it so that it fits owner<T>? One of the purposes is that the static analysis can be sure about the ownership.




More information about the Development mailing list