T
Todd Beauchemin
OK. I want to overload the >> operator so I can do
cin >> myset.
I have the format of set input be {ele1, ele2}.
Any suggestions on how to do this. I have
the following:
template<class T, class A, class L>
std::istream& operator>> (std::istream& i, std::set<T, A, L>& s) {
T val;
if (i.get () == '{') {
i >> val;
s.insert (val);
while (i.get () == ',') {
i >> val;
s.insert (val);
}
} // if
return i;
} // >> for set
but if i do {google, yahoo} for input then the set becomes
google,
is there anyway to adjust the delimiters such that it wont pick up
the , or the }?
cin >> myset.
I have the format of set input be {ele1, ele2}.
Any suggestions on how to do this. I have
the following:
template<class T, class A, class L>
std::istream& operator>> (std::istream& i, std::set<T, A, L>& s) {
T val;
if (i.get () == '{') {
i >> val;
s.insert (val);
while (i.get () == ',') {
i >> val;
s.insert (val);
}
} // if
return i;
} // >> for set
but if i do {google, yahoo} for input then the set becomes
google,
is there anyway to adjust the delimiters such that it wont pick up
the , or the }?