return type and templates

Timon Gehr timon.gehr at gmx.ch
Fri Nov 22 06:24:20 PST 2013


On 11/22/2013 02:43 PM, Jonathan M Davis wrote:
> On Friday, November 22, 2013 14:29:46 Timon Gehr wrote:
>> >The request would be reasonable if 'value' was declared as follows though:
>> >
>> >@property T value(T)() if (is(T == int)) { return _intValue; }
>> >
>> >i.e. the fact that the template argument equals the type of the
>> >resulting call can be read off directly from the signature. This is in
>> >the same ballpark as the existing IFTI features.
> How so? IFTI works by inferring the template arguments from the function
> arguments. In this case, for the compiler to figure out a type that it could
> use to instantiate the template, it would have to disect the template
> constraint, which is compeletly different. Yes, this particular template
> constraint  ...

I am not talking about the template constraint at all. The following 
would still be a signature that would work:

@property T value(T)(){ return _intValue; }




More information about the Digitalmars-d-learn mailing list