How to write a 'using' statement for enum classes?

Victor Odouard picture Victor Odouard · Jun 7, 2013 · Viewed 7k times · Source

In a rock, paper, scissors program that I am writing, I am enumerating the three different moves and declaring them as a class. However, when I try to write a using statement so that I have to avoid using the scope operator, it doesn't seem to work. Anyone know why?

enum class choice {rock, paper, scissors};

using namespace choice;

Here an error message comes up, saying: [Error] 'choice' is not a namespace name. Why is this? I thought that for choice could be a namespace, in this context.

Answer

Baptistou picture Baptistou · Nov 20, 2019

It will be possible in C++20, P1099R5 :

enum class choice {rock, paper, scissors};

using enum choice;