diff --git a/README.md b/README.md index c159a08..24eeef9 100644 --- a/README.md +++ b/README.md @@ -25,30 +25,18 @@ for (Channel channel : Channel::_values) { } ``` -...and more. See the [project page](http://aantron.github.io/better-enums) and +...and more. See the +[project page](http://aantron.github.io/better-enums#tutorial) and [examples](https://github.com/aantron/better-enums/tree/master/example) for a tutorial. ## Installation -Simply add `enum.h` and `enum_preprocessor_map.h` to your project. The current -version can be found at -[https://github.com/aantron/better-enums/releases](https://github.com/aantron/better-enums/releases). - -`enum_preprocessor_map.h` can handle enums with up to 256 constants. If you have -more, re-generate it by running something like: - - ./pp_map_gen.py enum_preprocessor_map.h 512 - -This only needs to be done once when the constant limit is exceeded. You don't -need to do this on every build. I hope to remove the need for this completely in -a future version. +Simply add `enum.h` from `master` to your project. ## Features - Generated at compile time by `constexpr` functions and the preprocessor. - `pp_map_gen.py` is only needed if you have an enum with more than 256 - constants. - Safe conversions between enums and integers and strings. [1-basic.cc](https://github.com/aantron/better-enums/blob/master/example/1-basic.cc) - Iterable collections of constants and names. @@ -58,22 +46,21 @@ a future version. [2-iterate.cc](https://github.com/aantron/better-enums/blob/master/example/2-iterate.cc) - Switch case checking. [3-switch.cc](https://github.com/aantron/better-enums/blob/master/example/3-switch.cc) -- Almost all operations are `constexpr` and can be used at compile time in your - own `constexpr` code. +- All operations are `constexpr` and can be used at compile time in your own + `constexpr` code. [4-constexpr.cc](https://github.com/aantron/better-enums/blob/master/example/4-constexpr.cc) - Constant values can be set (`Red = 1`) and aliased (`Favorite = Green`), just like with built-in enums. -- Generating a large number of enums is faster than including a typical standard - header like `iostream` – performance test included. +- Generating a large number of enums is about as fast as including a typical + standard header like `iostream` – performance test included. - Explicit choice of underlying representation type. - Header-only. - No dependencies besides the standard library. - Tested on gcc 4.9 and clang 3.6. -The library compiles only with gcc and clang due to use of weak symbols and due -to lagging C++11 support in msvc. It should ultimately be portable to msvc, -since msvc has its own version of weak symbols. Everything else in the library -is standard C++. +The library is standard C++, but it compiles only with gcc and clang due to +lagging C++11 support in msvc. A future runtime fallback version will allow +msvc and non-C++11 usage. ## Contact @@ -98,12 +85,6 @@ See the full [documentation](http://aantron.github.io/better-enums). There are several areas that still need improvement. -- I will try to eliminate the need for `pp_map_gen.py`. The library will then - consist of one file, `enum.h`. -- `to_string` can be made `constexpr`, like most of the rest of the code. -- Iterators over defined constants should be made random-access. This would - allow `constexpr` functions to use them by adding 1 – the only way to advance - them now is by mutating increment. - Some enum types might have a sensible choice for a default constructor. The library should allow it to be customized. - All safety checks are currently done by linear scans. This may be a diff --git a/doc/api.html b/doc/api.html index f1d08cd..feb0875 100644 --- a/doc/api.html +++ b/doc/api.html @@ -637,17 +637,16 @@ do_something(Enum::A); // converted silently

- member const char* enum_value.to_string() + member constexpr const char* enum_value.to_string() const

Returns the string representation of enum value on which the method is called. If multiple constants have the same numeric value, the string - returned can be the representation any of the constants. Note that this - method is not constexpr. Complexity is linear in - the number of constants. If the string does not name a constant, - throws std::runtime_error. + returned can be the representation any of the constants. Complexity is + linear in the number of constants. If the string does not name a + constant, throws std::runtime_error.

@@ -728,9 +727,9 @@ Enum::_values::end()

class _NameIterable::iterator

- An iterator over defined constant names with a dereference operator that is - not constexpr. Can be created explicitly by the - constexpr expressions + An iterator over defined constant names with a constexpr + dereference operator. Can be created explicitly by the constexpr + expressions

Enum::_names::begin()
diff --git a/doc/index.html b/doc/index.html
index c54ab43..364a838 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -59,8 +59,8 @@
 
     

Better Enums gives you rich, reflective enums with the nicest syntax yet - seen.1 All you have to do is add two short, - simple header files to your project, and you are ready to go. + seen.1 All you have to do is add one short + and simple header file to your project, and you are ready to go.

#include <enum.h>
@@ -71,15 +71,16 @@ ENUM(Channel, int, Red, Green, Blue);
reflective capacity, including string conversions, value listing, compile-time operations, static information about the range of declared constants, and (last and probably least) the name "Channel" - itself. + itself. You can even assign explicit values to constants and alias them + like with a normal built-in enum.

The enum is easy to maintain. There is no duplication of value names, no repetition of cumbersome macros, and no generator to run on every build. The library is header-only and has no dependencies, so there aren't - any object files to link with. You can assign explicit values to constants - and alias them like with a normal enum. + any object files to link with. It is also standard + C++.

@@ -95,13 +96,11 @@ ENUM(Channel, int, Red, Green, Blue);

Installation

- Download the - - latest release, then copy the files - enum.h and enum_preprocessor_map.h to your - project. That's it! Just make sure both files are in your include path and - you are compiling with gcc or - clang in + Download + + enum.h and copy it to your project. That's it! Just make sure it's in + your include path and you are compiling with gcc + or clang in C++11 mode.

@@ -212,13 +211,13 @@ Channel my_channel = Channel::_from_integral(2);

- Finally, most of the above is declared constexpr and can be - run at compile time. This means you can do all sorts of parsing and - processing at the same time the rest of your code is being compiled, - improving runtime and startup performance! See some + Finally, all of the above can be done at compile time. This means you can + do all sorts of parsing and processing at the same time the rest of your + code is being compiled, improving runtime and startup performance! See + some examples - and another - example. + 2 + 3.

diff --git a/doc/sitemap.xml b/doc/sitemap.xml index a581a2a..adb2747 100644 --- a/doc/sitemap.xml +++ b/doc/sitemap.xml @@ -2,11 +2,9 @@ http://aantron.github.io/better-enums - daily 1.0 http://aantron.github.io/better-enums/api.html - daily