Reputation: 6655
Which library has the definition for the global new and the delete operator? Specifically which file in the library contains the definition for these operators?
Upvotes: 0
Views: 125
Reputation: 254471
The non-placement forms of operator new
and operator delete
(and their array forms) are declared implicitly in the global scope in every translation unit.
The standard placement forms are declared in <new>
.
The definitions of library functions are not generally available. Your supplier might supply the source, in which case they will be in there somewhere.
Although, from your comments, you may be talking about the use of new
in a new-expression, rather than the operator new
function that allocates memory. The new-expression is handled by the compiler, generating the necessary calls to operator new
and the object(s) constructor(s). There probably won't be a specific implementation of this anywhere; you'd need to look at the relevant part of the compiler's code generator.
Upvotes: 3
Reputation: 791909
It's not specified where these are defined but it is specified that they are declared in the header <new>
. (You shouldn't have to include <new>
if you are just using the standard versions used by non-placement new
expressions, these are available automatically in all translation units.)
Upvotes: 3