读书人

error C2661: “std:vectorlt;Tygt;resize

发布时间: 2013-03-10 09:38:39 作者: rapoo

error C2661: “std::vector<_Ty>::resize”: 没有重载函数接受 0 个参数
本来运行好好的,没有错误,结果,我把opencv2.1换成opencv2.0,所有设置都改好后,第26行出现错误:
error C2589: “(”: “::”右边的非法标记
error C2143: 语法错误 : 缺少“)”(在“::”的前面)
error C2661: “std::vector<_Ty>::resize”: 没有重载函数接受 0 个参数
1> with
1> [
1> _Ty=std::pair<cv::Point,float>
1> ]
error C2059: 语法错误 : “)”

inline std::vector< std::pair<Point, float> > getVotes() const
{
if(buffered.size() > 0)
return buffered;

std::vector< std::pair<Point,float> > ret;
float avg = static_cast<float>(numPos)/(MapSize*MapSize);

for(int x = 0; x < MapSize; x++)
{
for(int y = 0; y < MapSize; y++)
{
float val = voteMap.at<float>(y, x);
if(val > avg)
{
int voteX = static_cast<int>(round((x - MapSize/2.0f) * MapStep));
int voteY = static_cast<int>(round((y - MapSize/2.0f) * MapStep));

ret.push_back( std::make_pair( Point(voteX, voteY), probPos * val / numPos ));
}
}
}

std::sort(ret.begin(), ret.end(), sortVotesDesc);
//ret.resize( std::min(10, (int)ret.size()) );
ret.resize( std::min( 10, (int)(ret.size()) ) );
buffered = ret;

return ret;
}
};

[解决办法]
std::min外面加个括号试试(std::min)
如果这样改能正常,那就是std::min和库里面的min宏名字冲突了

读书人网 >C++

热点推荐