Smart pointers : boost / Loki / RYO

Started by
3 comments, last by Si0n 19 years, 3 months ago
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.
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.
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.
boost:shared_ptr mostly, though I'd probably use the Loki ones if template typedefs ever became standard.
I use one that I designed myself. ;)

This topic is closed to new replies.

Advertisement