Typedef equivalence in function arguments
- by Warren Seine
Hi guys,
The question is kind of hard to ask without an example so here it is:
#include <vector>
struct O
{
};
struct C
{
template <typename T>
void function1(void (C::*callback)(const O*));
template <typename T>
void function2(void (C::*callback)(const typename T::value_type));
void print(const O*);
};
int main()
{
C c;
c.function1< std::vector<O*> >(&C::print); // Success.
c.function2< std::vector<O*> >(&C::print); // Fail.
}
The error that I am given is:
error: no matching function for call to ‘C::function2(void (C::*)(const O*))’.
Basically, the only difference between calls is that in function2, I'm more generic since I use the typedef std::vector<O*>::value_type which should resolve to O*, hence similar to function1.
I'm using G++ 4.2.1 (I know it's old), but Comeau confirms I'm wrong.
Why does the compilation fail?