Multiple Template Specialization Types (in D1)?

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Jul 1 14:26:51 PDT 2008


"Nick Sabalausky" <a at a.a> wrote in message 
news:g4e7bg$20n8$1 at digitalmars.com...
> Is there a way to do something like this in D1 without resorting to 
> function overloading?:
>
> void Foo(T : char, wchar, dchar)(T arg) {/*code*/}

It's not perfect, but:

void Foo(T)(T arg)
{
    static assert(is(T == char) || is(T == wchar) || is(T == dchar), "T must 
be char, wchar, or dchar");
}

D2 would let you put that in a template condition, but D1's stuck with a 
static assert. 




More information about the Digitalmars-d-learn mailing list