[Development] Move ctors for q_declare_shared types

Julien Blanc julien.blanc at nmc-company.com
Fri Jun 26 16:25:20 CEST 2015


Le vendredi 26 juin 2015 à 16:14 +0200, Olivier Goffart a écrit :


> > 
> > - Standard containers guarantee that the old elements get either move
> > assigned or destroyed.
> 
> I partially disagree.
> The wording seems to indeed implies that the move assignement operator of 
> std::vector should do iterate over all elements to destroy or move them. But 
> in practice, GCC implementation does not do that:
> http://cpp.sh/2s4w
> 
> Is it a bug in the GCC's stdlib implemenation?  Or is it a misunderstanding of 
> the wording of the standard?


Actually this is an error in your example, not gcc.

Line 15 :
v.push_back( {} ); --> a.push_back({});

The wording says that existing elements in the *destination* container
should be move assigned or destroyed. In that case, gcc correctly
destroys them.

The wording says nothing about individually moving elements (that would
be a huge performance breaker).

Regards,

Julien Blanc


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150626/95b85fa4/attachment.html>


More information about the Development mailing list