Search code examples
c++bitset

bitset has no member ullong


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

Solution

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

    http://ideone.com/RpMR2A

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