0

Are there any blatant differences between the two that makes one's use more practical in some situations than the other's? Can someone please outline the differences here and any relevant performance information for both?

Bob John
  • 3,688
  • 14
  • 43
  • 57

1 Answers1

0

A "bitvector," std::vector< bool >, is a dynamic-sized array on the heap, which satisfies most of the requirements for a Container class. To do so, it defines a funky iterator class which returns reference objects following the tricky proxy object design pattern.

A std::bitset is a static-sized array with the storage inline with the object. It doesn't have iterators, only access operators such as subscript.

The bitwise access part will perform similarly. The vector will also call operator new and operator delete when created and destroyed, and occasionally reallocate if necessary.

Potatoswatter
  • 134,909
  • 25
  • 265
  • 421