Tech News
← Home  ·  All topics

Cpp26

1 GoKawiil brief on this topic

C++23 introduces bitmask support for enums with automatic operators

A new C++23 proposal, P4313R1, adds a [[=std::bitmask_type]] annotation to enums, enabling automatic bitwise operations for enum classes. This feature simplifies working with enums representing flags by eliminating the need to manually define operators, leveraging a C++26 annotation to opt-in. The discussion also highlights how integral promotions affect bitwise operations on smaller types like shorts, which are promoted to int during computation.