M
Matt Bitten
Thinking about the standard exception classes. They all have
constructors that take a (char *). Say I do this:
std::string s("Got me a errer. Durn.");
throw std::exception(s.c_str());
s, along with its c_str() value, is going to vanish when it goes out of
scope. That means that the constructor for std::exception had better
copy the string. And that means it has to do an allocation. And THAT
means it might throw.
And, if you ask me, the fact that a constructor for an exception object
might throw, sounds like a Very Bad Idea (tm).
Or am I missing something?
constructors that take a (char *). Say I do this:
std::string s("Got me a errer. Durn.");
throw std::exception(s.c_str());
s, along with its c_str() value, is going to vanish when it goes out of
scope. That means that the constructor for std::exception had better
copy the string. And that means it has to do an allocation. And THAT
means it might throw.
And, if you ask me, the fact that a constructor for an exception object
might throw, sounds like a Very Bad Idea (tm).
Or am I missing something?