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
16BOOST_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
24STATIC_ASSERT( boost::core::popcount( (unsigned char)0x74 ) == 4 );
25STATIC_ASSERT( boost::core::popcount( (unsigned short)0x7400 ) == 4 );
26STATIC_ASSERT( boost::core::popcount( 0x740000u ) == 4 );
27STATIC_ASSERT( boost::core::popcount( 0x74000000ul ) == 4 );
28STATIC_ASSERT( boost::core::popcount( 0x7400000000ull ) == 4 );
29
30#endif
31

source code of boost/libs/core/test/bit_popcount_test_cx.cpp