title: Is there a way to distinguish between new's and new[]'s return value?
body: <p>Consider this code:</p>
  
  <pre><code>int *p = new int;
  cout &lt;&lt; sizeof(*p);
  delete p;
  </code></pre>
  
  <p>As expected the result is 4. Now, consider this other code:</p>
  
  <pre><code>int *p = new int[10];
  cout &lt;&lt; sizeof(*p);
  delete[] p;
  </code></pre>
  
  <p>I expected to get 40 (the size of the allocated array), however <strong>the result is still 4</strong>.</p>
  
  <p>Now, suppose I have a function <code>int *foo()</code> that returns a pointer to a structure created with <code>new</code> or with <code>new[]</code> (but I don't know which one):</p>
  
  <pre><code>int *p = foo();
  </code></pre>
  
  <p>My question is, is there a way (or hack) to know if <code>p</code> points to a single integer or an array of integers?</p>
  
  <p><em>Please keep in mind that this is just a theoretical question. I won't be writing real code in this fashion.</em></p>