Рассмотрим следующий фрагмент кода C++20:
Код: Выделить всё
#include
#include
#include
#include
#include
namespace rn = std::ranges;
int main() {
std::string input = "1 2 3 4 5 6 7 8 9 10";
std::istringstream input_stream(input);
std::vector head;
rn::copy(rn::istream_view(input_stream) | rn::views::take(5),
std::back_inserter(head));
int next_int = 0;
input_stream >> next_int;
for(auto x : head) std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78663215/why-does-taken-used-on-an-istream-view-cause-it-to-skip-the-next-token-in-c2[/url]