title: Basic questions about RAII, STL pop, and PIMPL
body: <p>While reading proggit today, I came upon this comment in a <a href="http://www.reddit.com/r/programming/comments/b9iiv/for_all_you_haters_of_c_take_a_look_at_the/" rel="nofollow noreferrer">post</a> about how the top places in the Google Ai challenge were taken by C++. User <code>reventlov</code> declares</p>
  <blockquote>
  <p>The biggest problem I have with C++ is that it's waaay too easy to think that you're a &quot;C++ programmer&quot; without really understanding all the things you need to understand to use C++ acceptably well.</p>
  <p>You've got to know RAII, and know to use namespaces, and understand proper exception handling (for example, you should be able to explain why the pop() methods in the STL do not return the values they remove). You've got to know which of the three generations of functions in the standard library is the right one. You should be familiar with concepts like PIMPL. You need to understand how the design of the standard library (especially the STL) works. You need to understand how macros interact with namespaces, and why you usually shouldn't use macros in C++, and what you should use instead (usually templates or inlines, rarely a class). You need to know about boost.</p>
  </blockquote>
  <p>I think I'm one of those clueless C++ programmers he mentions. To keep this brief, my questions are</p>
  <ol>
  <li>Can you give an example of a typical RAII oversight mistake, e.g. where best practices dictate the use of RAII but programmers have implemented using some other way?</li>
  <li><em>Why</em> doesn't the pop() methods in STL return the value they remove?</li>
  <li>I read the Wikipedia entry for PIMPL, didn't understand any of it. Can you give an example of a typical usage of the PIMPL idiom.</li>
  </ol>