On Tuesday, 17 May 2016 at 14:24:09 UTC, Steven Schveighoffer wrote:
I have this little helper in my iopipe library:

template PropertyType(alias x)
{
    static if(is(typeof(x) == function))
        alias PropertyType = typeof(x());
    else
        alias PropertyType = typeof(x);
}


FYI: In painlesstraits we use a different approach, where we test whether it is a function (with isSomeFunction) and then test for the property attribute:

https://github.com/msoucy/painlesstraits/blob/master/source/painlesstraits.d#L173
```
static if (isSomeFunction!(T))
        {
return (functionAttributes!(T) & FunctionAttribute.property);
        } else
            return false;
```

Reply via email to