多于一个结构匹配参数列表

More than one construction matches argument list

本文关键字:参数 列表 于一个 结构      更新时间:2023-10-16

我尝试用VS2010编译它

long long min = std::numeric_limits<int>::min();
unsigned long long max = std::numeric_limits<int>::max();

std::bitset<64> minimal(min);//here I'm getting the error  
cout << "minimal: " << minimal;  
error:  
error C2668: 'std::bitset<_Bits>::bitset' : ambiguous call to overloaded function  
1>          with  
1>          [  
1>              _Bits=64  
1>          ]  
1>          c:program filesmicrosoft visual studio 10.0vcincludebitset(136): could   be 'std::bitset<_Bits>::bitset(_ULonglong)'  
1>          with  
1>          [  
1>              _Bits=64  
1>          ]  
1>          c:program filesmicrosoft visual studio 10.0vcincludebitset(127):   or       'std::bitset<_Bits>::bitset(int)' 
1>          with  
1>          [  
1>              _Bits=64  
1>          ]    
1>          while trying to match the argument list '(__int64)'    

为什么?显然,这个参数是long long类型,构造函数应该用于该类型。我不明白这是怎么回事

我不认为long long是您在该列表中给出的选项之一。我只看到:

  • _ULonglong
  • int
  • _int64

为什么不将min转换为unsigned long long,看看是否可以修复它。或者更好的是,使用 unsigned类型—您是否有可能在中使用具有负数元素的 bitset ?: -)

这是VC2010中的一个错误,它已在VC2011中修复。

这里是Bug报告注意这里的注释