ifstream fin(file);
string line;
vector< set<string> > diag;
set<string> temp_set;
vector<string> temp_vec;
while(getline(fin, line)
temp_vec = split(line, " ");
for(int i = 0;i < temp_vec.size();i ++)
temp_set.insert(temp_vec[i]); // when is this set emptied?
diag.push_back(temp_set);
}
不妨试试这个:
ifstream fin(file);
string line;
vector< set<string> > diag;
vector<string> temp_vec;
while(getline(fin, line)
temp_vec = split(line, " ");
// no need for loop
// construct a new set each time
set<string> temp_set(temp_vec.begin(), temp_vec.end());
diag.push_back(temp_set);
}