I am having a problem with iterators for a forward_list. I am trying to erase a portion of a forward_list using erase_after which takes iterators as its arguments. I am trying to delete from the beginning of the forward_list to a specified index. I tried using pointer arithmetic, but it does not work.
However, the problem that you show does not seem to need either.
You create 'list' that contains N elements.
You swap N elements from start of 'list' to start of 'source'.
Now first N elements of 'source' are nonsense.
You proceed to remove those N elements from 'source'.
Tbh, I've never used forward_list and hence splice_after. A split felt natural operation for a linked list and browsing the documentation pointed to splice_after, whose description I had to read very carefully to figure out who is from and who is to.