Template argument deduction from member functions...

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top