title: Is there a safe way to use C++11 Smart Pointer and the Interface for Raw Pointer together?
body: <p>I want to use C++11 Smart Pointers in new projects, and encounter a problem. Many current projects still use raw pointers as parameters in their interface and have no interface for smart pointers, e.g. <a href="http://qt-project.org/doc/qt-5.0/qtwidgets/qmainwindow.html#setCentralWidget" rel="noreferrer">QMainWindow::setCentralWidget</a>.</p>
  
  <p>To keep type consistent, I have to pass the stored pointer from <code>get()</code> like this segment:</p>
  
  <pre><code>QMainWindow win;
  
  std::shared_ptr&lt;QWidget&gt; scrollArea{ std::make_shared&lt;QScrollArea&gt;() };
  // QScrollArea is a derived class of QWidget.
  
  win.setCentralWidget(scrollArea.get());
  </code></pre>
  
  <p>But I can't make sure whether other methods in Qt execute operator <code>delete</code> on the stored pointer of <code>scrollArea</code>.</p>
  
  <p><strong>Will it cause memory leak or other problems if some methods in Qt do that?</strong></p>
  
  <p>I've checked the latest <a href="http://isocpp.org/files/papers/N3690.pdf" rel="noreferrer">C++ Standard CD</a> and found nothing on that. Seems it's an undefined behavior.</p>
  
  <p>If doing this is an undefined behavior and dangerous, <strong>is there a safe way to use smart pointer(s) with the interface for raw pointer(s)?</strong></p>