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};
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…