Experimental Physics and
| |||||||||||||||||
|
Hey Jeff, I think the GDD smart pointer is a little bit weird, in a common way to use smart pointers as follows: { smartGDDPointer sGDDPtr=new gdd(); } the newly allocated gdd object isn't freed when sGDDPtr is out of scope. If you want to use smartGDDPointer as a normal smart pointer, you must place a line code immediately below the new operator, like this: { smartGDDPointer sGDDPtr=new gdd(); //The reference count of the newly created gdd object is actually 2 at this time. //The gdd() places the reference count to 1, and the assignment operator increase it to 2. sGDDPtr->unreference(); } We see that smartGDDPointer is the intrusive type of smart pointer, the gdd has one reference count member and two functions reference() and unreference(). In my opinion, the init() called by the gdd constructors shouldn't place the reference count to 1, the reference counting shouldn't be carried out by gdd itself. smartGDDPointer is the manager of the gdd object and the only guy who can operate the reference() and unreference() on gdd object Thanks, Alex
| ||||||||||||||||
ANJ, 02 Feb 2012 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |