On 18 Nov 2025 12:55, Ruben Perez via Boost wrote:
Hi all,
I've recently found myself frustrated due to the amount of boilerplate that bitmask types require. Say, for example, asio::cancellation_type_t: https://www.boost.org/doc/libs/latest/boost/asio/cancellation_type.hpp
When using enum class to avoid pouring identifiers into the parent namespace, you need to re-implement all the bitwise operators. This is not a lot of work, but is empty boilerplate, and implies adding tests and docs.
* Do you think this is a problem worth solving, or am I being too picky?
Yes, I've found myself solving the same problem multiple times. I've written a macro-based solution for that in my project.
* Do we already have something similar in Boost? I've found a BOOST_BITMASK macro (https://www.boost.org/doc/libs/latest/boost/detail/bitmask.hpp), but it doesn't seem to be public.
I intended to propose a more lightweight version of this macro (without the deprecated bitmask_set) to Boost.Core, but never got around to do it. I think, we should do it.
* Do you think the approach shown above is sound? In particular, operators are in the global namespace so that they work with any enum in any namespace correctly annotated. * Do you think such a small component could be useful in Boost at some point?
I'm not experienced with C++ reflection, so I can't comment on the implementation. But requiring C++23 for such a basic and widely needed feature seems like a high bar. In particular, I would not be able to use a C++23 library in my code. I would prefer a simpler solution that is compatible with C++17 at the most, although C++11 should be already enough to implement it.