forward_list<int> listOne;
forward_list<int> listTwo;
vector<int> arr = {2,4,3};
forward_list<int>::iterator it;
In the code mention above, I want to insert a std::vector
in listOne
and I tried using insert_after
function.
it = listOne.begin();
listOne.insert_after(it,arr);
But it didn't work.
I want to know that, is there a way to add a std::vector
or array in a std::forward_list
without any loop ?
You could use a std::copy
with std::front_inserter
copy(arr.rbegin(), arr.rend(), front_inserter(listOne));