Boost logo

Boost :

Subject: Re: [boost] Is there any interest in type-safe container of bool flags with noexcept guarantees?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2017-03-22 23:01:32

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?

Also, how do you deduce the number of bits from the enum type?

>> typedef typed_bitset< animal_traits, animal_traits::_count > animal;
>> animal a1; // all traits are false
>> a1[eats_grass] = 1;
>> a1[has_tail] = 1;
>> a1[10] = 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?

Boost list run by bdawes at, gregod at, cpdaniel at, john at