Replacing an std :: list object with an iterator

Given the iterator in std :: list, how do you replace the object at the position that the iterator refers to? Currently, all I can think of is invoking an insert with a new object and an iterator (to insert a new object before the element that the iterator refers to), and then erasing it to remove the object to be replaced. Is there a less roundabout way to do a replacement?

+6
source share
1 answer

What happened with:

(*it) = obj; 

where obj is the replacement value?

+22
source

Source: https://habr.com/ru/post/893640/


All Articles