Похожие чаты

Array<Char, 5> d = {"sdfd"}; compiled vector<array<char, 5>> s1{{"asdf"}}; not compiled

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?

6 ответов

25 просмотров

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

Alex Surname
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

Alex-Surname Автор вопроса

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'};

Похожие вопросы

Обсуждают сегодня

Карта сайта