Performance issue for vector::size() in a loop in C++

前端 未结 10 828
离开以前
离开以前 2020-11-29 04:37

In the following code:

std::vector var;
for (int i = 0; i < var.size(); i++);

Is the

10条回答
  •  盖世英雄少女心
    2020-11-29 05:06

    It's 'called' each time, but I put called into quotes because it really probably is just an inline method call, so you don't have to worry about its performance.

    Why not use vector::iterator instead?

提交回复
热议问题