[Interest] use of deleted function errors in QList / qarraydataops.h

Thiago Macieira thiago.macieira at intel.com
Tue Feb 28 01:14:00 CET 2023


On Monday, 27 February 2023 13:05:01 PST Hamish Moffatt via Interest wrote:
> On 28/2/23 04:14, Thiago Macieira wrote:
> > On Sunday, 26 February 2023 23:24:43 PST Hamish Moffatt via Interest wrote:
> >> Is there a solution?
> > 
> > Remove the const in:
> >       struct S
> >       {
> >       
> >           const QVector<int> v; // compiles if not const
> >       
> >       };
> > 
> > If S is not copyable, then QVector can't copy it and QVector requires
> > copying all its elements.
> 
> May I ask why that is? Qt5 QVector and std::vector are both OK with the
> above.

Qt 5 QVector is not ok with the above, it just hasn't produced an error *yet*. 
All Qt main containers are implicitly-shared and therefore must be able to 
copy their elements. Therefore, your elements must be copyable.

std::vector doesn't have this requirement. It is copyable if the element is 
copyable, otherwise it isn't.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230227/d82ed171/attachment.bin>


More information about the Interest mailing list