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. */