title: best practice when returning smart pointers
body: <p>What is the best practice when returning a smart pointer, for example a boost::shared_ptr? Should I by standard return the smart pointer, or the underlying raw pointer? I come from C# so I tend to always return smart pointers, because it feels right. Like this (skipping const-correctness for shorter code): </p>
  
  <pre><code>class X
  {
  public:
      boost::shared_ptr&lt;Y&gt; getInternal() {return m_internal;}
  
  private:
      boost::shared_ptr&lt;Y&gt; m_internal;
  }
  </code></pre>
  
  <p>However I've seen some experienced coders returning the raw pointer, and putting the raw pointers in vectors. What is the right way to do it?</p>