On 2009-04-19 15:52:02 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> said:
Now onto why ref was disallowed to bind to an rvalue. This is because
some functions take things by ref intending to change them.
True.
Passing an rvalue is in such cases a bug.
I disagree. Function modify the temporary value, then the value is
forgotten. It's just like calling a function and ignoring the returned
value. It could be a bug, but it may not.
For instance, a function may just be performing some destructive
operation on the argument, in which case a temporary rvalue may
very-well be appropriate since you are unlikely to need the result
afterwards.
Even C++0x saw the need and added rvalue non-const reference.
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1690.html>
--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/