Let\'s say, I have six types, and they each belong in a conceptual category.
Here is a diagram that shows this:
Two functions signatures are not allowed to differ only by the default value of a template parameter. What would happen if you explicitly called function< int, void >
?
Usual usage of enable_if
is as the function return type.
//Handle all types from Category 1
template
typename std::enable_if::value>::type
function(T t){
//do category 1 stuff to the type
return;
}
//Handle all types from Category 2
template
typename std::enable_if::value>::type
function(T t){
//do category 2 stuff to the type
return;
}