consider a class with a constant member:
class foo {
public:
const static int N;
};
foo::N
needs to initialized:
constexpr int foo::N = 5;
and note how using the constexpr
qualifier instead of const
here seems like a mistake.
but GCC, Clang and MSVC all compile just fine!
- is there something in the language that allows changing qualifiers here?
- is it an error overlooked by all three compilers?
Clang even allows both qualifier versions simultaneously:
constexpr int foo::N = 3;
const int foo::N = 5;
int main(){
return foo::N; //returns 3
}
what's going on?