Why I can specialize a static method A<int>::func()
and a static nonconst variable A<int>::flag
, but cannot specialize a static const variable A<int>::const_flag
?
template <class T>
struct A {
static void func() {};
static bool iso_error = true; // ISO C++ forbids in-class initialization of non-const static member 'A<int>::iso_error'
static bool flag;
const static bool const_flag = true;
};
template <class T>
bool A<T>::flag = true; // works fine
template <>
void A<int>::func() {}; // works fine
template <>
bool A<int>::flag = false; // works fine
template <>
const bool A<int>::const_flag = false; // duplicate initialization of 'A<int>::const_flag'