title: How to use a shared_ptr with a pointer to struct that should not be freed
body: <p>Currently I'm using some functions from the glib library. With glib also comes the gio. glib is a C library and therefore I need to delete some structures that I create.</p>
  <p>for many of the objects I create a smartpointer eg:</p>
  <pre><code>std::shared_ptr&lt;GAsyncQueue&gt; my_queue = std::shared_ptr&lt;GAsyncQueue&gt;(g_async_queue_create(), g_async_queue_unref);
  </code></pre>
  <p>For this creates a shared pointer to an <code>GAsyncQueue</code> and this is safely destroys the queue on its end of its life.</p>
  <p>However, I encounter a problem when I obtain a pointer from the gio library that I should not free. In the following code <code>my_connection</code> is a GSocketClient which implements (in glib speak) GIOStream.</p>
  <pre><code>std::shared_ptr&lt;GInputStream&gt; my_input_stream = 
       std::shared_ptr&lt;GInputStream&gt; (
          g_io_stream_get_input_stream(G_IO_STREAM(my_connection.get()))
       );
  </code></pre>
  <p>Because the documentation on GIOStream mentions, that the pointer obtained with <code>g_io_stream_get_input_stream()</code> should not be freed. That is because it is owned by the <code>my_connection</code> instance.
  I thought about creating a lamda for the destroy object, the second parameter of a shared pointer object. eg <code>auto deleter = [](GInputStream* ptr) {};</code> and then give that lambda as destroy function to the shared pointer, but that feels a kind of stupid.</p>