How can I get a void * pointer from std :: any I'm trying to do something like this:
... std::any& value = ... ... } else if (value.type() == typeid(std::string)) { ... } else { Parent* obj; If (obj = dynamic_cast<Parent*>(value.getPointer) { obj->something(); ... } else { logE("can't convert value:" << value.type().name(); } } ...
void *, you won't be able to pass it todynamic_cast. In general, the presence ofany,typeidanddynamic_castin one place is very suspicious. - VTTanyclassParentand if successful, execute its method - Alexey Gutnikstd::any_cast? - VTTParent, I do not want to do a check for each of them.any_castdoes not roll. He simply comparestype_idand castes in the necessary type. He is not downcast-it? Yes, and it seems like you cannot checktype_idfor inheritance - Alexey Gutnik