Right analogue of xmalloc in C++
<p>Two simple questions: In plain <code>C</code> we frequently use <code>xmalloc</code> which is a allocate-or-abort routine. I implemented it in C++. Is this a right exception-free implementation?</p>

<pre><code>template &lt;typename T&gt;
T *xnew(const size_t n)
{
    T *p = new (std::nothrow) T[n];
    if (p == nullptr)
    {
        cerr &lt;&lt; "Not enough memory\n";
        abort();
    }
    return p;
}

int main()
{
    int *p = xnew&lt;int&gt;(5000000000LL);
}
</code></pre>

<p>Second question, if I remove the <code>&lt;int&gt;</code> from the <code>xnew&lt;int&gt;(5000000000LL);</code> call, compiler (g++ 4.7.2) <strong>cannot infere</strong> that <code>[T = int]</code> anymore although the return type <code>int *</code> is still there. Why is that?</p>

<p><strong>Edit:</strong> Isn't there any overhead when using the <code>new</code> version which could throw exception even if it's not thrown? I really don't want to use any exceptions when not absolutely necessary.</p>
