Hi! There is a intrusive_ptr.cpp in boost 1.28, but I did not find any doc for that... exept for in the timing . Why? Guessing from the name, intrusive_ptr requires the pointed-to object to store the reference count or something like that, doesn't it? And what does anybody think of typedefing std::auto_ptr to boost::single_ptr? Finally I have a suggestion for a new type of smart pointer one could call "notifying_ptr": Sometimes all weak pointing objects need to be notified when the object pointed to is destroyed: e.g. in a game some units are set to attack some building, so they store a weak_ptr to the building, but when that building is destroyed, it would be easier to implement and faster performing, if the units got a message so they can look for a new target, instead of having strong pointers, marking the building as dead, and polling for that state every time the unit does something. It could be quite some time until all units have realized that the building is gone and it really can be released from memory. Regards
From: "nobody"
Hi!
There is a intrusive_ptr.cpp in boost 1.28, but I did not find any doc for that... exept for in the timing .
Why?
Because I haven't written the doc yet. :-)
Guessing from the name, intrusive_ptr requires the pointed-to object to store the reference count or something like that, doesn't it?
True.
And what does anybody think of typedefing std::auto_ptr to boost::single_ptr?
What would the purpose, assuming that you can typedef a template?
Finally I have a suggestion for a new type of smart pointer one could call "notifying_ptr": Sometimes all weak pointing objects need to be notified when the object pointed to is destroyed: e.g. in a game some units are set to attack some building, so they store a weak_ptr to the building, but when that building is destroyed, it would be easier to implement and faster performing, if the units got a message so they can look for a new target, instead of having strong pointers, marking the building as dead, and polling for that state every time the unit does something. It could be quite some time until all units have realized that the building is gone and it really can be released from memory.
Yes, this might be useful. It requires the ability to enumerate all pointers to a given object, which the current implementation doesn't provide. I'm not yet sure whether this should be "left to the reader" or be a part of the library.
Peter Dimov wrote:
Because I haven't written the doc yet. :-)
;-))) I was assuming this was some sort of old code I was reading, because it is the most straight forward version of a smart pointer I could think of. Well... it seems to be (part of) the future then.
typedefing std::auto_ptr to boost::single_ptr? What would the purpose, assuming that you can typedef a template?
Having everything in one namespace with a uniform naming scheme... auto_ptr doesn't say much, does it?
notifying_ptr Yes, this might be useful. It requires the ability to enumerate all pointers to a given object, which the current implementation doesn't provide. I'm not yet sure whether this should be "left to the reader" or be a part of the library.
No, no ;) Very much of boost as well as stl is very short "trivial"
code with only one purpose: Make it a standard everybody should at least
have heard of.
And I don't think this one is soooo easy to do as a simple "reader"; I
guess a good implementation would use bind so it does not have to send
some generic "notify" message. I wouldn't even know if I sould store the
vector
participants (2)
-
nobody
-
Peter Dimov