Subject: Re: [boost] Improved typesafe bitfield
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2016-02-07 11:17:37
On Sat, Feb 6, 2016 at 4:54 PM, Vicente J. Botet Escriba
> Le 06/02/2016 12:54, Niall Douglas a Ã©crit :
>> On 6 Feb 2016 at 12:00, Vicente J. Botet Escriba wrote:
>>> Do you see something wrong having two classes one for the bits enum and
>>> one for the set of those bits enums?
>>> Mixing both, the element and the set in a single class, has some
>>> drawbacks. The flag type is not an enum, that is, is_enum<flag>::value
>>> is false.
>> Tongari's solution split them as you describe.
>> I'm not against that solution, it's just a distinction I need to care
>> about during using them and I don't want to care. I just want C
>> bitfields which don't accidentally substitute for integers and
>> therefore lead to bugs.
> I understand you, however I believe that the intent is better reflected with
> a type for elements and a a type for the set of elements.
I agree. I've even had a few places where I need to specifically
state "this type is _one_ of the bits" vs "this type is a few of the
It is the difference between container and element.
Qt uses separate types. Not sure if that was for intent, or just the
best way they could implement it at the time, but I've grown to like
it that way.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk