Both SGI slist and C++11 std::forward_list appear identical to me unless I have missed something; both implement a singly-linked list.
I assume there is a difference though as the C++ Standard Commitee didn’t adopt the name slist and instead chose a new name, forward_list, when they added the container into the Standard Library for C++0x.
One major difference is that
std::forward_listlacks asize()member function, where as thesgi::slistdoesn’t. The motivation for this is that an O(N)size()has been problematic. N2543 has more details on the design decisions forforward_list.Update:
I recently had a good excuse to look closer at this subject.
slistalso has other member functions that one would be tempted to think are O(1), but are really O(N). These include:In short, if you’re not very careful, you can end up with significant performance problems by using
slist. Use ofstd::forward_listinstead ensures that you’ll get the expected O(1) performance out of your singly linked list.