title: Delete std::shared_ptr without destroying the managed object?
body: <p>I'm in the following scenario:</p>
  
  <pre><code>struct container {
      data* ptr;
  };
  
  void someFunc(container* receiver /* wants to be filled */) {
      auto myData = createData(); // returns shared_ptr&lt;data&gt;
      receiver-&gt;ptr = myData.get();
  }
  </code></pre>
  
  <p><em>The function that generates that data, and the object that receives it, are part of two different libraries, which I can't modify the source code of. I have to work with these data types, there's nothing I can do about it.</em></p>
  
  <p>So I have to implement a function that acquires some data, then passes a pointer to that data to an object. My problem is that the function that creates my data, returns a <code>shared_ptr</code> instance to it. The object that needs the data will only accept a raw pointer to it.</p>
  
  <p>As you can see, I call <code>get()</code> on the <code>shared_ptr</code> to get the raw pointer and pass it to the receiving object. If I'm not mistaken, then a <code>shared_ptr</code> decrements the reference count whenever it goes out of scope. So in this case, that means that it would destroy my data as soon as the function returns, since the reference count would reach 0.</p>
  
  <p>So how can I get rid of the <code>shared_ptr</code> instance without destroying the managed object? The object which I pass the data to (illustrated with the "container" struct for simplicity) does take care of the memory cleaning inside its destructor, so I don't need any reference counting or anything like that. I don't want anything to watch over that allocated data anymore (except the object that receives a pointer to it). I want to get rid of the <code>shared_ptr</code>, and only have a raw pointer to the allocated data, which I can pass to the receiving object.</p>
  
  <p>Is that possible?</p>