title: std::vector of multiple wrappers containing std::function callbacks does not work
body: <p>I am coding a wrapper <code>MyTest</code> that is containing a std::function&lt;> used for storing callback. 
  The wrappers are contained in a std::vector <code>tests</code> of shared_ptr&lt;>. 
  emplace_back a single wrapper in the vector works, i.e. the std::function callback can be fired. If I have two objects in the vector, only the last object callback works. </p>
  
  <p>Here are my classes:</p>
  
  <pre><code>typedef function&lt;void(const uint64_t &amp;)&gt; CallBackFunc_t;
  
  class MyWheel
  {
  private:
      class test
      {
      private:
          const CallBackFunc_t &amp;callback;
      public:
          test(const CallBackFunc_t &amp;cb);
          bool work();
      };
  
  public:
      vector&lt;shared_ptr&lt;test&gt;&gt; tests;
      int addTest(const CallBackFunc_t &amp;test_callback);
      void spin(void);
  
  };
  
  
  class MyTest
  {
  private:
      int handle = -1;
      MyWheel &amp;wheel;
  public:
      MyTest(MyWheel &amp;whl);
      int setCallback(const CallBackFunc_t &amp;callback);
  };
  </code></pre>
  
  <p>And the source.</p>
  
  <pre><code>MyWheel::test::test(const CallBackFunc_t &amp;cb) : callback(cb)
  {
  
  }
  
  bool MyWheel::test::work()
  {
      callback(0);
      return true;
  }
  
  int MyWheel::addTest(const CallBackFunc_t &amp;test_callback)
  {
      tests.emplace_back(new test(test_callback));
      return (int)(test.size()-1);
  }
  
  void MyWheel::spin(void)
  {
      for(vector&lt;shared_ptr&lt;test&gt;&gt;::iterator test = tests.begin(); test != tests.end(); ++test)
      {
         (*test)-&gt;work();
      }
  }
  
  MyTest::MyTest(MyWheel &amp;whl) : wheel(whl)
  {
  
  };
  
  int MyTest::setCallback(const CallBackFunc_t &amp;callback)
  {
      if(handle &lt; 0)
      {
          handle = wheel.addTest(callback);
      }
      return handle;
  }
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>
  MyWheel wh;
  MyTest t1(wh);
  MyTest t2(wh);
  
  t1.setCallback([&amp;](const uint64_t &amp;e) {
     cout &lt;&lt;"1\r\n";
  });
  
  t2.setCallback([&amp;](const uint64_t &amp;e) {
     cout &lt;&lt;"2\r\n";
  });
  
  while(true)
  {
     wh.spin();
  }
  
  </code></pre>
  
  <p>I expect "1" and "2" to be printed when running, but only "2" is...
  What am I doing wrong?</p>