"instanceOf" trait for conditional implementations

so so at so.so
Thu Oct 4 05:43:00 PDT 2012


On Thursday, 4 October 2012 at 09:43:08 UTC, monarch_dodra wrote:

> The current implementation for "isAssignable" is
> //----
> template isAssignable(Lhs, Rhs)
> {
>     enum bool isAssignable = is(typeof({
>         Lhs l = void;
>         void f(Rhs r) { l = r; }
>         return l;
>     }));
> }

OT - Is there any reason for disabling UFCS for this?

template isAssignable(Lhs, Rhs)
{
     enum bool isAssignable =
     {
         Lhs l = void;
         void f(Rhs r) { l = r; }
         return l;
     }.typeof.is;
}


More information about the Digitalmars-d mailing list