This crashes: #include <functional> void (*p)(...) = nullptr; std::function< void() > f = p; int main() { try { f(); } catch ( std::bad_function_call & ) {} } The problem is missing overloads of std::function::__not_null. On a related note, I'm working on a std::function extension. Is there no facility for function signature decomposition?
Looks like __not_null is missing quite a few overloads. Patch up for review as D9873 (http://reviews.llvm.org/D9873).
I created an account and left a comment in the review, but it still says "waiting for moderator approval." -- A lot of work can be saved by ignoring the function signature. template<class _R2, class _Cp> static bool not_null(_R2 _Cp::*__p) {return __p;} -- Actually, you should only need three overloads: one for pointers (including varargs function pointers), one for PTMs (effectively PTMFs but ignoring the function aspects), and the one which is always true.
Fixed in r245335.