In the [[C++]] [[programming language]], '''placement [[Syntax (programming languages)|syntax]]''' allows programmers to explicitly specify the [[memory management]] of individual objects — i.e. their "placement" in [[memory (computing)|memory]]. Normally, when an object is created dynamically, an allocation function is invoked in such a way that it will both allocate memory for the object, and [[Constructor (object-oriented programming)|initialize]] the object within the newly allocated memory.<!--5.3.5--> The placement syntax allows the programmer to supply additional arguments to the allocation function. A common use is to supply a [[pointer (computer programming)|pointer]] to a suitable region of storage where the object can be initialized, thus separating memory allocation from object construction.{{Citation needed|date=October 2010}}
The "placement" versions of the <code>[[new (C++)|new]]</code> and <code>[[delete (C++)|delete]]</code> operators and functions are known as placement <code>new</code> and placement <code>delete</code>.<ref name=McCluskey2000 /> A <code>new</code> ''expression'', placement or otherwise, calls a <code>new</code> ''function'', also known as an allocator function, whose name is <code>operator new</code>. Similarly, a <code>delete</code> ''expression'' calls a <code>delete</code> ''function'', also known as a deallocator function, whose name is <code>operator delete</code>.<ref name=Lischner2003 /><ref name=Lippman1997 />
Any <code>new</code> expression that uses the placement syntax is a placement <code>new</code> expression, and any <code>operator new</code> or <code>operator delete</code> function that takes more than the mandatory first parameter (<sourcesyntaxhighlight lang="cpp" enclose=noneinline>std::size_t</sourcesyntaxhighlight> and <source lang="cpp" enclose=none>void *</source>, respectively) is a placement new or placement delete function.<ref name=Meyers1998 /> A placement new function takes two input parameters: <syntaxhighlight lang="cpp" inline>std::size_t</syntaxhighlight> and <syntaxhighlight lang="cpp" inline>void*</syntaxhighlight>.
== History ==
In earlier versions of C++, there was no such thing as ''placement new''; instead, developers used explicit assignment to ''<code>this''</code> within constructors to achieve similar effect.<ref name=Stroustrup1991 /> This practice has been deprecated and abolished later,{{When|date=April 2025 |reason=Is there a specific C++ standard that abolishes this technique?}} and the third edition of ''[[The C++ Programming Language]]'' doesn'tdoes not mention this technique. Support for ''placement new'' operator has been added to compilers circa 1995.{{Citation needed|date=October 2010}}
== Expressions ==
The Standard C++ syntax for a non-placement <code>new</code> expression is<ref name=Lischner2003 />
: <code>new ''new-type-id'' ( ''optional-initializer-expression-list'' )</code>
The placement syntax adds an expression list immediately after the <code>new</code> keyword. This expression list is the placement. It can contain any number of expressions.<ref name=Lischner2003 /><ref name=Lippman1997 /><ref name=Loudon2003 />
: <code>new ( ''expression-list'' ) ''new-type-id'' ( ''optional-initializer-expression-list'' )</code>
There is no placement delete expression.<ref name=SolterKleper2005 />
== 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 />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
void * operator new (std::size_t) throw(std::bad_alloc);
void * operator new[] (std::size_t) throw(std::bad_alloc);
</syntaxhighlight>
</source>
The Standard C++ library provides two placement overloads each for these functions. Their declarations are:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
void * operator new (std::size_t, const std::nothrow_t &) throw()noexcept;
void * operator new (std::size_t, void *) throw()noexcept;
void * operator new[] (std::size_t, const std::nothrow_t &) throw()noexcept;
void * operator new[] (std::size_t, void *) throw()noexcept;
</syntaxhighlight>
</source>
In all of the overloads, the first parameter to the <code>operator new</code> function is of type <sourcesyntaxhighlight lang="cpp" enclose=noneinline>std::size_t</sourcesyntaxhighlight>, 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 <sourcesyntaxhighlight lang="cpp" enclose=noneinline>void *</sourcesyntaxhighlight>, 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 />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
void operator delete (void *) throw()noexcept;
void operator delete[] (void *) throw()noexcept;
</syntaxhighlight>
</source>
The Standard C++ library provides two placement overloads each for these functions. Their declarations are:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
void operator delete (void *, const std::nothrow_t &) throw()noexcept;
void operator delete (void *, void *) throw()noexcept;
void operator delete[] (void *, const std::nothrow_t &) throw()noexcept;
void operator delete[] (void *, void *) throw()noexcept;
</syntaxhighlight>
</source>
In all of the overloads, the first parameter to the <code>operator delete</code> function is of type <sourcesyntaxhighlight lang="cpp" enclose=noneinline>void *</sourcesyntaxhighlight>, which is the address of the storage to deallocate.<ref name=Lischner2003 />
For both the new and the delete functions, the functions are global, are not in any namespace, and do not have static linkage.<ref name=Lischner2003 />
=== Default placement ===
The placement overloads of <code>operator new</code> and <code>operator delete</code> that employ an additional <sourcesyntaxhighlight lang="cpp" enclose=noneinline>void *</sourcesyntaxhighlight> parameter are used for default placement, also known as ''pointer placement''. Their definitions by the Standard C++ library, which it is not permitted for a C++ program to replace or override, are:<ref name=Vermeir2001 /><ref name=Stroustrup1997b /><ref name=Anderson1998a />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
void * operator new (std::size_t, void * p) throw()noexcept { return p ; }
void * operator new[] (std::size_t, void * p) throw()noexcept { return p ; }
void operator delete (void *, void *) throw()noexcept { }
void operator delete[] (void *, void *) throw()noexcept { }
</syntaxhighlight>
</source>
Default placement does not require the inclusion of the Standard C++ library header <code><new></code> in the source code of a C++ program.<ref name=Lischner2003 /> However, [[GNU Compiler Collection|g++]] version 4.0 still requires the use of this header (this might be true of other versions of the compiler or other compilers too.){{Citation needed|date=October 2010}}
There are various uses for default placement.
Other uses, however, include calling a constructor directly, something which the C++ language does not otherwise permit.<ref name=Lippman1997 />
The C++ language does allow a program to call a [[destructor (computer science)|destructor]] directly, and, since it is not possible to destroy the object using a <code>delete</code> expression, that is how one destroys an object that was constructed via a pointer placement new expression. For example:<ref name=SolterKleper2005 /><ref name=SeedCooper2001 />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
p->~T() ;
</syntaxhighlight>
</source>
=== Use cases ===
Placement new is used when you do not want operator new to allocate memory (you have pre-allocated it and you want to place the object there), but you do want the object to be constructed. Examples of typical situations where this may be required are:
* You want to create objects in memory shared between two different processes.
* You want objects to be created in non-pageable memory.
* You want to separate memory allocation from construction e.g. in implementing a <code>std::vector<></code> (see <code>std::vector<>::reserve</code>).
The basic problem is that the constructor is a peculiar function; when it starts off, there is no object, only raw memory. And by the time it finishes, you have a fully initialized object. Therefore, i) The constructor cannot be called on an object ii) However, it needs to access (and initialize) non-static members. This makes calling the constructor directly an error. The solution is the placement form of operator new.
This operator is implemented as: <sourcesyntaxhighlight lang="cpp" enclose=div>
void* operator new(std::size_t count, void* here) noexcept { return here; }
inline void* operator new[]( std::size_t szcount, void* here) )noexcept { return here; }
</syntaxhighlight>
{ return here ; }
inline void* operator new[]( size_t sz, void* here )
{ return here ; }
</source>
In your case, using this is not required as an int is [[Plain old data structure|POD]], it has a trivial constructor. If you want to use it, you could use it this way:<source lang="cpp" enclose=div>
for( int i = 0; i < MAX_PIXELS; i++ )
{
int* p = new (buffer+i) int(i) ; // specify where you want the object
v.push_back( p ) ;
cout << "p = " << p << ", *p = " << *p << endl ;
}
</source>
note: Do not call delete for objects allocated using placement new. If they have non-trivial destructors, call the destructor directly (destruction is an operation on an object and therefore can be called!). Release the memory you allocated yourself.
=== Preventing exceptions ===
Normally, the (non-placement) new functions throw an exception, of type <code>std::bad_alloc</code>, if they encounter an error, such as exhaustion of all available memory. This was not how the functions were defined by Stroustrup's ''Annotated C++ Reference Manual'', but was a change made by the standardization committee when the C++ language was standardized. The original behaviour of the functions, which was to return a <sourcesyntaxhighlight lang="cpp" enclose=noneinline>NULL</sourcesyntaxhighlight> pointer when an error occurred, is accessible via placement syntax.<ref name=Lippman1997 /><ref name=Meyers1998 /><ref name=Loudon2003 />
Programmers who wish to do this in their programs must include the Standard C++ library header <code><<new>></code> (or import the <code>std</code> module) in the source code. This header declares the global <code>std::nothrow</code> object, which is of type <code>std::nothrow_t</code> (also declared in the header), which is used to call the overloaded new functions that are declared as taking <sourcesyntaxhighlight lang="cpp" enclose=noneinline>const std::nothrow_t &</sourcesyntaxhighlight> as their second parameter. For example:<ref name=Anderson1998a />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
import std;
#include <new>
struct T {} ;
int main () {
// Call the function operator new(std::size_t, const std::nothrow_t&) and (if successful) construct the object.
{
T* p = new (std::nothrow) T;
// Call the function operator new(std::size_t, const std::nothrow_t &) and (if successful) construct the object.
T * p = new (std::nothrow) T ;
if (p) {
// The storage has been allocated and the constructor called.
delete p ;
} else
; // An error has occurred. No storage has been allocated and no object constructed.
return 0 ;
}
</syntaxhighlight>
</source>
=== Custom allocators ===
Placement syntax is also employed for custom [[allocator (C++)|allocators]]. This does not use any of the allocator and deallocator functions from the Standard C++ library header <code><<new></code>, but requires that programmers write their own allocation and deallocation functions, overloaded for user-defined types. For example, one could define a memory management class as follows:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
import std;
#include <cstdlib>
class A {
public:
void * allocate ( std::size_t ) ;
void deallocate ( void * ) ;
} ;
</syntaxhighlight>
</source>
And define custom placement allocation and deallocation functions as follows:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
void* operator new(std::size_t size, A& arena) {
void *
return arena.allocate(size);
operator new (std::size_t size, A & arena)
{
return arena.allocate(size) ;
}
void
void operator delete (void * p, A & arena) {
arena.deallocate(p);
{
arena.deallocate(p) ;
}
</syntaxhighlight>
</source>
The program would employ the placement syntax to allocate objects using different instances of the <code>A</code> class as follows:<ref name=Vermeir2001 /><ref name=Stroustrup1997b />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
A first_arena, second_arena ;
T * p1 = new (first_arena) T ;
T * p2 = new (second_arena) T ;
</syntaxhighlight>
</source>
Destroying an object whose storage is allocated in such a fashion requires some care. Because there is no placement delete expression, one cannot use it to invoke the custom deallocator. One must either write a destruction function that invokes the custom deallocator, or call the placement delete function directly, as a function call.<ref name=SolterKleper2005 /><ref name=Vermeir2001 /><ref name=Stroustrup1997b />
The former would resemble:<ref name=Stroustrup1997b />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
void destroy(T* p, A& arena) {
void
p->~T(); // First invoke the destructor explicitly.
destroy (T * p, A & arena)
arena.deallocate(p); // Then call the deallocator function directly.
{
p->~T() ; // First invoke the destructor explicitly.
arena.deallocate(p) ; // Then call the deallocator function directly.
}
</syntaxhighlight>
</source>
which would be invoked from a program as:
:<sourcesyntaxhighlight lang="cpp" enclose=div>
A arena ;
T * p = new (arena) T ;
/* ... */
destroy(p, arena) ;
</syntaxhighlight>
</source>
The latter would involve simply writing the destructor invocation and delete function call into the program:<ref name=Vermeir2001 /><ref name=Dewhurst2003 />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
A arena ;
T * p = new (arena) T ;
/* ... */
p->~T() ; // First invoke the destructor explicitly.
operator delete(p, arena) ; // Then call the deallocator function indirectly via operator delete(void *, A &) .
</syntaxhighlight>
</source>
A common error is to attempt to use a delete expression to delete the object. This results in the wrong <code>operator delete</code> function being called. Dewhurst recommends two strategies for avoiding this error. The first is to ensure that any custom allocators rely upon the Standard C++ library's global, non-placement, <code>operator new</code>, and are thus nothing more than simple wrappers around the C++ library's memory management. The second is to create new and delete functions for individual classes, and customize memory management via class function members rather than by using the placement syntax.<ref name=Dewhurst2003 />
=== Debugging ===
Placement new can also be used as a simple debugging tool, to enable programs to print the filename and line number of the source code where a memory allocation has failed. This does not require the inclusion of the Standard C++ library header <code><new></code>, but does require the inclusion of a header that declares four placement functions and a macro replacement for the <code>new</code> keyword that is used in new expressions. For example, such a header would contain:<ref name=Anderson1998a /><ref name=Yongwei2007 />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
#if defined(DEBUG_NEW)
void * operator new (std::size_t size, const char* file, int line);
void * operator new[] (std::size_t size, const char* file, int line);
void operator delete (void * p, const char* file, int line);
void operator delete[] (void * p, const char* file, int line);
#define New new(__FILE__, __LINE__)
#else
#define New new
#endif
</syntaxhighlight>
</source>
This would be employed in a program as follows:<ref name=Anderson1998a /><ref name=Yongwei2007 />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
T * p = New T ;
</syntaxhighlight>
</source>
The custom-written placement new functions would then handle using the supplied file and line number information in the event of an exception. For example:<ref name=Anderson1998a /><ref name=Yongwei2007 />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
import std;
#include <new>
#include <cstdlib>
class NewErrorAlloationError {
public:
NewErrorAlloationError(const char * file, int line) { /* ... */ }
/* ... */
} ;
void* operator new(std::size_t size, const char* file, int line) {
void *
if (void* p = ::operator new(size, std::nothrow))
operator new (std::size_t size, const char* file, int line)
return p;
{
throw AlloationError(file, line);
if (void * p = ::operator new (size, std::nothrow))
return p ;
throw NewError(file, line) ;
}
</syntaxhighlight>
</source>
== Placement delete ==
As noted above, there is no placement delete expression. It is not possible to call ''any'' placement <code>operator delete</code> function using a <code>delete</code> expression.<ref name=SolterKleper2005 /><ref name=Anderson1998b />
The placement delete functions are called from placement <code>new</code> expressions. In particular, they are called if the [[constructor (computer science)|constructor]] of the object throws an exception. In such a circumstance, in order to ensure that the program does not incur a [[memory leak]], the placement delete functions are called. A placement new expression first calls the placement <code>operator new</code> function, then calls the constructor of the object upon the raw storage returned from the allocator function. If the constructor throws an exception, it is necessary to deallocate that storage before propagating the exception back to the code that executed the placement new expression, and that is the purpose of the placement delete functions.<ref name=Lischner2003 /><ref name=Meyers1998 /><ref name=SolterKleper2005 /><ref name=Anderson1998b />
The placement delete function that is called matches the placement new function that was invoked by the placement new expression. So, for example, if the following code is executed, the placement delete function that is called will be <code>operator delete(void *, const A &)</code>:<ref name=Lischner2003 /><ref name=SolterKleper2005 /><ref name=Anderson1998b />
:<sourcesyntaxhighlight lang="cpp" enclose=div>
import std;
#include <cstdlib>
#include <iostream>
struct A {} ;
struct E {} ;
class T {
public:
T() { throw E() ; }
} ;
void * operator new ( std::size_t, const A & ) {
{std::cout << println("Placement new called." << std::endl);}
}
void operator delete ( void *, const A & )
{std::cout << "Placement delete called." << std::endl;}
void operator delete(void*, const A&) {
int main ()
std::println("Placement delete called.");
{
}
A a ;
int main(){
A a;
try {
T * p = new (a) T ;
} catch (E exp) {std::cout << "Exception caught." << std::endl;}
std::println("Exception caught.");
return 0 ;
}
return 0;
}
</syntaxhighlight>
This is why the ''pointer placement'' delete functions are defined as no-operations by the Standard C++ library. Since the pointer placement new functions do not allocate any storage, there is no storage to <ref name=":0">{{Cite book|last1=Kundu|first1=Ashish|last2=Bertino|first2=Elisa|title=2011 31st International Conference on Distributed Computing Systems |chapter=A New Class of Buffer Overflow Attacks |date=June 2011|pages=730–739|doi=10.1109/ICDCS.2011.63|isbn=978-1-61284-384-1 |s2cid=8583476 |via=IEEE}}</ref> be deallocated in the event of the object's constructor throwing an exception.<ref name=SolterKleper2005 />
</source>
If no matching placement delete function exists, no deallocation function is called in the event of an exception being thrown by a constructor within a placement <code>new</code> expression. There are also some (older) C++ implementations that do not support placement delete (which, like the exception-throwing allocator functions, were an addition made to C++ when it was standardized) at all. In both such situations, an exception being thrown by a constructor when allocating using a custom allocator will result in a memory leak. (In the case of the older C++ implementations, a memory leak will also occur with ''non-''placement <code>new</code> expressions.)<ref name=Meyers1998 /><ref name=Anderson1998b />
This is why the ''pointer placement'' delete functions are defined as no-operations by the Standard C++ library. Since the pointer placement new functions do not allocate any storage, there is no storage to be deallocated in the event of the object's constructor throwing an exception.<ref name=SolterKleper2005 />
== Security ==
If no matching placement delete function exists, no deallocation function is called in the event of an exception being thrown by a constructor within a placement <code>new</code> expression. There are also some (older) C++ implementations that do not support placement delete (which, like the exception-throwing allocator functions, were an addition made to C++ when it was standardized) at all. In both such situations, an exception being thrown by a constructor when allocating using a custom allocator will result in a memory leak. (In the case of the older C++ implementations, a memory leak will also occur with ''non-''placement <code>new</code> expressions.)<ref name=Meyers1998 /><ref name=Anderson1998b />
Placement new expressions are vulnerable to security exploits. In 2011, Kundu and Bertino<ref name=":0" /> demonstrated some of the exploits on placement new. Some of the attacks are buffer overflow attacks, object overflow, selective stackguard overriding, virtual pointer subterfuge, memory misalignment attacks. In 2015, GCC released a patch<ref>{{Cite web|title=Martin Sebor - [PING] [PATCH] c++/67942 - diagnose placement new buffer overflow|url=https://gcc.gnu.org/legacy-ml/gcc-patches/2015-10/msg02001.html|access-date=2020-06-15|website=gcc.gnu.org}}</ref> based on the findings in.<ref name=":0" />
== Notes ==
{{reflist|3|refs=
<ref name=Anderson1998a>{{harvnb|Anderson|1998a|pp=345–356}}</ref>
<ref name=Anderson1998b>{{harvnb|Anderson|1998b|pp=631–632}}</ref>
<!-- <ref name=Buck1997>{{harvnb|Buck|1997}}</ref> -->
<ref name=Dewhurst2003>{{harvnb|Dewhurst|2003|pp=173–176}}</ref>
<ref name=Lischner2003>{{harvnb|Lischner|2003|pp=72–73,128–129,310, 623–625}}</ref>
<ref name=Lippman1997>{{harvnb|Lippman|1997|pp=386–389}}</ref>
<ref name=Loudon2003>{{harvnb|Loudon|2003|pp=109–110}}</ref>
<ref name=Stroustrup1991>{{harvnb|Stroustrup|1991|pp=}}{{Page needed|date=November 2010}}</ref>
<ref name=Stroustrup1994>{{harvnb|Stroustrup|1994|pp=214}}</ref>
<ref name=Stroustrup1997b>{{harvnb|Stroustrup|1997|pp=255–256, 576}}</ref>
<ref name=Vermeir2001>{{harvnb|Vermeir|2001|pp=113–115}}</ref>
<ref name=Yongwei2007>{{harvnb|Yongwei|2007}}</ref>
== References ==
{{refbegin|1}}
* {{cite book|ref=harv|title=Navigating C++ and Object-oriented Design|first=Gail|last=Anderson|chapter=Object Storage Management|publisher=Prentice Hall|year=1998a|isbn=0-13-532748-2|isbn13=9780135327487}}
* {{cite book|ref=harv|title=Navigating C++ and Object-oriented Design|first=Gail|last=Anderson|chapter=Exception Handling|publisher=Prentice Hall|year=1998b|isbn=0-13-532748-2|isbn13=9780135327487}}
* {{cite web|ref=harv|url=http://www.desy.de/user/projects/C++/g++faq/placement_new_syntax.html|title=3.4. g++ won't accept the placement new syntax.|date=1997-05-12|first=Joe|last=Buck|work=Frequently asked questions about the GNU C++ compiler|accessdateaccess-date=2008-11-26}}
* {{cite book|ref=harv|title=C++ Gotchas|first=Stephen C.|last=Dewhurst|chapter=Gotcha #62: Replacing Global New and Delete|chapterurlchapter-url=http://informit.com/articles/article.aspx?p=30642&seqNum=3|publisher=[[Addison-Wesley]]|year=2003|isbn=978-0-321-12518-7}}
* {{cite book|ref=harv|title=C++ in a Nutshell|first=Ray|last=Lischner|publisher=O'Reilly|year=2003|isbn=0-596-00298-X|isbn13=9780596002985}}
* {{cite book|ref=harv|title=C++ Gems|first=Stanley B.|last=Lippman|authorlinkauthor-link= Stanley B. Lippman |publisher=Cambridge University Press|year=1997|isbn=0-13-570581-9|isbn13=9780135705810}}
* {{cite book|ref=harv|title=C++ Pocket Reference|first=Kyle|last=Loudon|publisher=O'Reilly|year=2003 |isbn=0-596-00496-6|isbn13=9780596004965}}
* {{cite web|ref=CITEREFMcCluskey2000|url=http://glenmccl.com/nd_cmp.htm|title=Placement New/Delete|publisher=Glen McCluskey & Associates LLC|work=C++ Language and Library|date=2000-06-26|accessdateaccess-date=2008-11-26|url-status=dead|archive-url=https://web.archive.org/web/20060418093041/http://www.glenmccl.com/nd_cmp.htm|archive-date=2006-04-18}}
* {{cite news|ref=harv|date=1998-04-01|first=Scott|last=Meyers|title=Placement new and placement delete|url=http://ddj.com/showArticle.jhtml?documentID=cuj9804meyers&pgno=2|work=[[Dr. Dobb's Journal]]|publisher=United Business Media LLC}}
* {{cite book|ref=harv|title=An Introduction to Object-oriented Programming in C++|first1=Graham M.|last1=Seed|first2=Barry J.|last2=Cooper|publisher=Springer|year=2001|isbn=1-85233-450-9|edition=Second Edition}}
* {{cite book|ref=harv|title=Professional C++|first1=Nicholas|last1=Solter|first2=Scott|last2=Kleper|publisher=Wiley|year=2005|isbn=0-7645-7484-1|isbn13=9780764574849}}
* {{cite book|ref=harv|title=The C++ Programming Language|edition=2nd|first=Bjarne|last=Stroustrup|authorlinkauthor-link=Bjarne Stroustrup|isbn=978-0-201-53992-9|yeardate=July 1991|monthpublisher=JulyPearson Education Canada |url-access=registration|url=https://archive.org/details/cprogramminglang00stro}}
* {{cite book|ref=harv|last=Stroustrup|first=Bjarne|authorlinkauthor-link=Bjarne Stroustrup|title=Design and Evolution of C++|publisher=[[Addison-Wesley]]|isbn=978-0-201-54330-8|year=1994|chapter=Memory Management}}
* {{cite book|ref=harv|last=Stroustrup|first=Bjarne|authorlinkauthor-link=Bjarne Stroustrup|title=The C++ Programming Language|publisher=[[Addison-Wesley]]|edition=3rd|isbn10=0201889544|isbn=978-0-201-88954-3|year=1997|url-access=registration|url=https://archive.org/details/cprogramminglang00stro_0}}
* {{cite book|ref=harv|title=Multi-paradigm Programming Using C++|first=Dirk|last=Vermeir|publisher=Springer|year=2001|isbn=1-85233-483-5|isbn13=9781852334833}}
* {{cite web|ref=harv|title=A Cross-Platform Memory Leak Detector|date=2007-12-31|first=Wu|last=Yongwei|accessdateaccess-date=2008-11-26|work=Wu Yongwei's Programming Page|url=http://wyw.dcweb.cn/leakage.htm}}
{{refend}}
== Further reading ==
* {{cite book|last=Franek|first=Frantisek|title=Memory as a Programming Concept in C and C++|publisher=[[Cambridge University Press]]|isbn=978-0-521-52043-0|year=2004}}
* {{cite web|title=11.10: What is "placement new" and why would I use it?|url=http://parashift.com./c++-faq-lite/dtors.html#faq-11.10|work=C++ FAQ Lite|date=2006-09-25|first=Marshall|last=Cline|accessdateaccess-date=2008-11-26}}
* {{cite web|url=http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/topic/com.ibm.vacpp6m.doc/language/ref/clrc05cplr199.htm|title=C++ new Operator|work=IBM's Mac OS X compilers|year=2003|publisher=[[IBM]]|accessdateaccess-date=2008-11-27}}
* {{cite web|url=http://msdn.microsoft.com/en-us/library/t48aek43.aspx|work=[[MSDN]]|title=The operator new Function|publisher=[[Microsoft]]|access-date=|accessdate=2008-11-27}}
* {{cite web|url=http://msdn.microsoft.com/en-us/library/kewsb8ba.aspx|work=[[MSDN]]|title=new Operator (C++)|publisher=[[Microsoft]]|access-date=|accessdate=2008-11-27}}
{{DEFAULTSORT:Placement Syntax}}
[[Category:Articles with example C++ code]]
[[Category:C++]]
|