Subject: Re: [boost] Is there any interest in type-safe container of bool flags with noexcept guarantees?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2017-03-23 06:09:01
Le 23/03/2017 à 00:01, Andrey Semashev via Boost a écrit :
> On 03/23/17 01:54, Vicente J. Botet Escriba wrote:
>> I have an ordinal_set<Ordinal> that is type safe.
>> An enum as the previous one canbe see as an Ordinal and so
>> enum animal_traits
>> eats_meat, eats_grass, has_tail, _count
>> using animal_traits_set = ordinal_set<animal_traits>
> Is the ordinal_set part of Boost? Where can I see it?
It was enum_set in [TBost.Enums]
and then it became ordinal_set in [JASEL]
The last needs some work yet to adapt enums.
> Also, how do you deduce the number of bits from the enum type?
it is the size of the ordinal type. For enums, the number of unique
>>> typedef typed_bitset< animal_traits, animal_traits::_count > animal;
>>> animal a1; // all traits are false
>>> a1[eats_grass] = 1;
>>> a1[has_tail] = 1;
>>> a1 = 1; // error
>>> I suspect it would also be faster to compile.
>> compile time for ordinal sets would suffer a little bit as we need to
>> associate at compile time each enumerator to its position (this could be
>> provided by reflection or by user defined ordinal traits).
> Ah, so one would also have to specialize traits for the enum?
Yes. There could be a linear default trait 0..N trait.