1 | // constexpr test for boost/core/bit.hpp (bit_width) |
---|---|
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_width( (unsigned char)0x74 ) == 7 ); |
25 | STATIC_ASSERT( boost::core::bit_width( (unsigned short)0x7400 ) == 15 ); |
26 | STATIC_ASSERT( boost::core::bit_width( 0x740000u ) == 23 ); |
27 | STATIC_ASSERT( boost::core::bit_width( 0x74000000ul ) == 31 ); |
28 | STATIC_ASSERT( boost::core::bit_width( 0x7400000000ull ) == 39 ); |
29 | |
30 | #endif |
31 |