mercredi 4 novembre 2015

Assigning a member function pointer to std::function without mem_fn

I have a member function within class A called doNothing. When I try to assign it to std::function like below:

   std::function< void(A*) > foo =  &A::doNothing;

I am getting compile errors when I am compiling with Vs2012 :

 'std::_Func_class<_Ret,_V0_t>::_Set' : cannot convert parameter 1 from '_Myimpl *' to 'std::_Func_base<_Rx,_V0_t> *

If I assign it like below, I am not having any problems.

std::function< void(A*) > foo =  mem_fn(&A::doNothing);

What seems more strange to me is; if I try the same with GCC 4.7 none of the assignments do not fail.

What is going on with Vs2012 about that?

Aucun commentaire:

Enregistrer un commentaire