std::bind 和 boost::bind 多态性之间的区别

Kir*_*xas 5 c++ boost-bind stdbind c++11 visual-studio-2012

我有一个派生类,从中绑定了一个我没有在此类中重写的虚函数,因此我希望调用父类中的一个。
它与 boost (1.55) 配合得很好,但如果我从 C++11 切换到 std::bind,它会拒绝使用

错误 C2100:非法间接寻址 1> 功能(1152):请参阅函数模板实例化 '_Rx std::_Pmf_wrap<_Pmf_t,_Rx,_Farg0,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,>::operator ()( _Wrapper &) const' 正在编译 1> with 1> [ 1> _Rx=bool, 1> _Pmf_t=bool (__thiscall Base::* )(void), 1> _Farg0=Base, 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=派生 1> ]

这是最小代码

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 
Run Code Online (Sandbox Code Playgroud)

这不是一个主要问题,因为我可以坚持使用 boost,但我真的很想知道两者之间有什么区别。

我在这里检查了几个问题,但我不认为它与有什么关系。在这里也检查了 stroustrup 的网站,但我没有看到任何可以解释这种行为的内容。
我在这里缺少什么?

PS:我使用VS2012 Update 4,如果这可以帮助

Col*_*nee 3

Visual Studio 2012 有很多与std::function和相关的错误std::bind。这是其中之一;该代码可在 Visual Studio 2010 和 Visual Studio 2013 中运行。

最好的选择是单独使用 Boost.Function 和 Boost.Bind。