Bit field vs Bitset

后端 未结 5 1931
广开言路
广开言路 2021-02-05 08:17

I want to store bits in an array (like structure). So I can follow either of the following two approaches

Approach number 1 (AN 1)

struct BIT
{
   int da         


        
5条回答
  •  孤独总比滥情好
    2021-02-05 08:19

    Approach number 1 will most likely be compiled as an array of 4-byte integers, and one bit of each will be used to store your data. Theoretically a smart compiler could optimize this, but I wouldn't count on it.

    Is there a reason you don't want to use std::bitset?

提交回复
热议问题