Код: Выделить всё
virtual void doSomethingWithInts(std::ranges::input_range auto intsView) = 0;
< /code>
Вот более подробный пример: < /p>
#include
#include
class IGetRange{
virtual void doSomethingWithInts(std::ranges::input_range auto intsView) = 0;
};
class PrintRange : public IGetRange{
void doSomethingWithInts(std::ranges::input_range auto intsView) {
std::ranges::copy(intsView, std::cout);
}
};
class SendOverNetworkRange : public IGetRange{
NetworkAdapter networkAdapter;
void doSomethingWithInts(std::ranges::input_range auto intsView) {
//do some extra work with additional input
std::ranges::copy(intsView, networkAdapter);
}
};
class Caller {
std::vectordoSomethingWithInts(passView);
}
};
Я не хочу Чтобы пройти новый вектор , потому что он распределяет больше места. И Span не является вариантом, потому что мне придется распределить его.
Я хочу иметь возможность передать только диапазон с данным типом.
Подробнее здесь: https://stackoverflow.com/questions/794 ... ge-of-ints
Мобильная версия