Boost logo

Boost :

Subject: Re: [boost] Interest in bit-wise flags?
From: David Stone (david_at_[hidden])
Date: 2014-06-18 02:13:33


Is the code available online?

On Tue, Jun 17, 2014 at 6:09 PM, Jeffrey Bush <jeff_at_[hidden]> wrote:

> Hi Boost!
>
> I have developed a type-safe bit-wise flags class for my own personal use
> and
> am wondering if it would be of interest for me to submit it as a Boost
> library.
> At the moment it is not ready for submission (code is messy) but I am
> testing
> the waters so I present an overview below.
> * Fully ISO standard C++11 (except for an MSVC version which is
> API-compatible
> except it doesn't support as many an infinite number of flag names)
> * They are type-safe, requiring explicit casts to and from
> integers/booleans
> * Supports standard bit-wise operations, and always keep values within the
> possible set of flags
> * Supports getting the name of a flag and looking up flags by name at
> run-time
> (when a flag is actually multiple-flags it gives something like "A|B")
> * Supports getting an array of all flags at run-time
>
> Now the bad things, which may be a deal-breaker:
> * Because of limitations in C++ the syntax can feel a bit awkward. You have
> to
> use a macro to define flag-names (which actually creates a class) then
> you
> can pass those flag-names as template arguments to the flags. An example:
> FLAG_NAME(A);
> FLAG_NAME(B);
> FLAG_NAME(C);
> typedef Flags<std::uint8_t, Flag_A, Flag_B, Flag_C>::WithValues<0x01,
> 0x02, 0x04> MyFlags;
> * I also couldn't get around using the ::WithValues nested class
> * I use a set of macros to make this cleaner (e.g. the above could be
> FLAGS(A, B, C)) and once defined there is no more ugliness
>
> Thanks for consideration!
> Jeff
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>


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