Better Enums

Reflective compile-time enums for C++

Open-source under the BSD license

Version 0.11.3

To install, just add enum.h to your project.

Visit the GitHub repo for issues, feedback, and the latest development.

Download enum.h GitHub

Welcome to the Better Enums tutorials! The code in this tutorial forms a valid program, which you can download and play with. The program runs as part of the automated test suite.

Hello, World!

Download enum.h, then compile this program:

#include <iostream>
#include "enum.h"

BETTER_ENUM(Word, int, Hello, World)

int main()
    std::cout << (+Word::Hello)._to_string() << ", "
              << (+Word::World)._to_string() << "!"
              << std::endl;

    return 0;

Run it, and you should see the output "Hello, World!"

Congratulations, you have just created your first Better Enum!