Content deleted Content added
m fixed references |
Fix code highlighting |
||
Line 18:
== Functions ==
The placement new functions are overloads of the non-placement new functions. The declaration of the non-placement new functions, for non-array and array <code>new</code> expressions respectively, are:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />:<source lang="cpp" enclose=div>
void * operator new[] (std::size_t) throw(std::bad_alloc);
▲void * operator new[] (std::size_t) throw(std::bad_alloc);
</source>
The Standard C++ library provides two placement overloads each for these functions. Their declarations are:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />:<source lang="cpp" enclose=div>
void * operator new (std::size_t,
void * operator new[] (std::size_t,
void * operator new[] (std::size_t,
▲void * operator new[] (std::size_t, void *) throw();
</source>
In all of the overloads, the first parameter to the <code>operator new</code> function is of type <source lang="cpp" enclose=none>std::size_t</source>, which when the function is called will be passed as an argument specifying the amount of memory, in bytes, to allocate. All of the functions must return type <source lang="cpp" enclose=none>void *</source>, which is a [[pointer (computer programming)|pointer]] to the storage that the function allocates.<ref name=Lischner2003 />
There are also placement delete functions. They are overloaded versions of the non-placement delete functions. The non-placement delete functions are declared as:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />:<source lang="cpp" enclose=div>
void operator delete[] (void *) throw();
▲void operator delete[] (void *) throw();
</source>
The Standard C++ library provides two placement overloads each for these functions. Their declarations are:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />:<source lang="cpp" enclose=div>
void operator delete (void *,
void operator delete[] (void *,
void operator delete[] (void *,
▲void operator delete[] (void *, void *) throw();
</source>
|