I was looking at some code that uses Boost.Function and have a question about how code can be written to allow assignment to NULL. I tried to track down the corresponding Boost code, but was unable to. Basically, what makes this possible?
boost::function<void()> func;
func = NULL;
EDIT: The following doesn’t compile for me though, so how do they prevent this too?
func = 1;
By operator overloading with pointer parameter. From boost sources:
This doesn’t mean that “func” itself is NULL, indeed you can access its own functions. Following code compiles and doesn’t crash.