Question

I have tried to implement the following code, but I've got an error. Why is that?

#include <iostream>
#include <bitset>

int main()
{
    const std::string s = "0010111100011100011";
    unsigned long long value = std::bitset<64>(s).to_ullong();
    std::cout << value << std::endl;
}

i get the following error.

prog.cpp: In function ‘int main()’:
prog.cpp:7: error: ‘class std::bitset<64u>’ has no member named ‘to_ullong’ stdout
Was it helpful?

Solution

std::bitset::to_ullong is available since C++11.

http://ideone.com/RpMR2A

http://en.cppreference.com/w/cpp/utility/bitset

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top