Const ref and rvalues again...
martin
kinke at libero.it
Mon Oct 22 04:59:25 PDT 2012
On Monday, 22 October 2012 at 09:41:38 UTC, Timon Gehr wrote:
> (But it might be added that C++11 adds a new language feature
> just in order to be able to distinguish const and rvalue
> references in the callee, so even with C++'s semantics, this
> does not seem like a good idea.)
Yeah, and that T&& syntax is mainly used for _mutable_ rvalue
references in move constructors and assignment operators to move
(hijack) mutable data from the rvalue to another T instance
instead of copying that data, knowing that the rvalue's data is
not going to be accessed anymore anyway. So this is a different
case and does currently not apply to D afaik since there is no
way to forward rvalues:
void foo(ref T lvalue) { }
void foo(T rvalue) { }
In the latter overload for rvalues, you aren't given the original
rvalue, but a copy of it!
Distinguishing between _const_ rvalue and lvalue references
though makes no sense imho, and that is my whole point.
More information about the Digitalmars-d
mailing list