1

What is the difference between bit-vector and bitset container of stl ? Please explain. To my understanding bitset is the implementation of the concept of bitvector am I right or wrong? What are the other ways to implement bit vector?

Sasha
  • 492
  • 2
  • 6
  • 21
user1543957
  • 1,758
  • 4
  • 20
  • 30

2 Answers2

5

bit_vector has the same interface as an std::vector, and is optimised for space. It not a part of standard C++. This documentation claims it is close to an STL vector<bool>, which presumably is quite close to a standard C++ std::vector<bool>.

std::bitset is fixed size, and has a different interface.

juanchopanza
  • 223,364
  • 34
  • 402
  • 480
1

They're different. A std::bitset has a fixed size known at compile time. This allows it to be implemented very efficiently. A bit vector (I assume you mean std::vector<bool>) can vary in size like any other std::vector.

john
  • 85,011
  • 4
  • 57
  • 81