Templates and generic programming
T.2
Use templates to express algorithms that apply to many argument types
Reason
Generality. Minimizing the amount of source code. Interoperability. Reuse.
Example
That's the foundation of the STL. A single find algorithm easily works with any kind of input range:
template<typename Iter, typename Val>
// requires Input_iterator<Iter>
// && Equality_comparable<Value_type<Iter>, Val>
Iter find(Iter b, Iter e, Val v)
{
// ...
}
Note
Don't use a template unless you have a realistic need for more than one template argument type. Don't overabstract.
Enforcement
??? tough, probably needs a human