title: keeping shared_ptr use_count() at 1
body: <p>I was unable to find a similar question to this one, please direct me to one if I missed it!
  I am experimenting with smart pointers, and came to this scenario where I would like to keep the value returned by <code>use_count()</code>  in a shared_ptr object to 1 (to practice optimizing code).  Here is a snippet I am working with:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  #include &lt;vector&gt;
  
  // testFunc: displays the use_count of each shared ptr in the list
  void testFunc(const std::vector&lt;std::shared_ptr&lt;int&gt;&gt; &amp;list) {
      // reference each shared ptr in the list and display their use_count
      for (auto &amp;elem : list) {
          std::cout &lt;&lt; elem.use_count() &lt;&lt; std::endl;
      }   
  } // testFunc()
  
  int main() {
      // allocate shared ptr instance of an int
      auto sharedTest = std::make_shared&lt;int&gt;(11);
  
      // allocate another shared ptr instance of another int
      auto anotherSharedTest = std::make_shared&lt;int&gt;(22);
  
      // use std::move to prevent another copy of the shared ptrs from being created
      testFunc({ std::move(sharedTest), std::move(anotherSharedTest) }); 
  
      return 0;
  } // main()
  </code></pre>
  <p>The output by this program is</p>
  <pre><code>2
  2
  </code></pre>
  <p>since the use_count of both shared ptrs is 2.  Can anyone show me why I cannot keep them at 1?  I suspect that &quot;passing&quot; the vector to <code>testFunc</code> is creating a copy of each shared ptr when the entire vector is being passed, however this surprises me since I am passing the vector by reference.  Any input is greatly appreciated!</p>