I know that initializing an object of the bitset class means you have to use a compile-time constant for the number of bits. However, for my purposes, I want to a produces a giant array of boolean values and I know I could save memory by using the bitset class if only it weren't the case that the size of this array is known only at run time. Is there a way around this?
            Asked
            
        
        
            Active
            
        
            Viewed 613 times
        
    1
            
            
        - 
                    3http://en.cppreference.com/w/cpp/utility/bitset - look at the notes at the bottom of the page – Mat Sep 07 '13 at 08:06
 
2 Answers
2
            
            
        You could use dynamic_bitset from boost
http://www.boost.org/doc/libs/1_54_0/libs/dynamic_bitset/dynamic_bitset.html
or vector< bool > specialization from STL
http://en.cppreference.com/w/cpp/container/vector_bool
all depends on your requirements, such as the operators and functions that you need
        dieram3
        
- 592
 - 3
 - 7
 
1
            
            
        If you have access to boost you can use its dynamic_bitset:
http://www.boost.org/doc/libs/1_54_0/libs/dynamic_bitset/dynamic_bitset.html
        dschaeffer
        
- 618
 - 6
 - 15