error: no matching function for call to ‘std::vector<std::array<char, 5ul> >::vector(<brace-enclosed initializer list>)’
vector<array<char, 5>> s1{{"asdf"}};
how to fix?
how to fix?
constexpr char tmp[5] = "sdfd"; array<char, 5> d = tmp; This will definitely work, your issue is that string literals forms are not exactly arrays but array expects something to default initialize from and literals are not one of the accepted types
thank you. but I need std::array
That is what you get, I encourage you to read both of the 2 lines of code I sent
I found issue. it compiles only from gcc 11.1(std=c++11 is used everywhere) for older compiler vector<array<char, 5>> s1{array<char,5>{"asdf"}}; works
it's a char std::array, you will have to do it the hard way, array<char, 5> = {'s', 'd', 'f', 'd', '\0'};
Обсуждают сегодня