title: C++ object needs to update its vector and map of shared pointers to other objects
body: <p>I have <code>FooManager</code> class with a public member <code>std::map&lt;size_t, std::shared_ptr&lt;Foo&gt;&gt; fmap;</code> for keeping track of <code>Foo</code> instances. There is an additional <code>farray</code> public member of <code>FooManager</code> which is a <code>std::vector&lt;std::shared_ptr&lt;Foo&gt;&gt;</code>. The <code>Foo</code> instances are added as,</p>
  
  <pre><code>FooManager fooman;
  int total_foos = 100;
  for (int i = 0; i &lt; total_foos; ++i) {
      auto ff = std::make_shared&lt;Foo&gt;(foo_data, i);  // calls Foo constructor
      fooman.farray[i] = ff;
      fooman.fmap.emplace(ff-&gt;GetID(), ff);  // note that ff.id != index i
  }
  </code></pre>
  
  <p>Each <code>Foo</code> instance runs a <a href="https://www.boost.org/doc/libs/1_67_0/doc/html/thread.html" rel="nofollow noreferrer"><code>boost::thread</code></a> process, and I'm using <code>FooManager</code> to keep track -- initially I found this approach more straightforward than a <a href="https://www.boost.org/doc/libs/1_67_0/doc/html/thread/thread_management.html#thread.thread_management.threadgroup" rel="nofollow noreferrer"><code>boost::thread::group</code></a>, but I could be mistaken.</p>
  
  <p>At a barrier, where each <code>Foo</code> instance is waiting for <code>fooman</code> to do a computation that decides which <code>Foo</code> instances continue and which don't, I have a result <code>foo_continues</code> (a <code>std::vector&lt;int&gt;</code>) that corresponds to the indices of <code>fooman.farray</code>. If, for example, <code>foo_continues[3]=2</code> and <code>foo_continues[7]=0</code>, I need the <code>Foo</code> instance corresponding to index 7 to be deleted, and that of index 3 to continue <em>with two entries</em> being track in <code>fooman</code>. Importantly, I need the containers <code>fooman.farray</code> and <code>fooman.fmap</code> to update accordingly. How can this be done in a <code>FooManager::CommputeContinues</code> method?</p>
  
  <p>And if you have an alternative approach than to keeping both <code>fooman.farray</code> and <code>fooman.fmap</code>, I'm open to suggestions. Thanks in advance for the help!</p>