What is the syntax to test for specific types in templates

Oskar Linde Oskar_member at pathlink.com
Tue Apr 11 23:01:52 PDT 2006


In article <138zdzputeyti$.16ay0g5ad0xj6$.dlg at 40tude.net>, Derek Parnell says...
>
>I want to ensure that the template can only be generated for certain data
>types:...
>I think it should be something like ...
>
>template foo(T)
>{
>   T foo(T x)
>   {
>      static if ( is(ulong T) || ...

static if (is(T == ulong)) 
or maybe better for your application:
is (T : int)
for all T implicitly convertible to int.

/Oskar





More information about the Digitalmars-d mailing list