Why is std::bitset<8> 4 bytes big?

前端 未结 7 2026
滥情空心
滥情空心 2021-01-18 17:54

It seems for std::bitset<1 to 32>, the size is set to 4 bytes. For sizes 33 to 64, it jumps straight up to 8 bytes. There can\'t be any overhead because std::bitset<

7条回答
  •  醉话见心
    2021-01-18 18:46

    I had the same feature in Aix and Linux implementations. In Aix, internal bitset storage is char based:

    typedef unsigned char _Ty;
    ....
    _Ty _A[_Nw + 1];
    

    In Linux, internal storage is long based:

    typedef unsigned long _WordT;
    ....
    _WordT            _M_w[_Nw];
    

    For compatibility reasons, we modified Linux version with char based storage

    Check which implementation are you using inside bitset.h

提交回复
热议问题