| 1 | // constexpr test for boost/core/bit.hpp (popcount) |
|---|---|
| 2 | // |
| 3 | // Copyright 2023 Peter Dimov |
| 4 | // Distributed under the Boost Software License, Version 1.0. |
| 5 | // https://www.boost.org/LICENSE_1_0.txt |
| 6 | |
| 7 | #if defined(_MSC_VER) && _MSC_VER / 10 == 191 |
| 8 | # pragma warning(disable: 4307) // '*': integral constant overflow |
| 9 | #endif |
| 10 | |
| 11 | #include <boost/config.hpp> |
| 12 | #include <boost/config/pragma_message.hpp> |
| 13 | |
| 14 | #if defined(BOOST_NO_CXX14_CONSTEXPR) |
| 15 | |
| 16 | BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") |
| 17 | |
| 18 | #else |
| 19 | |
| 20 | #include <boost/core/bit.hpp> |
| 21 | |
| 22 | #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) |
| 23 | |
| 24 | STATIC_ASSERT( boost::core::popcount( (unsigned char)0x74 ) == 4 ); |
| 25 | STATIC_ASSERT( boost::core::popcount( (unsigned short)0x7400 ) == 4 ); |
| 26 | STATIC_ASSERT( boost::core::popcount( 0x740000u ) == 4 ); |
| 27 | STATIC_ASSERT( boost::core::popcount( 0x74000000ul ) == 4 ); |
| 28 | STATIC_ASSERT( boost::core::popcount( 0x7400000000ull ) == 4 ); |
| 29 | |
| 30 | #endif |
| 31 |
