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

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -