[Interest] Flags: Non-intrusive, type-safe bitwise operators for enums

Tobias Loew via Boost <[email protected]>
Newsgroups gmane.comp.lib.boost.devel
Message-ID <[email protected]>
Hi everyone,

I would like to gauge interest in a library I've been working on called 
Flags, which provides type-safe, non-intrusive bitwise operators for C++ 
enumerations.
The primary goal of the library is to make the usage of flag-like enums 
safer by preventing accidental mixing of different types while still 
allowing them to be used with standard bitwise logic.

A preliminary version of the library was presented here two years ago. 
The reception was positive and led to an enlightening discussion with 
Andrey Semashev, who pointed out several flaws in the design — notably 
potential ODR violations and the need for argument-dependent lookup 
(ADL) of operators. An enhanced version was then presented at C++Now 
2024, where it was also well-received. After incorporating all feedback 
and allowing another year for the library to mature within internal 
projects, I have decided to resubmit it here.

Key Features:

* Type-safety: Prevents accidental mixing of different enum types and 
disables built-in arithmetic operators for enabled enums to turn logical 
errors into compilation errors.
* Non-intrusive: Can be opted-in for existing enums (both scoped and 
unscoped) without modifying their definition. Simple macro-based opt-in 
via BOOST_FLAGS(...) [currently intended name].
* Compile-Time Friendly: Everything is constexpr, making it usable in 
template arguments.
* Zero Overhead: Designed as zero-cost abstraction in optimized builds.
* Distinguishes between flag-sets and their negations at the type level 
(based on a sound mathematical model).
* Requires at least C++11, uses newer features if present

Resources:

* Documentation: https://tobias-loew.github.io/flags/
* GitHub Repository: https://github.com/tobias-loew/flags
* Boost-Mail-Archive first presentation: 
https://lists.boost.org/archives/list/[email protected]/thread/EZXQFJWA5NX4MRHCDS6OAPRT6GDC2O2D/#YV4SLQDRRQ5KHOTVENE4JL4JG724YWPZ
* C++Now 2024 Presentation: "Fun with Flags", 
https://www.youtube.com/watch?v=2dzWasWblRc
* Godbolt Example: https://godbolt.org/z/PPoKaGrzc

I am interested in hearing if the community sees a place for this in 
Boost or has any feedback on the design.

Best regards,
Tobias Loew
_______________________________________________
Boost mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://lists.boost.org/mailman3/lists/boost.lists.boost.org/
Archived at: https://lists.boost.org/archives/list/[email protected]/message/I42DSK5TLH3GCGQQS4LPL43MMRKBEOKV/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.