I’d like to use std::forward_list
Because:
Forward list is a container which supports fast insertion and removal
of elements from anywhere from the container
But there’s no *std::forward_list::push_back* implementation.
Is there a high-performance way to add support for the one or no reason to do it?
std::forward_listsupports fast insertion and removal, but not traversal to the end. To implement.push_back, you’ll first need to get to the end of the list, which is O(N) and not fast at all, which is probably why it’s not implemented.You could find the iterator to the last element by incrementing
.before_beginN timesand then use
.insert_afteror.emplace_afterto insert the element: