PropertyType
Edwin van Leeuwen via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 17 07:50:32 PDT 2016
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;
```
More information about the Digitalmars-d
mailing list