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


_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to