How to return a NULL to boost::sharedPtr

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AJTech
    New Member
    • Dec 2010
    • 2

    #1

    How to return a NULL to boost::sharedPtr

    I am having something like

    typedef boost::shared_p tr<myClass1> MyClass1Ptr;

    MyClass1Ptr Function( int key,std::map<in t,MyClass1Ptr> _Map)
    {
    std::map<int,My Class1Ptr>::ite r i = _Map.find(key)
    if(i = _Map.end())
    {
    return NULL;
    }
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    A shared pointer is an object that manages a pointer to a dynaically allocated object.

    You do not put NULL in a shared pointer object. Instead you delete the shared pointer. That will call the shared pointer destructor where the reference count may or may not require the managed object to be deleted.

    Comment

    Working...