Код: Выделить всё
auto data = std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto output = [data](this auto self, size_t i) {
if (i >= 10) {
return;
}
std::print("{}, ", data[i]);
self(i + 1);
};
output(0);
Фрагмент Compiler Explorer
Подробнее здесь: https://stackoverflow.com/questions/797 ... -capturing
Мобильная версия