Re: template operator== not working
* Ben Voigt [C++ MVP]:
Alf P. Steinbach wrote:
const result or not has, as far as I know, no impact on RVO.
Then what "important possible optimization" were you referring to? I'm
lost.
Earlier in this thread, then giving URL to yet earlier reference, <url:
http://groups.google.com/group/microsoft.public.vc.language/msg/7209f10e7eece7d4>.
Just for clarity, this refers to what you the programmer can do, confined by the
rules of the language wrt. const and other things, whereas RVO is an
optimization applied by the compiler, which can do just about anything as long
as it's within the "as if" rule (and the standard explicitly gives it permission
to e.g. remove side-effects from copy constructors in some optimizations).
For the compiler, a little const on a temporary in the middle of a copy chain
that it's going to optimize away, doesn't matter: hey, it's optimized away,
anyway. It's not there, as far as the compiler's optimization circuits are
concerned. For the programmer doing similar optimization where the language
rules apply and must be followed at each step, the const is a showstopper.
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?