Article View: comp.std.c++
Article #3109Re: Why no allocator-specific delete?
From: Matt Timmermans
Date: Thu, 25 Jan 1996 16:01
Date: Thu, 25 Jan 1996 16:01
54 lines
2901 bytes
2901 bytes
(clamage@Eng.Sun.COM (Steve Clamage)) | In article 460@news.bridge.net, David Byrden <100101.2547@compuserve.com> | writes: | >Why, in the Septenber draft standard, is an allocator-specific verrion | >of 'new' provided; | > | >20.1.4.4 | > | > new(x) T | > | > returns an X::types<T>::pointer, where x is of an | > allocator type X | You are actually referring to the "placement new" syntax not having a | corresponding "placement delete" syntax. Yes, and this is very annoying. The lack of a placement-delete makes placement-new nearly useless. I can't, in fact, think of a single way that placement-new could be used properly. | No good syntax was found for such. The obvious syntax | delete (x) p; | leads to too many ambiguities. More importantly, it means that the | point of deletion would somehow have to know what placement version | of "new" was used and what the parameters were. Needing that knowledge | would make "placement delete" unsafe and hard to use. (Consider the | general case where the "new" and "delete" expressions are in different | compilation units, and the parameters to "new" affect how "delete" | should be called.) The caller of 'delete' already has to know the allocation policy of the object -- otherwise it would not know that it was safe to delete. Further, we already do this sort of thing all the time -- but we have to code it explicitly, i.e., remove object from collection, delete object. The lack of a placement-delete is on of the many factors in C++ conspiring to make it absolutely impossible to make generic collections that hold actual objects (with constructors) instead of just pointers. </Matt> -------------------------------------------------------------- Matt Timmermans | Phone: +1 613 596-2233 Microstar Software Ltd. | Fax: +1 613 596-5934 3775 Richmond Rd. | E-mail: mtimmerm@microstar.com Nepean Ontario CANADA K2H 5B7 | http://www.microstar.com --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<4e85k6$b04@noc.tor.hookup.net>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM>Show Full Headers
Complete Article Headers
From: mtimmerm@microstar.com (Matt Timmermans) Message-ID: <4e85k6$b04@noc.tor.hookup.net> X-Original-Date: Thu, 25 Jan 1996 14:55:49 GMT Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 25 Jan 96 16:01:45 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Re: Why no allocator-specific delete? Organization: Microstar Software Ltd. References: <4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM> X-Newsreader: Forte Free Agent v0.55 X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMQepg+EDnX0m9pzZAQEQGQGAgm4V0AUcqpHmhX1mBTwxP9J9LAf53TSb hJ0PO66jEniIvix9ll0x1hUIsBQSgc3b =j1mC