Question was changed!
I use a simple way to hide my enums from local namespaces - enumeration inside of a struct. It goes roughly like this:
struct Color
{
enum Type
{
Red, Green, Black
};
Type t_;
Color(Type t) : t_(t) {}
operator Type () const {return t_;}
private:
template<typename T>
operator T () const;
};
operator T () is a protection from implicit type casting. Then I tried to compile this code with gcc and with keil:
Color n;
int a[9];
a[ (int)n ] = 1;
gcc compiled it with no error (wich is what I expected), but Keil gived me an error: "invalid type conversion. operator () is inaccessible".
So my question is: which compiler is right?
I know about c++11 enum class, but it isn't supported by Keil now