Post increment and decrement

Ali Çehreli via Digitalmars-d digitalmars-d at puremagic.com
Sat Mar 14 15:35:24 PDT 2015


On 03/14/2015 03:23 PM, deadalnix wrote:

 > But, for some reason, the topic come up again and again from C++ devs
 > that have no idea the optimization guys solved the issues for years now.

If we are talking about C++, it is not possible to not take that copy 
for user-defined types. Due to separate compilation, the compiler does 
not even see the definition of operator++(int).

And the compiler cannot replace calls to operator++(int) with calls to 
operator++() (when the return value is not used) because the programmer 
may have done different things than the canonical implmentation of 
post-increment.

C++ needs a rule like D's, which will never be there.

Ali



More information about the Digitalmars-d mailing list