| 1 | // constexpr test for boost/core/bit.hpp (bit_floor) |
|---|---|
| 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 | #include <boost/config.hpp> |
| 8 | #include <boost/config/pragma_message.hpp> |
| 9 | |
| 10 | #if defined(BOOST_NO_CXX14_CONSTEXPR) |
| 11 | |
| 12 | BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") |
| 13 | |
| 14 | #elif defined(BOOST_MSVC) && BOOST_MSVC / 10 == 191 |
| 15 | |
| 16 | BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_MSVC is "BOOST_STRINGIZE(BOOST_MSVC) ) |
| 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::bit_floor( (unsigned char)0x74 ) == 0x40 ); |
| 25 | STATIC_ASSERT( boost::core::bit_floor( (unsigned short)0x7400 ) == 0x4000 ); |
| 26 | STATIC_ASSERT( boost::core::bit_floor( 0x740000u ) == 0x400000u ); |
| 27 | STATIC_ASSERT( boost::core::bit_floor( 0x74000000ul ) == 0x40000000ul ); |
| 28 | STATIC_ASSERT( boost::core::bit_floor( 0x7400000000ull ) == 0x4000000000ull ); |
| 29 | |
| 30 | #endif |
| 31 |
