PropertyType

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue May 17 08:05:25 PDT 2016


On 5/17/16 10:50 AM, Edwin van Leeuwen wrote:
> 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;
> ```
>

My code is less concerned as to whether it is a property or not. I just 
want to know the type of the expression :)

-Steve


More information about the Digitalmars-d mailing list