Fallback 'catch-all' template functions

Andrea Fontana via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 1 05:31:04 PDT 2016


On Thursday, 1 September 2016 at 08:46:07 UTC, Stefan Koch wrote:
> On Thursday, 1 September 2016 at 08:44:38 UTC, Stefan Koch 
> wrote:
>> void f(T)(T t) {
>>   static if (is(fImpl(t) == void)) {
>>     f(t);
>>   } else {
>>     // default impl here
>>   }
>> }
>
> Was meant to be
>  void f(T)(T t) {
>    static if (is(fImpl(t) == void)) {
>      fImpl(t);
>    } else {
>      // default impl here
>    }
>  }

why not:

static if (__traits(compiles, fImpl(t))) ?

Andrea


More information about the Digitalmars-d mailing list