[Interest] Q_FOREACH creating copy , was (no subject)
Prav
pr12og2 at programist.ru
Mon Jun 29 15:48:10 CEST 2015
> You're the one asking for help. You must not upset the people trying to help you.
I do not see any help in statements without supporting arguments. I just wanted to stress out what discussion can not evolve and help participants in this case.
As soon as the style changed I thanked ... so I was not trying to upset I was trying to make conversation useful for participants ... not only me can be interested in this question I think.
> Because you're wrong and the above can still detach.
> That can still detach. You want cbegin() and cend().
Good point ... I agree ... so here is the final "template" which is replacement for foreach
for (Container::const_iterator iter=container.cbegin(); iter!=container.cend(); ++iter) {
//...
}
But why this could be more insecure to container copy (as result of detaching) as Koehne Kai warns:
I'd be careful with such an advice, unless you understand the performance
implications (because range-based loop will sometimes detach the Qt
Container, which is potentially a lot more expensive than the shallow copy
foreach does)
is still unclear for me.
More information about the Interest
mailing list