首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用boost::bind时出现"no match for call“错误

使用boost::bind时出现"no match for call“错误
EN

Stack Overflow用户
提问于 2011-10-04 09:14:14
回答 1查看 4.8K关注 0票数 5

我对boost::bind还是新手,现在移植了一个两年前写于2009年的程序,看到了下面的编译错误。任何解决办法的想法都将不胜感激。

解压cpp文件:

代码语言:javascript
复制
class ClassA {
private:
    cNamespace::Bounds bounds_msg_;

    void boundsHandler(const PublisherPtr& p) { 
        p->publish(bounds_msg_);
    }

    void funcA() {
        node_->advertise<cNamespace::Bounds>("bounds", 10,
              boost::bind(&ClassA::boundsHandler, this, _1));  // <---- Line 445
    }
};

CMake时出错:

代码语言:javascript
复制
/home/userA/ClassA.cpp:445:   instantiated from here
/usr/include/boost/bind/bind.hpp:313: error: no match for call to ‘(boost::_mfi::mf1<void, ClassA, const PublisherPtr&>) (ClassA*&, const ros::SingleSubscriberPublisher&)’

环境:Ubuntu10.10,g++ ( Ubuntu /Linaro 4.4.4-14ubuntu5) 4.4.5

可能不是必需的,但函数advertise的API引用是here,或者:

代码语言:javascript
复制
template<class M >
Publisher   advertise (const std::string &topic, 
                       uint32_t queue_size, 
                       const SubscriberStatusCallback &connect_cb, 
                       const SubscriberStatusCallback &disconnect_cb=SubscriberStatusCallback(),
                       const VoidConstPtr &tracked_object=VoidConstPtr(), 
                       bool latch=false)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-10-04 09:21:50

看起来boost::bind生成的函数对象的调用类型与您绑定的函数的类型不同。

也就是说,使用const ros::SingleSubscriberPublisher&参数调用它,而不是使用预期的const PublisherPtr& p

假设SubscriberStatusCallback是一个boost::function,您应该确保它的参数与您绑定的参数相匹配。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7642359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档