On Tue, 2011-10-25 at 09:16 +0200, Stephan Bergmann wrote:
In general, and if the expression's value is not used, prefix
increment/decrement is preferable to postfix, as the former conceptually
avoids creation of a temporary that makes the old, unmodified value
available as the expression's value.
Just to be picky, if my memory of C++ serves, ...
(*) For built-in types, it is true that prefix and postfix
increment/decrement have the same effect on the variable.
(*) For STL iterators, I guess that the same statement is true. At
least, I think that a violation of the symmetry would have
provoked my "Oh, eeeuuuw!" reflex so strongly that I would
remember it. <grin />
(*) For class types in general, the prefix and postfix operators can
be completely different. In my opinion, it is evil to do this;
but the language allows it.
Terry.
That said, you see both forms with more-or-less similar frequency in the
wild.
-Stephan
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.