c++ - 绑定(bind) shared_ptr::reset - 未找到匹配的重载函数

标签 c++ boost bind shared-ptr

以下代码片段在 Visual Studio 2005(带有 boost 1.34)中有效,但无法在 Visual Studio 2015(带有 boost 1.62)中编译,提示“错误 C2672:‘boost::bind’:未找到匹配的重载函数”

我是不是漏掉了什么?

谢谢!

typedef boost::shared_ptr< int > SProxySharedPtr;
SProxySharedPtr    m_sptr_proxy;

auto a = boost::bind(&SProxySharedPtr::reset, &m_sptr_proxy);

最佳答案

boost::shared_ptr<.>::reset() 是一个重载的成员函数。因此,您必须明确指定要使用的重载:

auto a = boost::bind(static_cast<void(SProxySharedPtr::*)()>(&SProxySharedPtr::reset), &m_sptr_proxy);

关于c++ - 绑定(bind) shared_ptr::reset - 未找到匹配的重载函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41404347/

相关文章:

c++ - boost::Unique_Ptr 对象列表

c++ - 我如何更改 shm_open 路径?

jquery - KineticJS:通过 .on() 监听

javascript - 绑定(bind)和解除绑定(bind)切换

c++ - 基于QWidget的Qt小部件

c++ - 如何在场景中找到一个项目

c++ - C++11 中更优雅的 boost 积累?

c++ - 如何获取QXlsx中一行中已使用的列数

c++ - C++中double/float类型二进制序列化的可移植性

php - 如何从 PHP 绑定(bind) Zorba 中的 XQuery 外部变量?