#include <iostream>
#include <list>
int main()
{
// initializing lists
std::list<int> source = {1, 2, 3, 4, 5, 6, 7, 8};
std::list<int> destination = {88, 99, 100};
// range: from 2nd to 5th element
auto start = std::next(source.begin(), 1); // points to element 2
auto end = std::next(source.begin(), 5); // points to element 6
// Transfer range to destination at the beginning
destination.splice(destination.begin(), source, start, end);
std::cout << "Source list: ";
for (int val : source) std::cout << val << " ";
std::cout << "\nDestination list: ";
for (int val : destination) std::cout << val << " ";
}
/*
run:
Source list: 1 6 7 8
Destination list: 2 3 4 5 88 99 100
*/