Your problem is that const typename T::value_type is basically typename T::value_type const , which resolves to O* const , which obviously does not match const O* (which would be O const * when writing the ptr declaration for type (more useful to find out this behavior)).
As for archiving, what you want depends on what you want. If you want, you can use boost type_traits or tr1 type_traits to remove the pointer, add const and make it a pointer again as follows:
template <typename T> void function2(void (C::*callback)(typename boost::add_pointer<typename boost::add_const<typename boost::remove_pointer<typename T::value_type>::type>::type>::type));
Using tr1 instead of boost should basically be a replacement for boost:: with std::tr1:: .
However, I would not call it a useful generalization, so you may need to be overworked if you really want to go that route. Personally, I would either use something like boost function , or free functions as callbacks, the first of which would allow much greater flexibility in what can be used as callbacks (free functions, functors, member functions), and later, at least it makes it easy to create a second function that appropriately converts the arguments (that is, if you want to use a function that takes const O* as a parameter, you can create one that takes O* and calls the first with that parameter and uses him how about brotherly call).
source share