samedi 30 janvier 2016

How can I loop through all the elements in a two pair STL set

Here is the data type I am using.

  set< std::pair<string,string>,std::pair<string,string>> foo;

Here is my failed attempt at looping over it

for(auto &e: foo){
    cout << e.first << " " << e.second // this is where I am having an issue.
}

Is it possible to use auto this way? e.g

e.first, e.second // some c++ magic (i realize -> is wrong)  In pseudo -> //  e.third ...

I would love to use auto, but if not how would I write an iterator for the data type I am using?

Aucun commentaire:

Enregistrer un commentaire