我找到了这段代码:
enum
{
IsDynamic = (1U << 0), // ...
IsSharable = (1U << 1), // ...
IsStrong = (1U << 2) // ...
};
(1U << X)
有什么作用? 最佳答案
它设置位掩码:
1U << 0 = 1
1U << 1 = 2
1U << 2 = 4
etc...
发生的情况是1U(无符号值1)向左移动x位。
您发布的代码等效于:
enum
{
IsDynamic = 1U, // binary: 00000000000000000000000000000001
IsSharable = 2U, // binary: 00000000000000000000000000000010
IsStrong = 4U // binary: 00000000000000000000000000000100
}