I want to replace one element in a list<stringby a list<stringand
I need to obtain an iterator to the first element in the inserted
list.
In code:
void replace_element _by_list(list<s tring&my_list,
list<string>::i terator
&iter_to_remove ,
const list<string>
&list_to_insert ) {
list<string>::i terator next_iter = my_list.erase(i ter_to_remove);
my_list.insert( next_iter, list_to_insert. begin(),
list_to_insert. end());
// Does 'iter_to_remove ' point to the first element of the inserted
list, or is it invalid?
}
When I try this code I find that 'iter_to_remove ' indeed points to the
first element of the inserted list. However, I'm wondering whether
that is guaranteed.
I need to obtain an iterator to the first element in the inserted
list.
In code:
void replace_element _by_list(list<s tring&my_list,
list<string>::i terator
&iter_to_remove ,
const list<string>
&list_to_insert ) {
list<string>::i terator next_iter = my_list.erase(i ter_to_remove);
my_list.insert( next_iter, list_to_insert. begin(),
list_to_insert. end());
// Does 'iter_to_remove ' point to the first element of the inserted
list, or is it invalid?
}
When I try this code I find that 'iter_to_remove ' indeed points to the
first element of the inserted list. However, I'm wondering whether
that is guaranteed.
Comment