title: When is #include <new> library required in C++?
body: <p>According to <a href="http://www.cplusplus.com/reference/std/new/operator%20new/" rel="nofollow noreferrer">this reference</a> for <code>operator new</code>:</p>
  <blockquote>
  <p>Global dynamic storage operator
  functions are special in the standard
  library:</p>
  <ul>
  <li>All three versions of operator new are declared in the global namespace,
  not in the std namespace.</li>
  <li>The first and second versions are implicitly declared in every
  translation unit of a C++ program: The
  header  does not need to be
  included for them to be present.</li>
  </ul>
  </blockquote>
  <p>This seems to me to imply that the third version of <code>operator new</code> (placement <code>new</code>) is not implicitly declared in every translation unit of a C++ program and the header <code>&lt;new&gt;</code> does need to be included for it to be present. Is that correct?</p>
  <p>If so, how is it that using both g++ and MS VC++ Express compilers it seems I can compile code using the third version of <code>new</code> without <code>#include &lt;new&gt;</code> in my source code?</p>
  <p>Also, the MSDN Standard C++ Library reference entry on <code>operator new</code> gives some example code for the three forms of <code>operator new</code> which contains the <code>#include &lt;new&gt;</code> statement, however the example seems to compile and run just the same for me without this include?</p>
  <pre><code>// new_op_new.cpp
  // compile with: /EHsc
  #include&lt;new&gt;
  #include&lt;iostream&gt;
  
  using namespace std;
  
  class MyClass 
  {
  public: 
     MyClass( )
     {
        cout &lt;&lt; &quot;Construction MyClass.&quot; &lt;&lt; this &lt;&lt; endl;
     };
  
     ~MyClass( )
     {
        imember = 0; cout &lt;&lt; &quot;Destructing MyClass.&quot; &lt;&lt; this &lt;&lt; endl;
     };
     int imember;
  };
  
  int main( ) 
  {
     // The first form of new delete
     MyClass* fPtr = new MyClass;
     delete fPtr;
  
     // The second form of new delete
     char x[sizeof( MyClass )];
     MyClass* fPtr2 = new( &amp;x[0] ) MyClass;
     fPtr2 -&gt; ~MyClass();
     cout &lt;&lt; &quot;The address of x[0] is : &quot; &lt;&lt; ( void* )&amp;x[0] &lt;&lt; endl;
  
     // The third form of new delete
     MyClass* fPtr3 = new( nothrow ) MyClass;
     delete fPtr3;
  }
  </code></pre>
  <p>Could anyone shed some light on this, and when and why you might need to <code>#include &lt;new&gt;</code> - maybe some example code that will not compile without <code>#include &lt;new&gt;</code>?</p>