Difference between std :: bind and boost :: bind with polymorphism

I have a derived class from which I bind a virtual function that I did not override in this class, so I hope to name one from the parent class.
It works fine with boost (1.55), but if I switch to std :: bind from C ++ 11, it will refuse to compile with

error C2100: illegal indirection 1> function (1152): see the link to the function template instance '_Rx std :: _ Pmf_wrap <_Pmf_t, _Rx, _Farg0, _V0_t, _V1_t, _V2_t, _V3_t, _V4_t, _V5_t,> :: operator ( ) (_ Wrapper &) const 'compiles 1> with 1> [1> _Rx = bool, 1> _Pmf_t = bool (__thiscall Base :: *) (void), 1> _Farg0 = basic, 1> _V0_t = std :: _ Nil, 1> _V1_t = std :: _ Nil, 1> _V2_t = std :: _ Nil, 1> _V3_t = std :: _ Nil, 1> _V4_t = std :: _ Nil, 1> _V5_t = std :: _ Nil, 1> = std :: _ Nil, 1> _Wrapper = Derived 1>]

Here is the minimum code

class Runnable { virtual bool Run() =0;};
class Base : public Runnable { bool Run() {/*do stuff*/ return true;}};
class Derived : public Base {};

Derived d;
std::function<bool()> f = std::bind(&Derived::Run,std::ref(d)); //Do not compile
std::function<bool()> f = boost::bind(&Derived::Run,boost::ref(d)); //compile 

This is not a serious problem, since I can stick to the incentive, but I really would like to know what the difference between the two is.

, , . strustrup , .
?

Ps: VS2012 4,

+4
1

Visual Studio 2012 , std::function std::bind. ; Visual Studio 2010, Visual Studio 2013.

- Boost.Function Boost.Bind .

+2

Source: https://habr.com/ru/post/1529022/


All Articles