#enums
2 posts tagged #enums.
When two enumerators share a value, the value carries both names
With red = 1 and green = 1, a reflection-based enum_to_string(green) returns "red", because once the value is in a variable nothing distinguishes the two. C++26 reflection can list every name for a value, reject duplicates at compile time with std::meta::exception, prefer a canonical spelling through an annotation, and keep the exact name when you reflect the enumerator itself. The names come back as string_views over static storage, so none of this allocates.
A new proposal deletes your enum bitmask boilerplate
Every C++ codebase that uses a scoped enum as a flag set writes the same eight operator overloads by hand, just to get |, &, and ~ back. P4313 in the 2026-07 mailing proposes an opt-in attribute, enum class [[std::bitmask_type]], that generates all of it and keeps each bitmask a distinct type. Here is the boilerplate it removes, running today.