std::forward_list<T,Allocator>::erase_after
Min standard notice:
Removes specified elements from the container.
# Declarations
iterator erase_after( const_iterator pos );
(since C++11)
iterator erase_after( const_iterator first, const_iterator last );
(since C++11)
# Parameters
pos: iterator to the element preceding the element to removefirst, last: range of elements to remove
# Example
#include <forward_list>
#include <iostream>
#include <iterator>
int main()
{
std::forward_list<int> l = {1, 2, 3, 4, 5, 6, 7, 8, 9};
// l.erase(l.begin()); // Error: no function erase()
l.erase_after(l.before_begin()); // Removes first element
for (auto n : l)
std::cout << n << ' ';
std::cout << '\n';
auto fi = std::next(l.begin());
auto la = std::next(fi, 3);
l.erase_after(fi, la);
for (auto n : l)
std::cout << n << ' ';
std::cout << '\n';
}