错误:没有匹配函数调用'min(long unsigned int& unsigned int&)' [英] error: no matching function for call to ‘min(long unsigned int&, unsigned int&)’

查看:1467
本文介绍了错误:没有匹配函数调用'min(long unsigned int& unsigned int&)'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ubuntu 12.04 - 64位。我用boost 1.46,1.48,1.52和
测试了它gcc 4.4和4.6
当我尝试编译:

I'm using ubuntu 12.04 - 64 bits. I tested it with boost 1.46, 1.48, 1.52 and gcc 4.4 and 4.6 When I try to compile:

while (m_burstReqBeatsRemain) {
                if (m_burstReqAddress % m_dramRowSize == 0) {
                    m_admRequestQueue.push_back(adm_request());
                    adm_request &req = m_admRequestQueue.back();
                    req.address = m_burstReqAddress;
                    req.command = tlm::TLM_READ_COMMAND;
                    //call to min function
                    req.readLen = std::min(m_burstReqBeatsRemain * sizeof(Td), m_dramRowSize);
                }
                m_burstReqBeatsRemain--;
                m_burstReqAddress += sizeof(Td);
                m_ocpTxnQueue.push_back(m_ocpReq);
}

我收到此错误:

no matching function for call to ‘min(long unsigned int&, unsigned int&)
from /usr/include/c++/4.6/bits/stl_algobase.h*

注意:使用ubuntu 12.04 32位工作正常

Note: with ubuntu 12.04 32 bits works fine

任何想法如何解决这个问题?

Any idea how I can fix this?

推荐答案

std :: min T 上的函数模板,它是函数的两个参数的类型。但你似乎传递不同类型的函数参数,依赖于从函数参数中扣除模板参数,这是不可能的。

std::min is a function template on T which is the type of both parameters of the function. But you seem to pass function arguments of different type, and rely on template argument deduction from function arguments, which is not possible.

修复是:


  • 要么不依赖模板参数扣除,而要明确提及模板参数:

  • Either don't rely on template argument deduction, instead explicitly mention the template argument:

std::min<unsigned long>(ulongarg, uintarg); //ok
     //^^^^^^^^^^^^^^^ 
     //don't rely on template argument deduction
     //instead pass template argument explicitly.


  • 或传递相同类型的函式参数:

  • Or pass function arguments of same type:

    std::min(ulongarg, static_cast<unsigned long>(uintarg)); //ok
                      //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      //pass both arguments of same type
    


  • 这篇关于错误:没有匹配函数调用'min(long unsigned int&amp; unsigned int&amp;)'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆