When is it worthwhile to use bit fields?

前端 未结 11 591
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 09:10

Is it worthwhile using C\'s bit-field implementation? If so, when is it ever used?

I was looking through some emulator code and it looks like the registers for the c

11条回答
  •  伪装坚强ぢ
    2020-12-01 09:24

    Boost.Thread uses bitfields in its shared_mutex, on Windows at least:

        struct state_data
        {
            unsigned shared_count:11,
            shared_waiting:11,
            exclusive:1,
            upgrade:1,
            exclusive_waiting:7,
            exclusive_waiting_blocked:1;
        };
    

提交回复
热议问题