 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Frank Bergemann Guest
|
Posted: Tue Jun 05, 2012 7:53 pm Post subject: Effective C++, 2nd edition, item #10 "write operator delete |
|
|
I was going to use (and extend) the described mechanism for managing
dedicated objects - representing unix processes - in shared memory for
use in a fork()-based multi-process model (for process
synchronization, fork()-based because i've to use a non-threadsafe
library). However when adding the mechanism i was thinking: "Well, the
issue #10 deals properly with new/delete for Airplane. But the payload
is in AirplaneRep. And there is no such memory mgt for that class. The
c'tor for Airplane will have to use some
Airplaine::Airplane(...)
: rep(new AirplaneRep(...)
{ ...};
So i am lost trying to hold the "real" data in shared memory.
Okay, i will drop this approach and use placement new instead.
But i wonder about the example in item #10.
What's the use in sophisticated memory mgt for a "cheshire cat" class?
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
red floyd Guest
|
Posted: Wed Jun 06, 2012 4:36 am Post subject: Re: Effective C++, 2nd edition, item #10 "write operator del |
|
|
On 6/5/2012 12:53 PM, Frank Bergemann wrote:
| Quote: | I was going to use (and extend) the described mechanism for managing
dedicated objects - representing unix processes - in shared memory for
use in a fork()-based multi-process model (for process
synchronization, fork()-based because i've to use a non-threadsafe
library). However when adding the mechanism i was thinking: "Well, the
issue #10 deals properly with new/delete for Airplane. But the payload
is in AirplaneRep. And there is no such memory mgt for that class. The
c'tor for Airplane will have to use some
Airplaine::Airplane(...)
: rep(new AirplaneRep(...)
{ ...};
So i am lost trying to hold the "real" data in shared memory.
Okay, i will drop this approach and use placement new instead.
But i wonder about the example in item #10.
What's the use in sophisticated memory mgt for a "cheshire cat" class?
This is not what Item #10 is about. Operator new() and operator |
delete() can be overridden globally, or on a per-class basis.
Item 10 simply says, if you override operator new, then you need
to provide an operator delete as well.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group
|