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


A basic performance test is run on every compiler tested. It doesn't try to be very accurate — it just stress-tests the compiler once to get a rough idea of how long it takes to compile Better Enums.

The files compared in the test are as follows:

The argument is that if compiling a bunch of Better Enums is faster, or about as fast as, including a single standard header such as iostream, then Better Enums is fast enough for general use.

Results are given for select compilers and configurations as ratios of how long it took to compile the Better Enums file to how long it took to compile the iostream file. The less the ratio, the better. Ratios less than 1 mean the enums compiled faster, and ratios greater than 1 mean iostream compiled faster.

The time to merely include enum.h vary widely by compiler, with clang being by far the fastest. The ratios to iostream are given below.

On my test machines, clang processed the file in 40ms, gcc took 230ms, and VC2015 took 820ms. The first two are comparable to each other, but VC2015 runs on a different machine.

In general, I am very sensitive to performance. Better Enums was originally developed in the context of a commercial project where slow running times and slow compilation times were unacceptable. I am continuing to develop it in this spirit.