Better handling of out of bound enum values in ToString.
continuous-integration/drone/push Build is failing

This commit is contained in:
Deukhoofd committed 2020-04-10 19:51:35 +02:00
1 parent 60802341b0
commit 9244249a64
2 files changed
+6 -1

No files matched your search

+5 -1
View File
@@ -61,7 +61,11 @@
public: \
constexpr static const char* ToString(name value) { \
switch (value) { MACRO_UTILS_FOR_EACH(ENUM_CASE, name, values) } \
throw std::logic_error("Not reachable"); \
auto v = static_cast<int>(value); \
auto size = (int)((ceil(log10(v)) + 1) * sizeof(char)); \
char* snum = new char[size]; \
sprintf(snum, "%d", v); \
return snum; \
} \
constexpr static name Parse(const char* input, bool caseInsensitive = false) { \
if (caseInsensitive) \