Article View: comp.std.c++
Article #3131Re: Why no allocator-specific delete?
From: James Kanze US/ESC 60/3/141 #407...
Date: Mon, 29 Jan 1996 10:41
Date: Mon, 29 Jan 1996 10:41
55 lines
3202 bytes
3202 bytes
In article <4e85k6$b04@noc.tor.hookup.net> mtimmerm@microstar.com
(Matt Timmermans) writes:
|> (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.
The most common usage of placement new is simply to invoke the
constructor on an arbitrary block of memory. Since the destructor can
be invoked directly, there is no need for a corresponding placement
delete.
Another potential use of placement new is that described in the
standard: adding a parameter to modify error handling.
Finally, if you really are using the placement to pass information
concerning which arena to use, presumably each arena has a distinct
address range, so you can overload operator delete to test the address
range and choose the correct arena. In this case, it is a bit of a
bother that you can no longer get at the original operator delete, so
you have to overload the normal operator new too. (Luckily malloc is
still available.)
|> 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.
I don't understand the problem. My containers all contain actual
objects, and not just pointers.
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils, itudes et rialisations en logiciel orienti objet --
-- A la recherche d'une activiti dans une region francophone
---
[ 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:
<KANZE.96Jan29095513@slsvewt.lts.sel.alcatel.de>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM> <4e85k6$b04@noc.tor.hookup.net>Show Full Headers
Complete Article Headers
From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) Message-ID: <KANZE.96Jan29095513@slsvewt.lts.sel.alcatel.de> X-Original-Date: 29 Jan 1996 08:55:12 GMT Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 29 Jan 96 10:41:59 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Re: Why no allocator-specific delete? In-Reply-To: mtimmerm@microstar.com's message of 25 Jan 96 16:01:45 GMT Organization: SEL References: <4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM> <4e85k6$b04@noc.tor.hookup.net> Apparently-To: std-c++@ncar.ucar.edu X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMQyki+EDnX0m9pzZAQEJ3QGAl6x9CcmlbjIxxoSNLvKl6JrSjLRljrAy VDF1UmCbtpo20Woi+3kSKAsyCODmr7eY =h0C4