• Advertisement
Sign in to follow this  

Smart pointers : boost / Loki / RYO

This topic is 4801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Maybe somewhat of a banal topic, but anyway... There is a plethora of smart pointer implementations available - auto_ptr, boost's and loki's various flavours, or you could even roll-your-own. Obviously your usage of each is dependent upon when, where and how you are using them, but just wondering : what do YOU use as your stock-in-trade smart pointer, the one you reach for by default? And why - what makes that flavour the one you prefer as a default implementation? Regards, Jim.

Share this post


Link to post
Share on other sites
Advertisement
I usually reach for std::auto_ptr first, then boost::shared_ptr if that doesn't fit. If neither works out then I'll grab a loki pointer implementation, but it's fairly rare for that to happen. Basically, my order of preference is defined by the number of different ways I can screw things up. It's fewest with std::auto_ptr, but std::auto_ptr isn't very flexible.

Share this post


Link to post
Share on other sites
I have never actually had a case where I used auto_prt ... I still just do it myself if it's that easy (which maybe I need to change, would probably clean my code up a bit to use auto_ptr in the special cases where it applies) ...

boost smart_ptr is the only one I've used ... just because boost is the only library I install by default on every c++ compiling computer I use.

I also have a "roll your own" pair of classes I wrote 3-4 years ago, which I used in my last project as well - but that's probably just habit, cause I know them so well.

Share this post


Link to post
Share on other sites
boost:shared_ptr mostly, though I'd probably use the Loki ones if template typedefs ever became standard.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement