How would these tests be optimized if you moved the comparison into the category? The category test would be replaced with a virtual function call (which is arguably more expensive) but the error code value tests would still be executed.
Right now I must duplicate those tests at every use case site. If they were inside the category instead, they'd be hot in the branch predictor and microcode cache.
Some parts of your proposal (namely, switching to `string_view`) do not have a clear migration path, especially for C++03 users.
You didn't fully read my earlier email. There is no point using std::string_view with earlier than C++ 17. And boost::string_view doesn't have sufficient interop with std::string to substitute.
The std::string_view message() is 100% C++ 17 or later only.
My objection was not just about `std::string_view` being C++17-only, although it was part of it. Not all error categories can be ported to `std::string_view` in principle.
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. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/