Boost logo

Boost :

Subject: Re: [boost] interest in a flag library
From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2018-10-26 08:33:57


> There are std::bitset (fixed size, allocates on the stack) and boost::dynamic_bitset (dynamic size, allocates from stack and heap)
>
> https://www.boost.org/doc/libs/1_68_0/libs/dynamic_bitset/dynamic_bitset.html
>
> The latter also has more sensible implementations of operator& and operator|. Before you invent a new thing, what is wrong with these classes?

Naming and type safety.

Example: `File open(std::path, AccessMode)`
Usage: `auto file = open("myPath/filename.foo", AccessMode::Read |
AccessMode::Write)`

- Named access to bits (Read/Write) instead of indices
- Type safety: AccessMode instead of std::bitset, and you can't pass
e.g. Includes::All to AccessMode just the same as strong enums protect
against a similar issue




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk