On Sunday, 15 December 2013 at 15:01:47 UTC, Tommi wrote:
I'd rather do this:
namespace CheckerBoardColorNamespace
{
enum CheckerBoardColor { Red, Black };
};
using CheckerBoardColorNamespace::CheckerBoardColor;
auto v = CheckerBoardColor::Red;
int main()
{
using namespace CheckerBoardColorNamespace;
auto v = Red;
}
...and you get to have a nice name for the enum type.
That's a C++11 extension. "CheckerBoardColor::Red" is not a legal
value. There are no scoped enums in C++98/03.
That said, nice trick for "using namespace
CheckerBoardColorNamespace;" It's a nice way to emulate "with".
Too bad this means the enum (AFAIK) can't be strongly C++11-stlye
typed.
BTH though, if I had C++11 in my workplace, I'd just class it and
move on.