Would it be possible (and useful) to introduce declarations like `auto foo() if(isInputRange(auto));`

Roman D. Boiko rb at d-coding.com
Thu May 17 04:51:11 PDT 2012


On Thursday, 17 May 2012 at 11:49:18 UTC, Roman D. Boiko wrote:
> Is there anything preventing us from adding constraints on the 
> auto function return value? I mean, such language extension 
> seems to be quite useful.
>
> For example, it would be no longer necessary to provide method 
> bodies for functions with auto return values.
>
> In many cases this would eliminate the need for introducing an 
> interface.

interface returnsDuckTyped
{
     auto foo() if(isInputRange!auto);
}

(fixed typo)


More information about the Digitalmars-d mailing list