Use static_cast to convert void pointers back to other pointers, just revert them back to the same type that was originally used. No conversion is required to convert to a void pointer.
This works for any type of pointer, including type pointers from stdlib. (Technically, any pointer to an object type, but this is what is meant by "pointers", other types of pointers, such as pointers to data elements, require qualification.)
void func(void *d) { std::string &s = *static_cast<std::string*>(d);
source share