Skip to content

Commit 5457803

Browse files
committed
generate enum traits as constexpr
1 parent 2bd33eb commit 5457803

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Enum.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,18 @@ sub render_enum_tables($$$$$$) {
154154

155155
with_emit_traits {
156156
emit_block {
157-
emit "static const bool is_complex = " . ($complex ? 'true' : 'false') . ";";
157+
emit "static constexpr bool is_complex = " . ($complex ? 'true' : 'false') . ";";
158158
emit "typedef $base_type base_type;";
159159
emit "typedef $full_name enum_type;";
160-
emit "static const base_type first_item_value = $base;";
161-
emit "static const base_type last_item_value = $last_value;";
160+
emit "static constexpr base_type first_item_value = $base;";
161+
emit "static constexpr base_type last_item_value = $last_value;";
162162
# Cast the enum to integer in order to avoid GCC <= 4.5 assuming the value range is correct.
163163
emit_block {
164164
emit "return (value >= first_item_value && ",
165165
"value <= last_item_value);";
166166
} "static inline bool is_valid(base_type value) ";
167-
emit "static const enum_type first_item = (enum_type)first_item_value;";
168-
emit "static const enum_type last_item = (enum_type)last_item_value;";
167+
emit "static constexpr enum_type first_item = (enum_type)first_item_value;";
168+
emit "static constexpr enum_type last_item = (enum_type)last_item_value;";
169169
emit "static const char *const key_table[", $count, "];";
170170
if ($complex) {
171171
emit "static const DFHack::enum_identity::ComplexData complex;";

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Template for new versions:
1818

1919
# Future
2020

21+
## Structures
22+
- updated codegen to generate enum trait constants as ``consteval``
23+
2124
## Structures
2225

2326
# 53.04-r1

0 commit comments

Comments
 (0)