Concept difference between pre and post increment operator for STL

后端 未结 5 1439
再見小時候
再見小時候 2020-12-19 04:44

Supposedly:

for (vector::iterator iter = ivec.begin(); iter != ivec.end(); ++iter)
{}

I do understand the difference when it com

5条回答
  •  攒了一身酷
    2020-12-19 05:31

    In general pre-increment is usually preferable to post-increment because it may allow for some optimization that can avoid temporaries being constructed. As to exactly how it's implemented that depends on the STL included with your compiler.

提交回复
热议问题