I've been reading quite a few posts/questions about the micro-optimization of ++i and i++ in C++. And from what I've learnt is that ++i "can", not always, but can be faster than i++.
So this makes me ask this question, whats the point of i++ then? I thought that ++i is that you increment the value first then return it. Where as i++ you return the value then increment it. But I have made a very simple test on this:
for(int i = 0; i < 10; ++i)
{
std::cout << i << std::endl;
}
is the same as:
for(int i = 0; i < 10; i++)
{
std::cout << i << std::endl;
}
Both prints out the same results. So my real question is that is there a situation where you MUST use i++ rather than ++i? If there is, please explain. Thanks