Using C++11 range-based for loop correctly in Qt

后端 未结 2 663
野的像风
野的像风 2020-12-24 14:35

According to this talk there is a certain pitfall when using C++11 range base for on Qt containers. Consider:

QList list;

for(c         


        
2条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 15:22

    Qt has an implementation to resolve this, qAsConst (see https://doc.qt.io/qt-5/qtglobal.html#qAsConst). The documentation says that it is Qt's version of C++17's std::as_const().

提交回复
热议问题