我想要查找一个结构,其全部成员数据都匹配特定值。
我编写了以下简短的程序:
#include <iostream>
#include <vector>
using namespace std;
struct vlan {
int vlanId;
bool status;
};
vector<vlan> vlanTable;
int main(){
vlan tmp;
tmp.status = true;
tmp.vlanId = 1;
vector <vlan>::iterator flag = find(vlanTable.begin(), vlanTable.end(), tmp);
if ( flag != vlanTable.end()){
cout<<"found"<<endl;
}
else cout<<"not found"<<endl;
return 0;
}
它返回错误消息为:“模板参数推断 / 替换在 find 函数处失败。”
有人能帮我吗?
#include <algorithm>
。operator==
来确定如何进行等值比较。