Is using a vector of boolean values slower than a dynamic bitset?

后端 未结 4 1163
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-09 03:34

Is using a vector of boolean values slower than a dynamic bitset?

I just heard about boost\'s dynamic bitset, and I was wondering is it worth the trouble. Can I just

4条回答
  •  醉梦人生
    2020-12-09 04:02

    It appears that the size of a dynamic bitset cannot be changed: "The dynamic_bitset class is nearly identical to the std::bitset class. The difference is that the size of the dynamic_bitset (the number of bits) is specified at run-time during the construction of a dynamic_bitset object, whereas the size of a std::bitset is specified at compile-time through an integer template parameter." (from http://www.boost.org/doc/libs/1_36_0/libs/dynamic_bitset/dynamic_bitset.html) As such, it should be slightly faster since it will have slightly less overhead than a vector, but you lose the ability to insert elements.

提交回复
热议问题