J
Jason Heyes
I have a function that reads tags. The function prints any failures it
encounters to std::cout.
std::istream &read_tag(std::istream &is, std::string &tag)
{
std::string s;
if (!(is >> s))
{
std::cout << "Failed to read string of tag" << std::endl;
return is;
}
if (!(s == "start" || s == "end"))
{
std::cout << "Failed to read string of tag" << std::endl;
is.setstate(std::ios::failbit);
return is;
}
tag = s;
return is;
}
How do I write a silent version of read_tag that uses read_tag to complete
its task?
std::istream &read_tag_silent(std::istream &is, std::string &tag)
{
/* ? */
}
Any help is appreciated.
encounters to std::cout.
std::istream &read_tag(std::istream &is, std::string &tag)
{
std::string s;
if (!(is >> s))
{
std::cout << "Failed to read string of tag" << std::endl;
return is;
}
if (!(s == "start" || s == "end"))
{
std::cout << "Failed to read string of tag" << std::endl;
is.setstate(std::ios::failbit);
return is;
}
tag = s;
return is;
}
How do I write a silent version of read_tag that uses read_tag to complete
its task?
std::istream &read_tag_silent(std::istream &is, std::string &tag)
{
/* ? */
}
Any help is appreciated.