I think scoped enumerations are too restrictive so I have always used this method, but I found out today that it cause naming pollution in CLANG. What does the standard say about visibility?
<code>namespace E1_space {
enum E1: int;
}
using E1 = E1_space::E1; // or using E1_space::E1;
enum E1_space::E1: int {
Error
};
void foo() {
Error;
// x86-64 GCC 14.2 error: 'Error' was not declared in this scope; did you mean 'P3::E1_space::Error'?
// x64 MSVC v19.latest error C2065: 'Error': undeclared identifier
// x86-64 CLANG 19.1.0 warning: expression result unused
}
</code>
<code>namespace E1_space {
enum E1: int;
}
using E1 = E1_space::E1; // or using E1_space::E1;
enum E1_space::E1: int {
Error
};
void foo() {
Error;
// x86-64 GCC 14.2 error: 'Error' was not declared in this scope; did you mean 'P3::E1_space::Error'?
// x64 MSVC v19.latest error C2065: 'Error': undeclared identifier
// x86-64 CLANG 19.1.0 warning: expression result unused
}
</code>
namespace E1_space {
enum E1: int;
}
using E1 = E1_space::E1; // or using E1_space::E1;
enum E1_space::E1: int {
Error
};
void foo() {
Error;
// x86-64 GCC 14.2 error: 'Error' was not declared in this scope; did you mean 'P3::E1_space::Error'?
// x64 MSVC v19.latest error C2065: 'Error': undeclared identifier
// x86-64 CLANG 19.1.0 warning: expression result unused
}
4