Suppose I have this class:
template <typename T> class A {
T datum;
void foo();
}
I want to augment my class with the following typedef and method:
typedef enum {Red, Green, Blue} Color;
bar(Color color) { baz(datum,color); };
The thing is, I want Color to only be defined within the class, yet not be templated, i.e. I want to be able to do:
A<int> a;
a.bar(A::Red);
Now, I can't do this:
template <typename T> class A {
typedef enum {Red, Green, Blue} Color;
// ...
}
since it defines A<T>::Color
for different T's, not A::Color
. And this:
namespace A {
typedef enum {Red, Green, Blue} Color;
}
template <typename T> class A { /* ... */ }
doesn't seem to compile. Neither does this:
typedef enum {Red, Green, Blue} A::Color;
template <typename A> class A { /* ... */ }
So, can I get an A::Color
defined somehow?