KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Looking at some old code we have lots of things like the following: // This is dumb string do_something(int in) { stringstream out; try { out << std::fixed << in; } catch(std::exception &e) { out << e.what(); } return out.str(); } // Can't we just do this? Can this ever fail? string do_something_better(int in) { stringstream out; out << std::fixed << in; return out.str(); } When a stringstream reads a primitive can it ever throw an exception? What about when reading a string?
Tags (comma-separated)
Save Edits
Cancel