title: How to check memory allocation failures with new operator?
body: <p>Just recently I switched the language of my project to use C++ from C.
  With C, I used malloc and after that I check if malloc was successful but with C++, I use 'new' to allocate memory and I would like to know how you would normally check the memory allocation failure.</p>
  
  <p>From my google search, I saw nothrow like the following.</p>
  
  <pre><code>char *buf = new (nothrow)char[10];
  </code></pre>
  
  <p>I also saw the following.</p>
  
  <pre><code>try{} catch(bad_alloc&amp;) {}
  </code></pre>
  
  <p>But what about the following? I am using some of chrome library routines to use smart pointers.</p>
  
  <p>For instance, I have the code as follows.</p>
  
  <pre><code>scoped_array&lt;char&gt; buf(new char[MAX_BUF]);
  </code></pre>
  
  <p>It is great to use smart pointers but I am just not sure how I should check if the memory allocation was successful. 
  Do I need to break into two separate statement with nothrow or try/catch?
  How do you normally do these checks in C++?</p>
  
  <p>Any advice will be appreciated.</p>