Better Enums alternatives and similar libraries
Based on the "Miscellaneous" category.
Alternatively, view Better Enums alternatives based on common mentions on social networks and blogs.
-
ZXing
ZXing ("Zebra Crossing") barcode scanning library for Java, Android -
RE2
RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library. -
ZBar
Clone of the mercurial repository http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbar -
American fuzzy lop
american fuzzy lop - a security-oriented fuzzer -
Serial Communication Library
Cross-platform, Serial Port library written in C++ -
c-smart-pointers
Smart pointers for the (GNU) C programming language -
Experimental Boost.DI
C++14 Dependency Injection Library -
Mach7
Functional programming style pattern-matching library for C++ -
UNITS
a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies. -
constexpr-8cc
Compile-time C Compiler implemented as C++14 constant expressions -
outcome
Provides very lightweight outcome<T> and result<T> (non-Boost edition) -
cxx-prettyprint
A header-only library for C++(0x) that allows automagic pretty-printing of any container. -
libcpuid
a small C library for x86 CPU detection and feature extraction -
kangaru
🦘 A dependency injection container for C++11, C++14 and later -
CppVerbalExpressions
C++ regular expressions made easy -
value-category-cheatsheet
A C++14 cheat-sheet on lvalues, rvalues, xvalues, and more -
casacore
Suite of C++ libraries for radio astronomy data processing -
StrTk
C++ String Toolkit Library https://www.partow.net/programming/strtk/index.html -
ub-canaries
collection of C/C++ programs that try to get compilers to exploit undefined behavior -
QtVerbalExpressions
This Qt lib is based off of the C++ VerbalExpressions library. [MIT] -
access_profiler
a tool to count accesses to member variables in c++ programs -
CommonPP
Small library helping you with basic stuff like getting metrics out of your code, thread naming, etc.
InfluxDB - Power Real-Time Data Analytics at Scale
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Better Enums or a related project?
README
Better Enums
Reflective compile-time enum library with clean syntax, in a single header file, and without dependencies.
In C++11, everything can be used at compile time. You can convert your enums,
loop over them, find their max,
statically enforce conventions, and pass along the results as
template arguments or to constexpr
functions. All the reflection is available
for your metaprogramming needs.
The interface is the same for C++98 — you just have to use most of it at run time only. This library does provide scoped and sized enums, something not built into C++98.
See the project page for full documentation.
Installation
Simply add enum.h
to your project.
Additional features
- Uses only standard C++, though, for C++98, variadic macro support is required (major compilers have it).
- Supported and tested on clang, gcc, and msvc.
- Fast compilation. You have to declare a few dozen enums to slow down your
compiler as much as only including
iostream
does. - Use any initializers and sparse ranges, just like with a built-in enum.
- Control over size and alignment — you choose the representation type.
- Stream operators.
- Does not use the heap and can be compiled with exceptions disabled, for use in minimal freestanding environments.
Limitations
The biggest limitation is that the
BETTER_ENUM
macro can't be used inside a class. This seems difficult to remove. There is a workaround withtypedef
(or C++11using
):BETTER_ENUM(SomePrefix_Color, uint8_t, Red, Green, Blue) struct triplet { typedef SomePrefix_Color Color; Color r, g, b; }; triplet::Color color;
You can, however, use
BETTER_ENUM
inside a namespace.The macro has a soft limit of 64 declared constants. You can extend it by following these instructions. Ultimately, the number of constants is limited by your compiler's maximum macro argument count.
In some cases, it is necessary to prefix constants such as
Channel::Red
with a+
to explicitly promote them to typeChannel
. For example, if you are doing a comparison:channel == +Channel::Red
On msvc, you may need to enable warning C4062 to get
switch
case exhaustiveness checking.
History
The original version of the library was developed by the author in the winter of
2012-2013 at Hudson River Trading, as a replacement for an older generator
called BETTER_ENUM
.
*Note that all licence references and agreements mentioned in the Better Enums README section above
are relevant to that project's source code only.