how do I tell if something is lvalue?

Artur Skawina via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 1 12:53:35 PST 2016


On 02/01/16 21:42, Artur Skawina wrote:
> On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote:
>> That looks much nicer. It still needs work to properly handle functions with non-empty argument lists.
> 
> Then it gets a bit long for a one-liner ;)
> 
>    enum isLvalue(A...) = is(typeof((ref _){}(A[0](A[1..$])))) || is(typeof((ref _){}(A[0])));

And it's of course wrong in case there is a zero-args ref-returning
overload present. So...

   enum isLvalue(A...) = A.length>1?is(typeof((ref _){}(A[0](A[1..$])))):is(typeof((ref _){}(A[0])));


artur


More information about the Digitalmars-d-learn mailing list