W
werasm
Hi all,
I've found this little piece of code that surprised me when it did not
compile:
struct B1{ void x(); };
struct B2{ void y(); };
struct C : B1, B2{ using B1::x; };
template <class T>
T foo( void (T::*mf)() );
int main()
{
typedef void (C::*Tmf)();
Tmf mf = &C::x;
foo( &C::x ).y(); //Fails - B1 deduced
foo( mf ).y(); //OK
return 0;
}
It surprised me that B1 was deduced at T instead of C. Could anyone
perhaps enlighten me from the standard.
Kind regards,
Werner
I've found this little piece of code that surprised me when it did not
compile:
struct B1{ void x(); };
struct B2{ void y(); };
struct C : B1, B2{ using B1::x; };
template <class T>
T foo( void (T::*mf)() );
int main()
{
typedef void (C::*Tmf)();
Tmf mf = &C::x;
foo( &C::x ).y(); //Fails - B1 deduced
foo( mf ).y(); //OK
return 0;
}
It surprised me that B1 was deduced at T instead of C. Could anyone
perhaps enlighten me from the standard.
Kind regards,
Werner