Skip to content

Commit ad44eda

Browse files
committed
Add comparison of alternatives section
1 parent ae486bd commit ad44eda

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@ defined type. This also means that upgrading a regular enum already widely used
9292
No strange behavior, or edge cases, when used with other third party libraries
9393
(e.g. serialization), or standard library type traits.
9494

95-
This first point is especially notable since [Better
96-
Enums](https://github.com/aantron/better-enums) seems like the best maintained,
97-
most polished, and most suggested smart enum solution I've seen. Last I checked,
98-
it uses enum like classes, which carry all the disadvantages mentioned above.
99-
This being a deal breaker for me was one of the major motivations for writing
100-
this library. More generally, I recommend that if you are considering a smart
101-
enum library, if this point isn't discussed in the docs, simply try to define an
102-
enum and switch case on it, or define it as a non-type template parameter. If it
103-
doesn't work, I'd reconsider.
104-
10595
Second, all the functionality in defining enums is preserved. You can define
10696
`enum` or `enum class`es, set storage explicitly or let it be implicit, define
10797
the value for an enumeration, or allow it to be determined implicitly. You can
@@ -122,6 +112,33 @@ currently a linear search; this may be changed in the future (most alternatives
122112
are not trivial to implement without doing heap allocations or dynamic
123113
initialization).
124114

115+
### Quick Comparison of Alternatives
116+
117+
The best known alternative is probably [Better
118+
Enums](https://github.com/aantron/better-enums). The biggest issue with Better
119+
Enums is simply that its macros don't actually create enums or enum classes, but
120+
enum like classes. This carries all of the disadvantages discussed in the
121+
previous section, and for me was just a deal breaker. There are also more minor
122+
issues like not being able to define a nested enum, having a lower default
123+
enumeration limit. Conversely, I'm not aware of any advantages, except one: it
124+
does support C++03, which wise enum never will, so it's a good choice for older
125+
codebases.
126+
127+
A recent interesting alternative is [Meta
128+
Enum](https://github.com/therocode/meta_enum). This does declare actual
129+
enum/enum classes. As benefits, it doesn't have any limit on the number of
130+
enumerations by design, and it doesn't require different macros for declaring
131+
enums nested inside classes. As far as I can tell though, the approach means
132+
that it can't support switch case generation (e.g. for to_string), nor can it
133+
support 11. It currently only seems to support 17 but 14 support may be
134+
possible.
135+
136+
As far as I saw, neither library has something like the adapt macro, though I
137+
think either one could add it pretty easily. Overall, I feel
138+
139+
If any of this information is incorrect, please let me know and I'll make
140+
correcting it the highest priority.
141+
125142
### Version differences
126143

127144
Wise enum tries to target each language version idiomatically. In 11, template

0 commit comments

Comments
 (0)