Hacker News new | past | comments | ask | show | jobs | submit login

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.




You 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).


> 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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: