I am reading the SFML development book and have a question regarding the "An interacting world" chapter and the section which focuses on cleanup.
The removal is performed by the following method. In the first part, std::remove_if() rearranges the children container, so that all active nodes are at the beginning and the ones to remove at the end. The call to erase() actually destroys these SceneNode::Ptr objects ...
Why is remove_if() used to rearrange the children container, separating active nodes and ones to be removed? What benefit or security (if there is one) comes with reorganizing the container? This isn't exactly explained why this is done versus another method (i.e. why wouldn't we just mark and remove each object in its original position, rather than organizing the container? ), but seems very specific. Is the method used in the book a standard or is this the only possible solution to managing your objects with a container?