title: Unique pointer and const correctness
body: <p>I was not expecting this code to compile:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  class A
  {
  public:
  
      inline int get() const
      {
          return m_i;
      }
  
      inline void set(const int &amp; i)
      {
          m_i = i;
      }
  
  private:
  
      int m_i;
  };
  
  int main()
  {
      const auto ptr = std::make_unique&lt; A &gt;();
  
      ptr-&gt;set( 666 ); // I do not like this line    D:&lt;
      std::cout &lt;&lt; ptr-&gt;get( ) &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>If <strong>ptr</strong> was a raw C pointer, I would be ok with that. But since I'm using a <strong>smart pointer</strong>, I can't understand what is the rationale behind this.</p>
  
  <p>I use the unique pointer to express <strong>ownership</strong>, in Object Oriented Programming this could be seen as an object composition ("part-of" relationship).</p>
  
  <p>For example:</p>
  
  <pre><code>class Car
  {
      /** Engine built through some creational OO Pattern, 
          therefore it has to be a pointer-accessed heap allocated object **/
      std::unique_ptr&lt; Engine &gt; m_engine;
  };
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>class A
  {
      class Impl;
  
      std::unique_ptr&lt; A::Impl &gt; m_impl; // PIMPL idiom
  };
  </code></pre>
  
  <p>If an instance of a class Car is <strong>constant</strong>, why the Engine should not be constant as well? If it was a shared pointer I would have been completely fine with that.</p>
  
  <p>Is there a smart pointer who can reflect the behaviour I want?</p>