[Interest] Q_FOREACH creating copy , was (no subject)

Prav pr12og2 at programist.ru
Tue Jun 30 13:46:34 CEST 2015


> Maybe you can  read my mail from this morning. In short, i talked about
> c++11 ranged base for loop which would look like
Sure  I did ... I just have to work with MSVC 2010 compiler which does not support such loops (this is Microsoft's jail for developers) ... but it seems very interesting ... thanks for sharing ... I will be aware of this option


>> 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.

But I still see nothing bad in using iterator-bases loop for Qt-containers.




More information about the Interest mailing list