Why do we need a list argument in the splice func cpp? Why only iterators aren't sufficient?
Result is the same if I pass l1 or l2 as a second argument
l1.splice(st, l1, it, it2); or l1.splice(st, l2, it, it2);
prints 1 4 5 2 3
#include <bits/stdc++.h>
using namespace std;
int main()
{
// initializing lists and iterator
list<int> l1 = { 1, 2, 3 };
list<int> l2 = { 4, 5 };
auto it = l2.begin();
auto it2 = l2.end();
auto st = l1.begin();
std::advance(st,1);
// result the same if in splice l1 or l2
// 1 4 5 2 3
l1.splice(st, l2, it, it2);
cout << "list l1 after splice operation" << endl;
for (auto x : l1)
cout << x << " ";
return 0;
}