Boost logo

Boost Users :

Subject: [Boost-users] How to return a Null pointer for shared_ptr
From: hce (webmail.hce_at_[hidden])
Date: 2009-12-01 20:12:33


I defined a shared_ptr in to a map table. How can I return a NULL
pointer in a function to search the table if it is not found as
following example?

typedef shared_ptr<int> IntPtr;
typedef std::map<std::string IntPtr> MapTable;

MapTable mt;

IntPtr search(const std::string& key)
    MapTable::const_iterator it = mt.find(key);
    if (it == mt.end()) {
         return NULL; // can't compile it??
    return it->second;

Thank you.

Kind regards,


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at