lundi 10 janvier 2022

how to cast from intrusive_ptr

I have to get a child class pointer that is wrapped in boost's intrusive_ptr from intrusive_ptr<parent_class> returned by a class function.

class parent{...}
class child: public parent{...}


intrusive_ptr<parent>  GetElementPtr(ElementID Id)  {...};



/* in some other cpp file*/

ElementID XXX = ...;
intrusive_ptr<child> childElem = GetElementPtr(XXX); // cannot do so like this
  

Aucun commentaire:

Enregistrer un commentaire