void test(const std::size_t& x) {
std::array<std::string, x> arr;
}
When I compile the above code I get this error.
main.cpp: In function ‘void test(std::size_t&)’: main.cpp:15:24: error: ‘x’ is not a constant expression
How can I get the above code to compile?
std::arrayinstead ofstd::vectorif the size is not a compile-time constant? That is pretty much the difference in use case between the two.