On 01/15/18 03:01, Niall Douglas via Boost wrote:
Is anybody actually generating a totally unique message per invocation for the same error code which couldn't be cached and reused? I've never seen it yet. Almost all use of message() is for printing to human readable output.
libc++ uses strerror_r or snprintf to generate error messages (see system_error.cpp[1]). libstdc++ uses strerror[2] (which seems like a bug as it is not thread-safe). strerror_r implementation in glibc may dynamically generate the error message, although most of the time it returns one of many constant strings. Either way, users of strerror_r have to assume the result is dynamically generated. You didn't mention how you would solve the problem of thread synchronization to the static storage or cache. In case of a hash map, how would you be removing entries from it? Because if you don't, you're wasting memory. [1]: https://llvm.org/svn/llvm-project/libcxx/trunk/src/system_error.cpp [2]: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/src/c%2B%2B11...