The template mechanism in C++ only accidentally became useful for template metaprogramming. On the other hand, D\'s was designed specifically to facilitate this. And apparently
in D you can check the size of a type and the available methods on it and decide which implementation you want to use
this is used for example in the core.atomic module
bool cas(T,V1,V2)( shared(T)* here, const V1 ifThis, const V2 writeThis ){
static if(T.sizeof == byte.sizeof){
//do 1 byte CaS
}else static if(T.sizeof == short.sizeof){
//do 2 byte CaS
}else static if( T.sizeof == int.sizeof ){
//do 4 byte CaS
}else static if( T.sizeof == long.sizeof ){
//do 8 byte CaS
}else static assert(false);
}