I've been using an technique whereby a tag used as a parameter to a
template class C determines which of several potential base classes
(A,B) C inherits from. What I want to know is whether there is an
accepted name for this idiom.
To illustrate the point, here is some code which demonstrates it in
action...
// Selector classes - these are typically just empty structs
struct A_Tag { };
struct B_Tag { };
// Potential base classes
class A { /* ... */ };
class B { /* ... */ };
// Definition of the class which selects the appropriate base for C
template<class Tag> struct Selector { };
// Specialisations of the selector map tags onto base classes
template<> struct Selector<A_Tag> { typedef A base_t; };
template<> struct Selector<B_Tag> { typedef B base_t; };
// OK, here is the class which we actually instantiate
template<class Tag>
class C : public Selector<Tag>::base_t
{ /* ... */ };
// And now the instantiations...
C<A_Tag> c_inheriting_from_A;
C<B_Tag> c_inheriting_from_B;
Gareth