Why do struct literals count as lvalues?

kennytm kennytm at gmail.com
Thu Aug 18 12:49:31 PDT 2011


Trass3r <un at known.com> wrote:
> struct A {}
> static A bar()
> {
>     return A();
> }
> void foo(ref A a) {}
> void main()
> {
>     foo(A());   // works
>     foo(bar()); // doesn't
> }
> 
> Where's the difference?

The difference -- you've answered yourself in the title ;).

Reason why struct literals are lvalues -- because Walter and others believe
this is valid. Check the discussion in bugzilla issues 5178 and 5889. 

BTW, C99's compound literals also give lvalues.


More information about the Digitalmars-d mailing list