From e7c1079c4fd48602e80df4a887f50f70115e471c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 22 Sep 2018 20:05:31 +0300 Subject: [PATCH] Try to work around g++-5 constexpr issue in failed_impl --- include/boost/system/error_code.hpp | 35 ++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 99d23a1..c2b1bc0 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -385,7 +385,33 @@ template struct enable_if // failed_impl -#if defined(BOOST_SYSTEM_HAS_CONSTEXPR) +#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR) + +inline bool failed_impl( int ev, error_category const & cat ) +{ + return cat.failed( ev ); +} + +#elif BOOST_WORKAROUND(BOOST_GCC, < 60000) + +inline bool failed2_impl( int ev, error_category const & cat ) +{ + return cat.failed( ev ); +} + +BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat ) +{ + if( cat == system_category() || cat == generic_category() ) + { + return ev != 0; + } + else + { + return failed2_impl( ev, cat ); + } +} + +#else BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat ) { @@ -399,13 +425,6 @@ BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & c } } -#else - -inline bool failed_impl( int ev, error_category const & cat ) -{ - return cat.failed( ev ); -} - #endif } // namespace detail