I have an enum in a namespace and I\'d like to use it as if it were in a different namespace. Intuitively, I figured I could use \'using\' or \'typedef\' to accomplish this,
Starting from C++11 you can use enum class. Importing enum class imports all its values:
namespace foo
{
enum class bar {
A
};
}
namespace buzz
{
using foo::bar;
}
int main()
{
foo::bar f;
foo::bar g = foo::bar::A;
buzz::bar x;
buzz::bar y = buzz::bar::A;
buzz::bar z = foo::bar::A;
}
The code above successfully compiles: http://coliru.stacked-crooked.com/a/2119348acb75d270.