template specialization

Robert Clipsham robert at octarineparrot.com
Tue Jun 8 15:01:54 PDT 2010


On 08/06/10 22:25, Larry Luther wrote:
> Q: Is this the way it's supposed to be?

Yes, byte implicitly casts to ubyte so it's accepted. Try switching the 
templates round, they will both be byte. The way around this is to add 
template constraints to the templates:

void get(T:ubyte)(T[] buffer) if( is( T == ubyte ) ) { }
void get(T:byte)(T[] buffer) if( is( T == byte ) ) { }

etc.

Hope this helps,

Robert


More information about the Digitalmars-d-learn mailing list