Похожие чаты

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 ответов

13 просмотров

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

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

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

Hey guys, did you see the new announcement about $Fun? 🔥
Filip Murphy
55
А чем вам питонисты не угодили?😂
.
79
Привет, запускаю werf в dind в k8s, получаю ошибку на этапе build/beforeSetup: /.werf/stapel/embedded/bin/bash: /.werf/scripts/5898bdfe5214357d3706b879cc8d3d78460fb379607cbd...
florius0
4
пацаны, как-нибудь можно панель задач заблюрить, что она была похожа на kde или винду 7, 11?
В
16
Dim Dim, [02.07.2024 11:07] DB 0x62 Dim Dim, [02.07.2024 11:07] DB 0x66 Dim Dim, [02.07.2024 11:07] кто пояснит что это?
Dim Dim
14
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
So total 101m burned Today?
Simu
18
Язык Си можно выучить за день? По книжке ANSI C на 230 страниц
Vincent Vegan
29
I have ocean on kucoin and binance what should I do for the migration??
Kobayashitcoin
10
Ребята, я не смешарик еще, новенький в разработке. Вот делаю по тутору игру, и не могу понять, почему у меня выходит корабль за пределы экрана. Сможет кто-нибудь подсказать по...
deshollow
7
Карта сайта