Multiple types in one specialized D template -
say have deal ushort
, uint
way, string
differently. guess need 1 specialized template string
, other both ushort
, uint
. it?
// void func(t)(t var) { ... } // uint , ushort void func(t: uint, ushort)(t var) { ... }
that idea, although code can't compile. it's valid or bad?
try this:
void func(t)(t var) if ( is(t : uint) || is(t : ushort) ) { ... } void func(t : string)(t var) { ... }
you in 1 function:
void func(t)(t var) { static if ( is(t : uint) || is(t : ushort) ) { ... } else if ( is(t : string) ) { ... } else { // handle else } }
Comments
Post a Comment