I'm pretty sure you could make the Base class a template and the Key could be a template parameter. Does the Key class actually need to be defined inside the Base class?