I have a set of sets of ints called nets which I'm trying to iterate through to determine if either of the ints to or from have been added to an existing set; if so, I add them to the existing set (this is to keep track of all combinations of shorts on an electrical network).
However, I CANNOT get the set::insert function to work! I'm able to use (*it).count just fine to determine if either int has already been added to a set, but (*it).insert doesn't work (I always receive the error No matching member function call to 'insert'). However, if I just create a set of ints, setName.insert(to) works fine.
What's wrong with my code?
for (std::set<std::set<int>>::iterator it=nets.begin(); it!=nets.end(); ++it) {
if ((*it).count(to) || (*it).count(from)) {
currentSet = (*it);
(*it).insert(to);
(*it).insert(from);
addedToExistingSet = true;
}
}