I can create constexpr std::array:
constexpr std::array<int,5> values {1,2,3,4,5};
It works fine. But I cannot create constexpr vector:
constexpr std::vector<int> vec = {1,2,3,4,5};
It gives me an error:
the type 'const std::vector<int>' of constexpr variable 'vec' is not literal constexpr std::vector<int> vec = {1,2,3,4,5};
vectorconstructor is not declaredconstexpr. Why is it not so declared? Becausevectorconstructor generally needs to allocate memory on the heap, which of course can only be done at run time.vectoris its ability to resize dynamically. If you don't need that, just usestd::arrayor plain array.Qtand there are nothing likestd::arraycontainer, so I tried to useQVectorandQListand it does not work. I don't want to mixQtandstlcontainers. So, I guess now I have to