how do I tell if something is lvalue?

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 1 11:47:54 PST 2016


On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote:
> On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn 
> wrote:
>> Thanks! I was surprised this is not straightforward.
>
>    enum isLvalue(alias A) = is(typeof((ref _){}(A)));
>
> artur

That looks much nicer. It still needs work to properly handle 
functions with non-empty argument lists. Also, can alias 
parameters take runtime variables? I can't remember.

struct S
{
     int w(int n) { return 1; }
}

static assert(isLvalue!(S.w));


More information about the Digitalmars-d-learn mailing list