The question came up once (but i can't find the mail - i _think_ it was from Anton?) about how to avoid passing a NULL pointer to a bound function. i didn't know of a generic way to do it because NULL is not always semantically illegal (and thus it is, for conversion purposes, generically legal).
We've actually had a solution for a while now, but i didn't realize it: the overloading/argument-validation templates can be used for that purpose, by simply applying a predicate which checks if the value (A) has the right type and (B) is not NULL. If the predicate fails, the bound function will not be called.
The basic approach is shown here:
i haven't yet written a concrete predicate to perform the NULL check, but if such a use case comes up it'll be easy to add one. (This would be useful when binding puts() or strlen()).
PS: i'm still looking for a new name for the PredicatedXyz family of templates. See the above (rather ugly, but functionally quite cool) example and you'll understand why.
--
----- stephan beal
http://wanderinghorse.net/home/stephan/