Apple将CFBit记录为UInt32,但我对此感到困惑。 如果每个位用32 位定义,那么这是否会破坏使用位向量的目的? 我错过了什么吗?
Apple documents CFBit as being a UInt32, but I'm confused as to why. Doesn't that defeat the purpose of using a bit vector if each bit is defined with 32 bits? Am I missing something?
最满意答案
不,它不是,因为CFBit不是例如CFBitVector的存储类。 它仅用于比较位向量中特定位置的特定位是0还是1.编译器(clang)中没有内置类型来存储单个位(就像在嵌入式系统的某些编译器中一样),因此需要这种解决方法。 为什么选择UInt32才是出于这个目的,我无法分辨。
同样:CFBitVector内部不是 CFBit实例的向量。
No, it isn't, because CFBit is not the storage-class of e.g. a CFBitVector. It's just used to compare whether a particular bit at a specific position in a bitvector is 0 or 1. There is not built-in type in the compiler (clang) to store individual bits (like it is in some compilers for embedded systems), therefore such kind of workaround is needed. Why exactly UInt32 is choosen for that purpose, I can't tell.
Again: CFBitVector internally is NOT a vector of CFBit instances.
更多推荐
发布评论