
24 Aug
2004
24 Aug
'04
1:20 p.m.
Vladimir Prus wrote:
I wonder if shared_ptr can hold a pointer to a function.
Yes, it can.
I've just tried the following program:
#include <boost/shared_ptr.hpp> using namespace boost;
int main() { extern int* object; boost::shared_ptr<int> p(object);
extern void (*function)(); boost::shared_ptr<void ()> p2(function);
return 0; }
The first initialization, of course, work. The second produces a lots of errors. Do I miss something obvious?
"Requires: the expression 'delete p' shall be well-formed and its behavior defined." Try a null deleter.