Smart_ptr vs. Shared_ptr

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Smart_ptr vs. Shared_ptr

      Hi guys!

      What is the diff. between a Smart_ptr and a Shared_ptr?
      From what I can see/understand from the code I've viewed thus far, there is not much a difference, am I right?

      Addition: Both implement 'reference counting', both handle their own construction/destruction, and both can be used in a container.


      Me.
      Confused and dazed.

      The post was edited 1 time, last by Sabrina ().

    • RE: Smart_ptr vs. Shared_ptr

      Are you talking about boot's shared_ptr class? As far as I know, there isn't a smart_ptr class in boot. smart_ptr.hpp is a header that #include's various smart pointer headers, including shared_ptr.hpp.

      -Rez
    • RE: Smart_ptr vs. Shared_ptr

      The difference is that one exists and one doesn't. ;) shared_ptr is a smart pointer implementation.

      -Rez
    • My understanding that "smart pointer" was a general title for the section of "pointer wrapping classes", such as boost::shared_ptr, boost::scoped_ptr, and std::auto_ptr. Generally, "smart pointers" use a variety of techniques, though I am not aware of a specific implementation of a smart_ptr class, nor the technique it would use.

      Apologies if this is information that you already know.
      Feel you safe and secure in the protection of your pants . . . but one day, one day there shall be a No Pants Day and that shall be the harbinger of your undoing . . .
    • Smart_ptr was used in the first edition of the book's source code, and was a basic smart pointer class. shared_ptr, from the Boost C++ library, is a better implrmentation of a smart pointer.

      Smart pointers have code behind them to destroy objects when nothing is pointing at them anymore - giving a programmer insurance against leaking memory.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Originally posted by mrmike
      Smart_ptr was used in the first edition of the book's source code, and was a basic smart pointer class.


      Ahhh, that makes sense. Now I see where the confusion is. I really should read the first edition.....

      -Rez
    • Well - let's just say I'm glad I wrote the 2nd Edition and leave it at that!
      Mr.Mike
      Author, Programmer, Brewer, Patriot