I have learned what C++ I know in order to build a link to rdkit from my own system, so the following may be more of a general coding question than anything rdkit-specific.
I am looking at the python wrappers, and I see many functions return a ROMol object by static casting the RWMol pointer to a pointer of its base class. I believe this line <https://github.com/rdkit/rdkit-orig/blob/master/Code/GraphMol/Wrap/rdmolfiles.cpp#L56> shows an example. First, what is the purpose of this upcasting? MolToSmiles could just return a python RWMol object, if I read the code correctly. Is this done as a means of preventing users from shooting themselves in the foot, by making them create an RWMol first before accessing the add/delete/replace methods? Second, I see instances in the python wrappers where the ROMol objects are downcast to RWMol using static_cast, such as is done on this line <https://github.com/rdkit/rdkit-orig/blob/master/Code/GraphMol/Wrap/MolOps.cpp#L129> for the SanitizeMol wrapper. Is static_cast'ing from a ROMol to a RWMol always safe? What I know about type inheritance in C++ is minimal (it can fit in this email), but I did not know you could do this. In reading up on this, I would think you would have to dynamic_cast and check the result. Thanks, Jason
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss