Call site 'ref'
Peter Alexander
peter.alexander.au at gmail.com
Sun Jan 15 16:30:45 PST 2012
On 15/01/12 11:56 PM, Jonathan M Davis wrote:
> On Monday, January 16, 2012 00:41:14 Timon Gehr wrote:
>> Well, struct literals are lvalues, at least in DMD.
>
> Yeah. I don't understand that. I've argued about it with Walter before.
> Apparently they are in C++ as well. I don't understand it. It makes it so that
In C++, struct literals are rvalues. C++ just has a special rule that
const references can bind to rvalues (but non-const references cannot),
and another special rule that when a const reference binds to a
temporary it extends the life of the temporary.
The benefit in C++ is so that you can write one function that takes a
const reference and it works with rvalues as well as lvalues. Taking by
value would be too expensive a lot of the time.
More information about the Digitalmars-d
mailing list