"Anders" <anders> wrote...
Can anyone tell me why you have to explicitly write the template
parameters in the .to_string() method? e.g:
bitset<8> bit(string("11"));
cout << bit.to_string<char, char_traits<char>, allocator<char> >() <<
endl;
Because 'to_string' is a template member. You only need to specify
the first one, by the way: bit.to_string<char>()
However, *I* don't have to do that to output the actual bitset:
#include <bitset>
#include <iostream>
#include <string>
using namespace std;
int main()
{
bitset<8> bit(string("11"));
cout << bit << endl;
}
works fine for me. It prints
00000011
Victor