|
Boost : |
Subject: Re: [boost] Is there any interest in type-safe container of bool flags with noexcept guarantees?
From: Bjørn Roald (bjorn_at_[hidden])
Date: 2017-03-22 06:39:08
> On 21 Mar 2017, at 19:23, Steven Watanabe via Boost <boost_at_[hidden]> wrote:
>
> AMDG
>
> On 03/21/2017 10:31 AM, Роман ÐÑлов via Boost wrote:
>>
>> <snip>
>> class eats_meat;
>> class eats_grass;
>> class has_tail;
>> Then bind these types to flag identifiers
>> typedef typed_flags<eats_meat, eats_grass, has_tail> animal;
>>
>
> what's wrong with
> struct animal {
> bool eats_meat : 1;
> bool eats_grass : 1;
> bool has_tail : 1;
> };
>
To me standard C bitfields fit the bill, and is what I will use as long as I do not need to do bitwise operations on the flags. For just setting and reading them, it works fine and is simple to use. Beyond that, allthough outside this topic I really wish the language had the ability to take better control of the binary representation and layout of C bitfields for binary data portability.
â
Bjørn
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk