Scope resolution operator on enums a compiler-specific extension?

I tried the following code:

enum test
{
    t1, t2, t3
};

void main() 
{
    test t = test::t1;
}

Visual C++ 9 compiled it with the following warning:

warning C4482: nonstandard extension used: enum 'test' used in qualified name

Doesn't look like it's standard.


That is not standard.

In C++11, you will be able to make scoped enums with an enum class declaration.

With pre-C++11 compilers, to scope an enum, you will need to define the enum inside a struct or namespace.


In standard c++, things to the left of "::" must be a class or namespace, enums don't count.

Tags:

C++

Standards