Templates and generic programming
T.62
Place non-dependent class template members in a non-templated base class
Reason
Allow the base class members to be used without specifying template arguments and without template instantiation.
Example
template<typename T>
class Foo {
public:
enum { v1, v2 };
// ...
};
???
struct Foo_base {
enum { v1, v2 };
// ...
};
template<typename T>
class Foo : public Foo_base {
public:
// ...
};
Note
A more general version of this rule would be "If a class template member depends on only N template parameters out of M, place it in a base class with only N parameters." For N == 1, we have a choice of a base class of a class in the surrounding scope as in T.61.
??? What about constants? class statics?
Enforcement
- Flag ???