ref const(T) the same as C++'s const T&?

Trass3r un at known.com
Tue Mar 1 06:27:14 PST 2011


Peter Alexander Wrote:
> If they don't, how do I pass large structs into a function efficiently?

The weird thing is struct literals count as lvalues in D2, so this works:

struct A {}
void foo(ref A a) {}
void main()
{
    foo(A());
}

while calling the following doesn't:
static A bar()
{
    return A();
}

foo(bar());

Where's the freaking difference?


More information about the Digitalmars-d mailing list