Search code examples
c++standards

Scope resolution operator on enums a compiler-specific extension?


On this question, there's an answer that states:

You can use typedef to make Colour enumeration type accessible without specifying it's "full name".

typedef Sample::Colour Colour;
Colour c = Colour::BLUE;

That sounds correct to me, but someone down-voted it and left this comment:

Using the scope resolution operator :: on enums (as in "Colour::BLUE") is a compiler-specific extension, not standard C++

Is that true? I believe I've used that on both MSVC and GCC, though I'm not certain of it.


Solution

  • 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.