Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- There won't be a discernable performance difference, when using a decent compiler.
- for (int i=0; i < data.size(); ++i)
- data[i].Foo();
- Not slower, just profile that! Simple code tends to be quicker. In this case, all versions are equally simple
- for (Object& it : data)
- it.Foo();
- Fixed that for you: use a reference to avoid unwanted copying. This is roughly equivalent to:
- for (auto it=std::begin(data); it!=std::end(data); ++it)
- it->Foo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement