Apparently you can't construct a bitset without a constant value in the constructor and I was wondering if there was a way around that:
Example:
Not being able to create a bitset with a variable makes it near useless.Code:std::cout << std::bitset<50>(123456789) << std::endl; // legal size_t bits = 50; std::cout << std::bitset<bits>(123456789) << std::endl; // illegal
My actual problem is taking place in a loop and I wish to output the bits for huffman code for each one - and since huffman codes are of variable length I need variable length bitsets. I thought bitset's would be ideal for this situation.
Thanks, G.




Reply With Quote