Placement syntax: Difference between revisions

Content deleted Content added
No edit summary
Tags: Reverted Mobile edit Mobile web edit
Undid revision 1228072781 by 103.173.7.231 (talk)
Line 1:
OutIn the [[C++]] [[programming language]], '''placement [[Syntax (programming languages)|syntax]]''' allows programmers to explicitly specify the [[memory management]] of individual objects&nbsp;— i.e. their "pplacement" 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 />