I like to define my enum's that belong to a certain class inside that class. That makes it clear they belong together and helps against namespace pollution:
class Bar
{
public:
enum class Foo
{
something,
somethingElse
};
Bar(Foo foo);
//etc...
};
Purely out of curiosity I'd like to know if one can do the same for a enum class that is used as template parameter for the class it's defined in:
template <Bar::Foo foo>
class Bar
{
public:
enum class Foo
{
something,
somethingElse
};
};
Obviously this won't compile because Bar
has not been declared yet at the moment we try to use Bar::Foo
as a template parameter type. I'd like to see if someone can come up with some creative workaround.