Thread View: comp.std.c++
2 messages
2 total messages
Started by Michael Feathers
Wed, 06 Jan 1993 03:20
Overloading operator delete
Author: Michael Feathers
Date: Wed, 06 Jan 1993 03:20
Date: Wed, 06 Jan 1993 03:20
25 lines
1371 bytes
1371 bytes
I discovered the hard way a while ago that the operator delete can not be overloaded in C++. I've read the annotation in the ARM and I can not say that I agree with the reasoning. One example given for overloading operator new involves using another arena for allocation. But how will this memory be deallocated? Doesn't the possibility of using the global delete accidently make the absence of an overloadable delete at least as "hazardous" as allowing it? I understand that there are many applications in which programmers may not be concerned with reclaiming memory, but aren't there enough to justify being able to use operator delete symmetrically with operator new without resorting to the work around discussed in the ARM? The work around that I've choosen involves using a set of malloc/free type functions since I have no means of using an overloaded delete symmetrically with an overloaded new. Michael Feathers [feathers@fiu.edu]
Re: Overloading operator delete
Author: Michael Feathers
Date: Wed, 06 Jan 1993 12:12
Date: Wed, 06 Jan 1993 12:12
37 lines
1987 bytes
1987 bytes
I am the author of this article. I just realized that I did not explain thoroughly. In article <C0Ex9D.Ct7@fiu.edu> feathers@serss0 (Michael Feathers) writes: > >I discovered the hard way a while ago that the operator delete can not be >overloaded in C++. That is, overload operator delete with the placement syntax. We can provide extra versions of operator new with an arbitrary number of additional arguments, but there can be no additional arguments to delete other than those specified in the ARM. I don't have the ARM at home with me right now, so I can not recite chapter and verse. >I've read the annotation in the ARM and I can not say that I agree with >the reasoning. One example given for overloading operator new involves using >another arena for allocation. But how will this memory be deallocated? > >Doesn't the possibility of using the global delete accidently make the >absence of an overloadable delete at least as "hazardous" as allowing it? > >I understand that there are many applications in which programmers may not >be concerned with reclaiming memory, but aren't there enough to justify being >able to use operator delete symmetrically with operator new without resorting >to the work around discussed in the ARM? > >The work around that I've choosen involves using a set of malloc/free type >functions since I have no means of using an overloaded delete symmetrically >with an overloaded new. > >Michael Feathers [feathers@fiu.edu] > > Michael Feathers [feathers@fiu.edu]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads