How should we decide which one to used?
Decide if you need bidirectional iteration. If forward iteration is good enough, use std::forward_list
, unless you need to support C++ versions older than C++11, which may only have std::list
.
Is there any performance benefit of any of the list above other?
std::forward_list
eliminates a pointer per node (with all the attendant benefits for the data cache and memory subsystem), while std::list
provides constant-time iterator decrement.
But in practice, neither of these containers is as widely used as one might believe when attending computer science school. The real performance of std::vector
is superior for many applications, and its memory usage is always less. More demanding applications requiring lists would do well to consider intrusive lists, which standard C++ does not provide.