如何擦除结构向量中的所有值,其中结构值k等于0?
struct tabuRecord {
int x;
int y;
int k;
tabuRecord( int x, int y, int k)
: x(x), y(y), k(k){}
};
vector <tabuRecord> tabu;
v.insert(v.begin(), tabuRecord(1, 2, 3));
v.insert(v.begin(), tabuRecord(4, 5, 0));
v.insert(v.begin(), tabuRecord(7, 8, 9));
v.insert(v.begin(), tabuRecord(10, 11, 0));
我试过
tabu.erase(std::remove(tabu.begin(), tabu.end(), tabu.k=0), tabu.end());
和
tabu.erase(std::remove(tabu.begin(), tabu.end(), tabuRecord.k=0), tabu.end());