Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. C/C++
  3. Better Enums

Better Enums

BSD-2-ClauseC++0.11.3

A C++ compile-time enum library providing reflection, iteration, and string conversion in a single header file.

Visit WebsiteGitHubGitHub
1.8k stars182 forks0 contributors

What is Better Enums?

Better Enums is a C++ library that enhances standard enums with reflection capabilities, allowing developers to convert enums to strings, iterate over enum values, and perform compile-time queries. It solves the problem of C++ enums lacking built-in introspection and utility functions, providing a single-header solution without dependencies.

Target Audience

C++ developers working on projects that require robust enum handling, such as serialization, debugging, UI code, or metaprogramming, especially those using C++11 or needing compatibility with C++98.

Value Proposition

Developers choose Better Enums for its clean syntax, compile-time efficiency, and cross-compiler support, offering a lightweight yet powerful alternative to manual enum utilities or heavier reflection libraries.

Overview

C++ compile-time enum to string, iteration, in a single header file

Use Cases

Best For

  • Adding string conversion and iteration to C++ enums
  • Compile-time enum reflection for metaprogramming
  • Implementing serialization or logging with enum values
  • Creating UI components that display enum names
  • Writing cross-platform C++ code with consistent enum handling
  • Enhancing legacy C++98 projects with scoped and sized enums

Not Ideal For

  • Projects that require enums to be defined directly inside class definitions
  • Enums with more than 64 constants where extending the limit is undesirable
  • Teams preferring zero-macro solutions or standard C++11/14 enum features without library dependencies

Pros & Cons

Pros

Compile-Time Reflection

Enables conversion to strings, iteration, and bounds checking at compile time in C++11, allowing for efficient metaprogramming with zero runtime overhead in optimized builds.

Single-Header Simplicity

Just add enum.h to your project with no external dependencies, making integration trivial and reducing build system complexity.

Cross-Compiler Support

Tested and works on clang, gcc, and msvc, ensuring reliable portability across different development environments and platforms.

Legacy C++98 Enhancement

Provides scoped and sized enums for C++98, bringing modern enum features like controlled representation to older codebases without requiring language upgrades.

Cons

Class Definition Limitation

Cannot be used directly inside class definitions, forcing workarounds like typedefs or namespace usage, which can complicate code organization.

Constant Count Limit

Has a soft limit of 64 constants per enum, requiring manual extension for larger enumerations and potentially increasing maintenance burden.

Syntactic Promotion Required

In comparisons, constants often need explicit promotion with the + operator to avoid type issues, introducing subtle boilerplate and error risk.

Frequently Asked Questions

Quick Stats

Stars1,820
Forks182
Contributors0
Open Issues44
Last commit2 years ago
CreatedSince 2015

Tags

#metaprogramming#c-plus-plus-11#type-safety#enum#c-plus-plus#enum-reflection#reflection#code-generation#cpp#header-only#compile-time#c-plus-plus-98

Built With

C
C++

Links & Resources

Website

Included in

C/C++70.6k
Auto-fetched 1 day ago

Related Projects

Magic EnumMagic Enum

Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code

Stars6,101
Forks555
Last commit2 days ago
RTTRRTTR

C++ Reflection Library

Stars3,467
Forks484
Last commit2 years ago
NameofNameof

Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum

Stars2,320
Forks126
Last commit5 days ago
reflect-cppreflect-cpp

A C++20 library for fast serialization, deserialization and validation using reflection. Supports JSON, Avro, Boost Serialization, BSON, Cap'n Proto, CBOR, Cereal, CSV, flexbuffers, msgpack, parquet, TOML, UBJSON, XML, YAML, yas / msgpack.org[C++20]

Stars1,880
Forks181
Last commit1 day ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub