0
typedef std::shared_ptr<object> RObject;

class RObjectbase : public std::enable_shared_from_this<RObjectbase>
{
     public:
     virtual ~RObjectbase () {}
};

class RObject: public RObjectbase
{
    //some functions
};

class ABC
{
    public:
        String key;
        RObject object;
};

typedef std::list<ABC> listAbc;
typedef std::map<String, listAbc::iterator> KeyIterMap;

listAbc _list;
KeyIterMap _map;

RObject getObject()
{

    KeyIterMap::iterator f = _map.find(key);    
    if (f == _map.end())
    {
        // Key not found
        //
        return NULL;
    }

    listAbc::iterator iter = f->second;
    const RObject& object = iter->object;

    _list.push_front(ABC());
    ABC& abc = _list.front();
    abc.key = key;
    abc.object = object;

    f->second = _list.begin();

    _list.erase(iter);

    return object;
}

/*While debugging at the point of "return object" in function "getObject" I have 1 shared-ptr and 2 weak-ptr in ios while in android devices I got expired shared-ptr and 2 weak-ptr , which crashes my program. This code worked fine when I am creating object using make_shared(iter->object) but again this is not required in ios. Any help is appreciated. */

kiri
  • 9
  • 1
  • This code worked fine when I am creating object using make_shared(iter->object) but again this is not required in ios. – kiri Apr 25 '16 at 14:42
  • Please edit your question to include this additional information instead of adding a comment. – buczek Apr 25 '16 at 14:44

0 Answers0