Let\'s say, I have six types, and they each belong in a conceptual category.
Here is a diagram that shows this:
As an alternative to category selection via "traits", you can also consider CRTP (where the type carries the category as a base):
template class category1 {};
template class category2 {};
class A1: public category1 { ..... };
class A2: public category2 { ..... };
class B1: public category1 { ..... };
class B2: public category2 { ..... };
templatevoid funcion_on1(category1& st)
{
T& t = static_cast(st);
.....
}
templatevoid funcion_on1(category2& st)
{
T& t = static_cast(st);
.....
}
The advantage is to have a less polluted namespace.