Код: Выделить всё
std::vector foo = some_generator_function();
std::span bar {foo};
/* Wrapper for C API that uses bar->data() and bar->size_bytes()
* if bar != nullptr, guaranteed not to change any data in bar.
* In some cases bar is constructed from a const C array.
*/
do_smth (&bar);
Теперь я пытаюсь обернуть его в отдельную функцию :
Код: Выделить всё
void do_wrap (const std::vector& foo) {
std::span bar (foo);
do_smth (&bar);
}
Есть ли для этого какая-то причина? На данный момент я подозреваю, что квалификатор const.
Построение как bar (foo.data(), foo.size()) приводит к аналогичной ошибке.
Компиляция с помощью g++ 14.2.0, MinGW64.
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/793 ... stdvectort
Мобильная версия