From 1659dfbeba4b91c94b3d2015fcde978c6af944f5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 24 Sep 2021 04:27:08 +0300 Subject: [PATCH] Avoid instantiating generic_category in error_condition::operator std::error_condition --- include/boost/system/detail/error_condition.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/boost/system/detail/error_condition.hpp b/include/boost/system/detail/error_condition.hpp index c48f424..255b282 100644 --- a/include/boost/system/detail/error_condition.hpp +++ b/include/boost/system/detail/error_condition.hpp @@ -222,7 +222,23 @@ public: operator std::error_condition () const { +// This condition must be the same as the one in error_category_impl.hpp +#if defined(BOOST_GCC) && BOOST_GCC < 50000 + return std::error_condition( value(), category() ); + +#else + + if( cat_ ) + { + return std::error_condition( val_, *cat_ ); + } + else + { + return std::error_condition( val_, std::generic_category() ); + } + +#endif } inline friend bool operator==( std::error_code const & lhs, error_condition const & rhs ) BOOST_NOEXCEPT