[Benchmark] Post increment vs Pre increment
- I believe that the difference between ++i and i++ is obvious for c++ practitioners
- Pre-increment operator is faster, because instead of post-increment, it doesn't create a copy of object
// Pre-increment operator for KClass
KClass & operator++() { ++m_position; return *this; }
// Post-increment operator for KClass
KClass operator++(int) {
KClass copy(*this);
++(*this); // Calls KClass pre-increment operator
return copy;
}
(via http://en.allexperts.com/q/C-1040/Increment-operators.html)