Limiting template functions to template instantiations of a struct

simendsjo simendsjo at gmail.com
Thu Nov 7 08:42:02 PST 2013


On Thursday, 7 November 2013 at 15:46:53 UTC, Marco Leise wrote:
> Am Wed, 06 Nov 2013 14:22:13 +0100
> schrieb "simendsjo" <simendsjo at gmail.com>:
>
>>      template isFoo(T) {
>>          static if(is(T:Foo!U, int U))
>>              enum isFoo = true;
>>          else
>>              enum isFoo = false;
>>      }
>
> enum isFoo(T) = is(T:Foo!U, int U);
>
> correct ?

I haven't tried 2.064 yet, but that should be correct. I'll be 
able to shave away a whole lot of "useless" lines because of 
this. And the strange thing is that I didn't even know about this 
enhancement before reading the changelog.


More information about the Digitalmars-d-learn mailing list