Andrey Semashev wrote:
virtual char const* message( int ev, char* buffer, size_t len ) noexcept;
I like the idea, but what about platforms that don't have strerror_r?
All platforms should be able to implement this interface; you could for instance FormatMessageA into the provided buffer directly, or call strerror and then copy the string into the buffer, and so on.
noexcept means that the new overload cannot be implemented atop the standard one (e.g. one can't forward the call to the current std::error_category::message).
For compatibility reasons (if we make this function pure this will break all existing user categories) we'll have to provide a default implementation in terms of the string-returning one (even though the reverse would be more natural.) It would be something like try { string msg = message(ev); strlcpy(buffer, msg.c_str(), len); return buffer; } catch(...) { return "Message unavailable"; }