Partial specialisation: howto? (in the right news group this time. *sigh*)
Simen Kjaeraas
simen.kjaras at gmail.com
Sat May 16 17:47:38 PDT 2009
div0 wrote:
It seems I might know how to do this after all.
As is mentioned under template constraints[1], templates can be specialized by trailing the parameter list with a condition:
template createHandlerCode( T... ) if ( T[0]._type == EHandlerType.eMsgRangeHdlr ) {
string format( ) {
return createMessageRangeHandler!( T ).format();
}
}
template createHandlerCode( T... ) if ( T[0]._type == EHandlerType.eMsgHdlr ) {
string format( ) {
return createMessageHandler!( T ).format();
}
}
template createHandlerCode( T... ) if ( T[0]._type == EHandlerType.eCmdIdHdlr ) {
string format( ) {
return createCommandIdHandler!( T ).format();
}
}
This code is D2-only and untested, so there is certainly a possibility it will not work for you.
[1]: http://www.digitalmars.com/d/2.0/template.html#Constraint
--
Simen
More information about the Digitalmars-d-learn
mailing list