[Development] QList

Ville Voutilainen ville.voutilainen at gmail.com
Wed Mar 29 13:39:34 CEST 2017


On 29 March 2017 at 14:26, Marc Mutz <marc.mutz at kdab.com> wrote:
>> If I start using QArrayList<indirect_type> today, and it's immediately
>> deprecated, what
>> should I use instead? vector<unique_ptr<indirect_type>>? That doesn't
>> do implicit sharing,
>
> Because it's you who asks: if CoW is so super-important, why did the committee
> drop support for CoWed std::string in C++11?

Because they don't have cross-thread signals that need to sometimes
copy the value. :)

>> so I can't pass it by value into slots.
>
> Why would you want to? No-one does that. People use cref, like for all large
> types. Qt makes sure that a copy is taken only when needed, ie. when the slot
> is in a different thread from the emitter. That is very rare, and people can
> be expected to pass a shared_ptr<vector> instead in these situations.

Right. I can't use a vector<unique_ptr<int>> universally, I need to
use a shared_ptr<vector<unique_ptr<int>>>
for signal cases. That's not very user-friendly any more.

> Bottomline: don't expect me to support any form of implicit sharing. The
> answer will always be: because you should use explicit sharing.
>
> This is why I see QArrayList as a phase-out vehicle for QList, not as a fancy
> new container.


All this makes me wonder why we should have QArrayList at all. If it's
slated for immediate deprecation,
we perhaps should never let it out, and just tell people to use
QVector or QLinkedList instead of QList.



More information about the Development mailing list