enable @@ -11,7 +5,7 @@ declare parse -print +format count @@ -19,6 +13,7 @@ iterate + switch @@ -29,22 +24,25 @@ switch safe cast -at compile time-
#include <enum.h> +during +compilation ++
#include <enum.h>
-ENUM(Channel, int, Red = 1, Green, Blue)
+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);
+size_t n = Channel::_size();
+for (Channel c : Channel::_values()) {
+ run_some_function(c);
+}
-switch (c) {
+switch (c) {
case Channel::Red: // ...
case Channel::Green: // ...
case Channel::Blue: // ...
@@ -54,35 +52,60 @@ size_t n = Channel::_size;
Channel c = Channel::_from_integral(3);
-constexpr Channel c = Channel::_from_string("Blue");
+constexpr Channel c =
+ Channel::_from_string("Blue");
+ $be is a single, lightweight header file that makes your compiler generate + reflective enum types. +
-### What do you get? +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. + +All you have to do to use it is includeenum.h.
+
+Try it live online in
+[Wandbox](http://melpon.org/wandbox/permlink/pdlAAGoxnjqG6FRI), or begin the
+[tutorial](${prefix}tutorial/HelloWorld.html)!
+
+
+
+### Features
constexpr functions.
+ No ugly macros. Use initializers as with built-in enums.
+ Internal members have underscores to avoid clashing with your constant
+ names.
enum.h. There are no objects or libraries to link with.
enum.h. It's a metaprogram executed by your
+ compiler.
+
+ switch
Use a Better Enum like a built-in enum, and still have the
@@ -90,15 +113,7 @@ working example.
enums. Generated members have underscores to avoid conflicts
- with your constant names.
-
- switch statements for
@@ -106,29 +121,56 @@ working example.
enum.h. It's a metaprogram executed by your
- compiler.
-
- iostream.
+ Iteration and counting are much easier to maintain than with an extra
+ Count constant and assuming a dense range.
enum.h.
+ Much less impact on build time than even just including
+ iostream. enum.h is only slightly more than 1000
+ lines long.
constexpr functions.
+
+ std::cout or use
+ boost::lexical_cast.
+
+ switch-friendly constants of any literal
+ type.
+
+ enum.h
-
- Current version: $version- This page is an advanced demo showing the kind of compile-time code you can - write on top of Better Enums. You can download it and - try it out. + This page is an advanced demo showing the kind of code you can write on top of + Better Enums. It's a valid program — you can + download it and try it out. The program runs as part of + the automated test suite.
$demo_body diff --git a/doc/template/download.tmpl b/doc/template/download.tmpl index 76cc260..46e6804 100644 --- a/doc/template/download.tmpl +++ b/doc/template/download.tmpl @@ -1,2 +1,2 @@ -href="https://raw.githubusercontent.com/aantron/better-enums/$version/enum.h" +href="https://raw.githubusercontent.com/aantron/better-enums/$ref/enum.h" download \ No newline at end of file diff --git a/doc/template/header.tmpl b/doc/template/header.tmpl index 1630395..ac19494 100644 --- a/doc/template/header.tmpl +++ b/doc/template/header.tmpl @@ -31,11 +31,25 @@Version $version
+To install, just add enum.h to your project.
+ Visit the GitHub repo for issues, feedback, and let me know if you + found this library useful! +
+Welcome to the Better Enums tutorials! The code in this tutorial forms a - valid program, which you can download and play with. + valid program, which you can download and play with. The + program runs as part of the automated test suite.
$tutorial_body diff --git a/doc/template/version.tmpl b/doc/template/version.tmpl index 899f24f..2774f85 100644 --- a/doc/template/version.tmpl +++ b/doc/template/version.tmpl @@ -1 +1 @@ -0.9.0 \ No newline at end of file +0.10.0 \ No newline at end of file diff --git a/doc/tutorial/1-hello-world.md b/doc/tutorial/1-hello-world.md index 0cb72b5..a7b915d 100644 --- a/doc/tutorial/1-hello-world.md +++ b/doc/tutorial/1-hello-world.md @@ -1,6 +1,6 @@ ## Hello, World! -Downloadenum.h, then build this program with it:
+Download enum.h, then compile this program:
#include