简体   繁体   English

没有匹配的函数来调用'const RadioMap :: comp'类型的对象

[英]No matching function for call to object of type 'const RadioMap::comp'

struct comp
{
    bool operator()(const CartesianLocation& loc1, const CartesianLocation& loc2)
    {
        //Compare the 2 locations, return true if loc1 is less than loc2
        return loc1.id < loc2.id;
    }
};

std::map<CartesianLocation, std::list<RadioSignal<RadioDevice>>, comp> radioMap;

public:
  void add(CartesianLocation location, std::list<RadioSignal<RadioDevice>> observedSignals) {
    radioMap[location] = observedSignals;
  }

On this line radioMap[location] = observedSignals; 在这一行上, radioMap[location] = observedSignals; I am getting below error: 我得到以下错误:

No matching function for call to object of type 'const RadioMap::comp' on this line if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first)) 如果(__tree_.value_comp()。key_comp()(__ k,__nd-> __ value _.__ cc.first))在此行上没有用于调用'const RadioMap :: comp'类型对象的匹配函数

Any idea where I may be wrong? 知道我哪里错了吗?

You are missing the const qualifier on the call operator of comp : 您缺少comp的调用运算符上的const限定词:

bool operator()(const CartesianLocation& loc1, 
                const CartesianLocation& loc2) const { }
                                               ^^^^^

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有匹配的函数可以调用&#39;const std :: __ 1 :: packaged_task类型的对象 <void ()> &#39;,但`std :: is_const`返回false - No matching function for call to object of type 'const std::__1::packaged_task<void ()>', but `std::is_const` returns false 没有匹配的函数来调用A :: A(MainWindow * const) - no matching function for call to A::A(MainWindow * const) 错误:没有匹配函数可调用const - error: no matching function for call to const No Matching函数使用const参数调用模板化函数 - No Matching function call to templated function with const parameters 缺少“ const”会导致“错误:没有匹配的调用函数” - missing “const” leading to “error: no matching function for call to” 没有匹配的函数来调用&#39;bind( <unresolved overloaded function type> ,const std :: _ Placeholder &lt;1&gt;&,int *) - no matching function for call to ‘bind(<unresolved overloaded function type>, const std::_Placeholder<1>&, int*) 在 const 对象上调用非常量函数 - Call non-const function on a const object 没有匹配的函数要求对const char *进行模板专业化 - No matching function call for template specialization of const char* 没有匹配的调用函数:const指向指针的指针 - No matching function for call : const pointer to pointer 没有匹配函数可用于调用“哈希”类型的对象 <char"> &#39;(Stroustrup书本钻) - No matching function for call to object of type 'hash<char">' (Stroustrup Book Drill)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM