jeudi 26 octobre 2017

iterator of a set inside a set is equal to the insider set.begin()?

for example :

set<set<T>> outer_set;
set<T> insider_set1, insider_set2;
T a;
insider_set1.insert(a);
set<T>::iterator chosen_itr;
for(auto temp_set: outer_set){
    if(temp_set.count(a)){
        chosen_itr = temp_set.begin();
        break;
    }
}
T b = something(...);
*chosen_itr.insert(b);

will this code add b to the insider_set1 inside of outer_set or the chosen_itr belongs to a temporary set that was created at auto temp_set

if chosen_itr is some random iterator how to get the real one??

Aucun commentaire:

Enregistrer un commentaire