title: Passing unique_ptr as reference parameter or const unique_ptr reference
body: <p>I have some pool of objects that I maintain in a <code>std::vector&lt;std::unique_ptr&lt;MyObject&gt;&gt;</code> and I pass objects from this pool to a function <code>void process(...)</code>. I'm not clear on the best way to pass one of these objects to the <code>process()</code> function. If I'm understanding the different answers and articles I've read it's best to pass this as a regular reference as follows:
  <code>void process(MyObject&amp; buffer);</code></p>
  
  <p>From my understanding this is preferable because:</p>
  
  <ol>
  <li>The buffer I'm passing in should be guaranteed to remain in existence throughout the lifetime of the <code>process()</code> method by virtue of the fact that it's called by the owner of the unique_ptr, i.e. the calling method</li>
  <li>the caller can pass stack allocated objects as well so this doesn't impose allocation restrictions on clients of this method</li>
  <li>If the ptrs can be nullptr then it's advisable to pass a raw pointer to the <code>process()</code> method instead</li>
  </ol>
  
  <p>Is this understanding or correct or what is the best guidance? Here are the references I've read:
  <a href="https://stackoverflow.com/questions/48811917/passing-const-unique-ptr-reference-as-parameter">Passing const unique_ptr reference as parameter</a></p>
  
  <p><a href="https://www.chromium.org/developers/smart-pointer-guidelines" rel="nofollow noreferrer">https://www.chromium.org/developers/smart-pointer-guidelines</a></p>
  
  <p><a href="https://herbsutter.com/2013/06/05/gotw-91-solution-smart-pointer-parameters/" rel="nofollow noreferrer">https://herbsutter.com/2013/06/05/gotw-91-solution-smart-pointer-parameters/</a></p>