From fa82b680cf4f25de775b1f198d4d78e1b24d6c53 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 30 Dec 2020 19:40:52 +0200 Subject: [PATCH] Work around clang++ 3.3 failure --- include/boost/core/bit.hpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/include/boost/core/bit.hpp b/include/boost/core/bit.hpp index ed9b159..c469bc8 100644 --- a/include/boost/core/bit.hpp +++ b/include/boost/core/bit.hpp @@ -329,36 +329,44 @@ BOOST_CONSTEXPR int countr_one( T x ) BOOST_NOEXCEPT #if defined(__GNUC__) || defined(__clang__) +#if defined(__clang__) && __clang_major__ * 100 + __clang_minor__ < 304 +# define BOOST_CORE_POPCOUNT_CONSTEXPR +#else +# define BOOST_CORE_POPCOUNT_CONSTEXPR BOOST_CONSTEXPR +#endif + namespace detail { -BOOST_CONSTEXPR inline int popcount_impl( unsigned char x ) BOOST_NOEXCEPT +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned char x ) BOOST_NOEXCEPT { return __builtin_popcount( x ); } -BOOST_CONSTEXPR inline int popcount_impl( unsigned short x ) BOOST_NOEXCEPT +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned short x ) BOOST_NOEXCEPT { return __builtin_popcount( x ); } -BOOST_CONSTEXPR inline int popcount_impl( unsigned int x ) BOOST_NOEXCEPT +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned int x ) BOOST_NOEXCEPT { return __builtin_popcount( x ); } -BOOST_CONSTEXPR inline int popcount_impl( unsigned long x ) BOOST_NOEXCEPT +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long x ) BOOST_NOEXCEPT { return __builtin_popcountl( x ); } -BOOST_CONSTEXPR inline int popcount_impl( unsigned long long x ) BOOST_NOEXCEPT +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long long x ) BOOST_NOEXCEPT { return __builtin_popcountll( x ); } } // namespace detail +#undef BOOST_CORE_POPCOUNT_CONSTEXPR + template BOOST_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT {