3 ms·
It's usually a C++-ism, since in C++ generic iterators overwrite operator++, and when writing generic code, you must allow for this, since ++i is equivalent to
by tsimionescu 7y ago
It's usually a C++-ism, since in C++ generic iterators overwrite operator++, and when writing generic code, you must allow for this, since ++i is equivalent to i.operator++(), while i++ is equivalent to `auto x=i; i.operator++(); return x`.
Given the author, I assume that this is also common in D.
- jstimpfle 7y agoYou can override the postfix increment operator as well. The argument I've heard for why in C++ prefix is preferred is that compilers have a harder time optimizing out the temporary object cruft (especially older compilers).
- WalterBright 7y ago> You can override the postfix increment operator as well. You can, but if there are side effects in the object's implementation then it can be less efficient.