I was playing around with boost::function when I stumbled across the following issue.
typedef int(*IFnPtr2)(Interface*,int,bool&);
IFnPtr2 p = NULL;
boost::function<int(Interface*,int,bool&)> fn; // this is fine
boost::function<IFnPtr2> fn2; // this gives me a compile error
I was wondering why function is behaving differently when used with the type and a typedef that should denote to the same type. It is not a problem for me because I just don’t use the typedef but still I am curious to know why there is a difference.
The compiler I am using is MSVC2010.
Use a function type for the template parameter to
boost::function, not a function pointer type: