title: Naked pointer to unique_ptr
body: <p>I have a structure with a vector and I need to store a pointer to one of its items. With naked  pointers, I'd do like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;memory&gt;
  #include &lt;unistd.h&gt;
  
  struct A {
      A () {
          v = {1, 2, 3, 4};
          uv = &amp;v.front();
      }
  
      std::vector&lt;int&gt; v;
      int* uv;
  };
  
  int main()
  {
      A a;
      std::cout &lt;&lt; *a.uv &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>Now, I can get rid of the naked pointer with <code>make_shared</code>:</p>
  
  <pre><code>struct A {
      A () {
          v = {1, 2, 3, 4};
          uv = std::make_shared&lt;int&gt;(v.front());
      }
  
      std::vector&lt;int&gt;     v;
      std::shared_ptr&lt;int&gt; uv;
  };
  </code></pre>
  
  <p>Since C++11 doesn't implement make_unique yet, how can I do the same thing with a unique_ptr? I tried assigning the front element by making <code>uv</code> a <code>unique_ptr</code> and calling <code>uv.reset(&amp;v.front());</code>, but I get the following error:</p>
  
  <pre><code>malloc: *** error for object 0x7f856bc0bcf0: pointer being freed was not allocated
  </code></pre>
  
  <p>Any help? Thanks</p>