Re: Rationale for intrusive_ptr?
Well to answer my own question, I think, it can be used when you already have something that is reference counted and you want to manage it yourself. Also in places where new and delete aren't the correct actions. Or when you need something with less resource requirements than shared_ptr. For example, when multi-threading is turned on, shared_ptr asks for a mutex. Intrusive_ptr leaves that up to you. Am I getting close here? I didn't think about using it when you have a function that takes a shared_ptr but you need to pass in this. I dunno, I tend to use shared_ptr sparingly. If I don't need a shared_ptr, I don't ask for one on the interface to a function. That way the user can pass in a naked pointer or a shared_ptr::get(). I make sure to document what the function does (and does not do) with the input pointer though. Thanks. __________________________________ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250
--- At Tue, 1 Feb 2005 16:18:14 -0800, Brian Neal wrote:
I didn't think about using it when you have a function that takes a shared_ptr but you need to pass in this.
Before Boost I had my own version of shared pointer that used an intrusive method. This was the most interesting part of using the intrusive method. The intrusive method allows you to move from shared_ptr to raw pointer and back to shared pointer. This is not a common application of shared_ptr which is why the non-intrusive version is so popular. But when you need intrusive, you know you need it. ...Duane
participants (2)
-
Brian Neal
-
Duane Murphy