From 2e2430c4fae268c57f009d98b8c01262ecddb72f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 3 Feb 2022 04:36:58 +0200 Subject: [PATCH] Add error_code::category_name helper, use it in to_string --- include/boost/system/detail/error_code.hpp | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/include/boost/system/detail/error_code.hpp b/include/boost/system/detail/error_code.hpp index 910a9af..f211e5d 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -83,6 +83,28 @@ private: // >3: pointer to source_location, failed_ in lsb boost::uintptr_t lc_flags_; +private: + + char const* category_name() const BOOST_NOEXCEPT + { + // return category().name(); + + if( lc_flags_ == 0 ) + { + // must match detail::system_error_category::name() + return "system"; + } + else if( lc_flags_ == 1 ) + { + // must match detail::interop_error_category::name() + return "std:unknown"; + } + else + { + return d1_.cat_->name(); + } + } + public: // constructors: @@ -598,7 +620,7 @@ public: else #endif { - std::string r = category().name(); + std::string r = category_name(); detail::append_int( r, value() ); return r; }