title: Difference between `const shared_ptr<T>` and `shared_ptr<const T>`?
body: <p>I'm writing an accessor method for a shared pointer in C++ that goes something like this:</p>
  
  <pre><code>class Foo {
  public:
      return_type getBar() const {
          return m_bar;
      }
  
  private:
      boost::shared_ptr&lt;Bar&gt; m_bar;
  }
  </code></pre>
  
  <p>So to support the const-ness of <code>getBar()</code> the return type should be a <code>boost::shared_ptr</code> that prevents modification of the <code>Bar</code> it points to. My <em>guess</em> is that <code>shared_ptr&lt;const Bar&gt;</code> is the type I want to return to do that, whereas <code>const shared_ptr&lt;Bar&gt;</code> would prevent reassignment of the pointer itself to point to a different <code>Bar</code> but allow modification of the <code>Bar</code> that it points to...  However, I'm not sure. I'd appreciate it if someone who knows for sure could either confirm this, or correct me if I got it wrong. Thanks!</p>