Am I doing something wrong or is Microsoft's support of std::popcount broken in version 16.6.0 of Visual Studio?
I'm using Microsoft Visual Studio 16.6.0, with C++ Language Standard set to Preview - Features from the Latest C++ Working Draft (std:c++latest) and trying to compile the popcount sample code from cppreference:
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
#include <iostream>
int main()
{
for (std::uint8_t i : { 0, 0b11111111, 0b00011101 }) {
std::cout << "popcount(0b" << std::bitset<8>(i) << ") = "
<< std::popcount(i) << '\n';
}
}
Even though cppreference states that bit operations (P0553R4) have been supported since version 16.5 and MSVC 16.6 defines the feature macro __cpp_lib_bitops, the above code gives the following errors:
Error C3861 'popcount': identifier not found ConsoleApplication3 C:\Users\rsjaf\source\repos\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp 22
Message see declaration of 'std' ConsoleApplication3 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\include\iostream 19
Error (active) E0135 namespace "std" has no member "popcount" ConsoleApplication3 C:\Users\rsjaf\source\repos\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp 22
Error C2039 'popcount': is not a member of 'std' ConsoleApplication3 C:\Users\rsjaf\source\repos\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp 22
When I look in the bit header, I do see a template for popcount, but it seems to be disabled for my application.