Is the ranged based for loop beneficial to performance?

前端 未结 5 1891
遥遥无期
遥遥无期 2020-12-02 18:34

Reading various questions here on Stack Overflow about C++ iterators and performance**, I started wondering if for(auto& elem : container) gets \"expan

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 18:45

    No. It is same as the old for loop with iterators. After all, the range-based for works with iterators internally. The compiler just produces equivalent code for both.

提交回复
热议问题