Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
Dec 14, 1999

Purpose of Placement delete

C++ defines a placement version of operator delete. Placement delete is not supposed to be called directly by the user. Rather, it merely serves as the deacllocation function that the implementation must invoke when an exception occurs during the construction of an object by placement new. To generalize, for every version of operator new, C++ provides a matching operator delete. Since there are six versions of operator new (ordinary new, placement new, nothrow new, as well as their array counterparts), there are also six corresponding versions of delete.

As opposed to a common belief, placement delete does not invoke the destructor of its argument; in fact, it has no effect. To ensure that an object constructed by placement new is destructed, you need to call its destructor explicitly.

Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap