Splitting range into sub-ranges
问题 I have a container std::vector and I would like to efficiently split it into sub-ranges with x items in each. The original container is not needed so the items should be moved and not copied into the sub-ranges. I've managed to do the splitting using copying, however I'm unsure how to do it with move assignments? range.insert(range.end(), new_items.begin(), new_items.end()); while(range.size() >= x) { sub_ranges.push_back(std::vector<int>(range.begin(), range.begin() + x)); range = std: