I have an enum definition inside a class in the header:
namespace A {
class B {
public:
enum Value {
VALUE1 = 1,
VALUE2 = 2,
};
};
}
And I want to use its values in the source file without a prefix, for example:
#include "header"
int main() {
someFn(VALUE1);
return 0;
}
I tried using A::B::Value;, but clang gives an error:
Using declaration cannot refer to class member
Even if I move enum outside the class:
namespace A {
enum Value {
VALUE1 = 1,
VALUE2 = 2,
};
}
and do using A::Value;, the error went away, but the compiler complains about VALUE1:
use of undeclared identifier "VALUE1"
Is there a way to use enum values without any prefixes if the enum is defined elsewhere? - Use is #defineout of the question.
If there is no way, then what is the possible problem with implementing this behavior in C ++ Standard?