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?
You are doing something utterly weird.
The signature of set is:
template<
class Key,
class Compare = std::less<Key>,
class Allocator = std::allocator<Key>
> class set;
So you are using std::pair<std::string, std::string>
as comparator. It will fail to compile as soon as you try to insert something.
But I am pretty sure that's not what you want.
You probably either want
map<pair<string, string>, pair<string, string>>;
or
set<pair<pair<string, string>, pair<string<string>>>;
or maybe
set<tuple<string, string, string, string>>;