Article View: comp.std.c++
Article #1932Re: Why not op delete(void* v&,size_t);?
From: Don Organ
Date: Fri, 08 Sep 1995 20:52
Date: Fri, 08 Sep 1995 20:52
68 lines
2814 bytes
2814 bytes
tblancha@evolving.com (Todd Blanchard) writes:
> This is common in C:
>
> #define free(X) { free(X); X=0; }
>
> You could do something similar in C++ as:
>
> void operator delete (void*& p, size_t s)
> {
> ::delete p;
> p = 0;
> }
>
> but the standard definition is:
> void operator delete(void* p, size_t);
>
> Why is that?
> --
> -----------------------------------------------------------------------
> Todd Blanchard tblancha@evolving.com
> Evolving Systems Inc. VOX: (303) 689-1798
> FAX: (303) 689-1399
> "Never underestimate the power of stupid people in large groups."
stephen.clamage@eng.sun.com (Steve Clamage) writes:
> In article lvf@citadel.evolving.com, tblancha@evolving.com (Todd Blanchard) writes:
> >
> >Designers could try telling the truth once in awhile and say something like:
> >"Nobody thought of it early enough and its too late to change now."
> >Which I suspect is more likely.
>
> Except in this case, the approach had been discussed years ago and rejected
> as not a good idea. See D&E, for example.
>
> I recommend that you do a minimum of research before accusing others
> of laziness and mendacity.
>
> ---
> Steve Clamage, stephen.clamage@eng.sun.com
I think the original question may have been slightly confusing.
It showed
void operator delete (void*& p, size_t s)
I think it was intended to be
void operator delete (void*& p)
In D&E I found an answer to why the 2nd argument to delete is illegal.
What is the answer to the question:
why the 1st (only) argument must be void* and can't be void*&?
From the original posting, the intention seems clear to allow the
delete operator to assign 0 to the pointer passed as the
argument (i.e. the pointer must be passed by reference, not by value).
I did a minimum of research - but didn't find an answer in D&E.
(And I've lost my ARM!)
Could someone point me to the exact page in D&E (or ARM or anywhere)
or post a rationale?
Thanks.
Don Organ
[ 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:
<9509082051.AA01889@dawn.megaeng>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: dorgan@megatest.com (Don Organ) Newsgroups: comp.std.c++ Subject: Re: Why not op delete(void* v&,size_t);? Date: 8 Sep 1995 20:52:43 GMT Organization: ? Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <9509082051.AA01889@dawn.megaeng> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text To: std-c++@ncar.ucar.edu Content-Length: 2077 X-Lines: 64 Originator: clamage@taumet