Better C++?

Steven Schveighoffer schveiguy at yahoo.com
Fri Feb 14 13:15:45 PST 2014


On Fri, 14 Feb 2014 15:27:46 -0500, Jeremy DeHaan  
<dehaan.jeremiah at gmail.com> wrote:

> My original idea was to be (C++)++, which makes sense
> conceptually, but wasn't valid code. :P

Actually, it doesn't make sense. C++ increments C, but returns the value  
that C was before the increment. So it returns a temporary. Incrementing a  
temporary is not allowed (where would the incremented value go?), and even  
if it were allowed, would likely not be what you want ;)

++++C may be valid, but is butt-ugly.

C+=2 is just far superior on all fronts!

-Steve


More information about the Digitalmars-d mailing list