enable

declare


parse
format


count
iterate




switch






safe cast


during
compilation
#include <enum.h>

BETTER_ENUM(Channel, int, Red = 1, Green, Blue)


Channel     c = Channel::_from_string("Red");
const char  *s = c._to_string();


size_t      n = Channel::_size();
for (Channel c : Channel::_values()) {
    run_some_function(c);
}


switch (c) {
    case Channel::Red:    // ...
    case Channel::Green:  // ...
    case Channel::Blue:   // ...
}


Channel     c = Channel::_from_integral(3);


constexpr Channel c =
    Channel::_from_string("Blue");

$be is a single, lightweight header file that makes your compiler generate reflective enum types.

That means you can easily convert enums to and from strings, validate them, and loop over them. In $cxx11, you can do it all at compile time. It's what built-in enums ought to support. Better Enums simply adds the missing features. And, it is based on the best known techniques, thoroughly tested, fast, portable, and documented exhaustively. To use it, just include enum.h. Try it live online in [Wandbox](http://melpon.org/wandbox/permlink/6kFervewqeDsNAGu), or begin the [tutorial](${prefix}tutorial/HelloWorld.html)!
### Highlights
### Documentation
%% title = Clean reflective enums for C++ %% description = Reflective enums in a single header file, with clean syntax. The enums can be converted to string, iterated, and counted, at run time or as part of metaprogramming. Free and open source under the BSD license. %% class = index