什么消耗更多的存储空间 - boost :: dynamic_bitset <>或原始存储?

Eag*_*gle 0 c++ boost boolean data-storage

我有一个程序存储优化问题.

我有,说4096"结"存储在:

  boost::dynamic_bitset<>
Run Code Online (Sandbox Code Playgroud)

我现在正在考虑重构我的程序并构建一个CKnot包含a 的类bool.

问题是什么会占用更多空间:

  • boost :: dynamic_bitset <>(4096,false);
  • CKnot Knot [4096] //包含一个bool

谢谢

小智 6

bitset会相当小,因为C++中的bool必须至少为一个字节大小,而bitset中的每个位都是一个位.