Re: Is this a bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2009-07-16 at 17:31 -0700, Ian Lance Taylor wrote:
> For an integer type there is no performance difference between ++x and
> x++.
> 
> For a C++ class which defines operator++ and a copy constructor, there
> can be performance differences between ++x and x++.  The latter often
> requires the compiler to invoke the copy constructor to hold onto the
> old value before invoking operator++.  So if you are writing C++, it's
> often a good idea to write ++x when x is a class type, such as an STL
> iterator.  The compiler can sometimes eliminate the copy constructor,
> but not always.
> 
> Ian

Thank you, Ian. Being mostly a C programmer, I often forget about the
things that C++ does behind the scenes.

My real preference is assembly language. Then it's just me and the
machine. ;)

Bob



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux