The problem is that each different template instantiation is a different type with its own static variable that is not shared with other instances that have different template parameters. You could provide a non-template base class that contains the static variable.