Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-08-25 07:12:19

If I have boost::shared_ptr<some_class>, it's possible to cast it to
shared_ptr<void>. But it does not appear to be any way to convert pointer to
function to pointer to void -- just because there's no implicit conversion
from function pointer to void*.

So, when I compile the attached program with g++, I get:

  sp.cpp:22: instantiated from here
   /home/ghost/Work/boost/boost/shared_ptr.hpp:163: error: invalid conversion
   `void (* const)()' to `void*'

Is there any way to make it work? What I'm trying to do is:

- access a function from DLL -- i.e. get shared_ptr<function_type>
- do something with the function
- cast the pointer into shared_ptr<void>

The last pointer will be stored in various places to keep the DLL in memory
until last object which depend on it is destroyed.

I think I can keep shared_ptr<function_type> everywhere, but can
shared_ptr<void> work somehow?


Boost list run by bdawes at, gregod at, cpdaniel at, john at