Let's say I have a class Class, which has an associated enum member Enum. The enum only makes sense in the context of this class, and therefore it is specified inside it. Then you can just call Class::Enum::Something from outside of the class, which is fine.
class Class
{
public:
enum class Enum : uchar
{
Something
}
}
However, if the class Class is templated, you cannot do Class::Enum::Something, but you have to Class<T>::Enum::Something (or Class<>::Enum::Something if T has some default type).
template <typename T = double>
class Class
{
public:
enum class Enum : uchar
{
Something
}
}
The Enum has to be the same for all Ts, since it's just a simple enum, but the T always has to be specified anyway.
My question is - is there a clever way of avoiding this?
Class::Enum::Something. It's not a function.Enumis different in each template instantiation, despite having all the same names. If you want the sameEnumyou can't put it inside a template. One possibility would be to define it in a class and use that class as a base class for the template.