dimanche 4 octobre 2015

Abbreviated syntax for a C++11 enum class nested in a class?

I use a C++11 library which has a header with an enum class nested in a class:

class ClassWithARatherLongName
{
public:
    enum class EnumWithARatherLongName
    {
        VALUE1,
        VALUE2,
        VALUE3
    };
    (other code)
};

Then I use the enumerators in my code:

void foo()
{
    ... ClassWithARatherLongName::EnumWithARatherLongName::VALUE1 ...
}

This works, but is tedious. Isn't there a way to abbreviate the syntax?

Ideally, I would like to be able to write something like:

void foo()
{
    (some directive that allows to use an abbreviated syntax)
    ... VALUE1 ...
}

Aucun commentaire:

Enregistrer un commentaire