[Development] Adding std::weak_ptr<void> to QModelIndex

Marc Mutz marc.mutz at kdab.com
Fri Apr 21 09:13:37 CEST 2017


On Friday 21 April 2017 08:42:37 Filippo Cucchetto wrote:
> Is there any plan to enhance the QModelIndex interface by adding support to
> std::weak_ptr<void?
> I know that is not necessary since we can directly store T* from
> shared_ptr<T> but being able to store a weak_ptr seems a little bit safer.

There is no such plan. QModelIndexes should not be stored anywhere, they are 
simply an interface type: as long as you're using ti correctly, you could not 
observe the weak_ptr being reset, anyway, and adding an expensive-to-copy type 
such as std::weak_ptr to an otherwise Trivial Class does not pull it's weight.

If and when we change QModelIndex to become more convenient, but also more 
expensive to use, it should probably get a QVariant (or std::any), not any 
particular type.

Thanks,
Marc

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts



More information about the Development mailing list