Placement syntax: Difference between revisions

Content deleted Content added
m Clean up spacing errors around ref tags., replaced: /ref>b → /ref> b
Citation bot (talk | contribs)
Alter: publisher. Add: s2cid, isbn, authors 1-1. Removed parameters. Some additions/deletions were parameter name changes. | Use this bot. Report bugs. | Suggested by SemperIocundus | #UCB_webform 1355/2500
Line 225:
</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 journal|lastlast1=Kundu|firstfirst1=Ashish|last2=Bertino|first2=Elisa|date=June 2011|title=A New Class of Buffer Overflow Attacks|url=https://ieeexplore.ieee.org/document/5961725|journal=2011 31st International Conference on Distributed Computing Systems|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 />
 
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 />
Line 261:
* {{cite book|title=C++ Gems|first=Stanley B.|last=Lippman|author-link= Stanley B. Lippman |publisher=Cambridge University Press|year=1997|isbn=9780135705810}}
* {{cite book|title=C++ Pocket Reference|first=Kyle|last=Loudon|publisher=O'Reilly|year=2003 |isbn=9780596004965}}
* {{cite web|ref=CITEREFMcCluskey2000|url=http://glenmccl.com/nd_cmp.htm|title=Placement New/Delete|publisher=Glen McCluskey &amp; Associates LLC|work=C++ Language and Library|date=2000-06-26|access-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|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|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}}