I'm trying to initialize the member vec
within the class scope, but the compiler throws a more cryptic error.
class A {
public:
static const size_t sz = 10;
static const std::vector<double> vec{ sz }; // error
};
The compiler (gcc) gives the following error(s):
error: in-class initialization of static data member 'std::vector<double> A::vec' of non-literal type
10 | static std::vector<double> vec{ sz };
| ^~~
error: non-constant in-class initialization invalid for non-inline static member 'A::vec'
10 | static std::vector<double> vec{ sz };
| ^
note: (an out of class initialization is required)
How I can fix this?