Since forward_list has been accepted into the standard, it might be a
good idea to create a version of insert_iterator that works with it.
Forward_list is basically a C-style singly-linked list, and for
technical reasons it is defined so that insertions, deletions, etc. are
performed after an input iterator, instead of in front of it. Thus,
while list has an insert() member function taking an iterator and a
value, forward_list has an insert_after function.
One result of this is that forward_list cannot work with standard
insert_iterators, which assume the presence of an insert() member
function. This makes it much harder to use a forward_list as the target
of an STL algorithm. For instance, if vec is a vector<int>, list1 is an
empty list<int>, and list1 is a list<int> we can write code like
transform(vec.begin(), vec.end(), inserter(list1, list1.end()), Foo);
There's no equivalent way of doing the same thing to write to a
forward_list. (While we could use a front_inserter, the elements would
be added in reverse order, which could be a problem in many cases.) I
think it would be useful to define a class insert_after_iterator() and
an associated free function inserter_after() to handle this case for
forward_lists.
Joe Gottman
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|