错误:调用没有匹配的函数'分钟(长unsigned int类型和放大器;,无符号整型和放大器;)“ [英] error: no matching function for call to ‘min(long unsigned int&, unsigned int&)’

查看:248
本文介绍了错误:调用没有匹配的函数'分钟(长unsigned int类型和放大器;,无符号整型和放大器;)“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Ubuntu 12.04 - 64位。我和提升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);
}

我得到这个错误:

I get this error:

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 ::分钟 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
    


  • 这篇关于错误:调用没有匹配的函数'分钟(长unsigned int类型和放大器;,无符号整型和放大器;)“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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