Lesson plan

Placement syntax

Placement syntax in the C++ programming language refers to the syntax for explicitly specifying the memory management of individual objects (i.e. their "placement" in 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 initialize the object within the newly allocated memory. The placement syntax allows the programmer to supply additional arguments to the allocation function. A common use is to supply a pointer to a suitable region of storage where the object can be initialized, thus separating memory allocation from object construction. The "placement" versions of the new and delete operators and functions are known as placement new and placement delete . A new expression, placement or otherwise, calls a new function, also known as an allocator function, whose name is operator new . Similarly, a delete expression calls a delete function, also known as a deallocator function, whose name is operator delete . Any new expression that uses the placement syntax is a placement new expression, and any operator new or operator delete function that takes more than the mandatory first parameter ( size_t ) is a placement new or placement delete function. A placement new function takes two input parameters: size_t and void* .

Back to article

Article summary

Placement syntax in the C++ programming language refers to the syntax for explicitly specifying the memory management of individual objects (i.e. their "placement" in 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 initialize the object within the newly allocated memory. The placement syntax allows the programmer to supply additional arguments to the allocation function. A common use is to supply a pointer to a suitable region of storage where the object can be initialized, thus separating memory allocation from object construction. The "placement" versions of the new and delete operators and functions are known as placement new and placement delete . A new expression, placement or otherwise, calls a new function, also known as an allocator function, whose name is operator new . Similarly, a delete expression calls a delete function, also known as a deallocator function, whose name is operator delete . Any new expression that uses the placement syntax is a placement new expression, and any operator new or operator delete function that takes more than the mandatory first parameter ( size_t ) is a placement new or placement delete function. A placement new function takes two input parameters: size_t and void* .

Key claims

No claims recorded.

Discussion questions

  1. Summarise the article in your own words. Which single claim would you verify first, and why?
  2. Which claim in this article is most likely to be revised as the sources update? How would you check its current status?
  3. If two sources disagreed about one of these facts, what would you need in order to trust one over the other?

Bibliography

No sources recorded.

Key claims and bibliography are generated from the same tracked claims and sources as the article page.