According to cplusplus.com, this is the implementation of the std::runtime_error class:
class runtime_error : public exception {
public:
explicit runtime_error (const string& what_arg);
};
Since the constructor is explicit, I expected it to only accept std::string objects.
throw std::runtime_error("error message");
This code compiles (GCC), though. Shouldn't the compiler complain about the implicit const char* to const string conversion?
explicitworks. It prevents astd::stringfrom being converted to astd::runtime_errorimplicitly, not aconst char *to astd::string. That one's up tostd::string's constructor. - chris