diff options
| author | gingerBill <bill@gingerbill.org> | 2023-01-03 12:18:35 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-01-03 12:18:35 +0000 |
| commit | 747a11a954824da7960a247299986f56d1316773 (patch) | |
| tree | d3ac481d2293ad641adcb9bc0fbe549829a0b43f /src/string_set.cpp | |
| parent | 252be0fb417f9cdde5e9c4b348cd995a20433aea (diff) | |
Allow all set entry types to be implicitly cast to their key/value type to allow for easier iteration
Diffstat (limited to 'src/string_set.cpp')
| -rw-r--r-- | src/string_set.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/string_set.cpp b/src/string_set.cpp index 753afa9bf..fb4640c20 100644 --- a/src/string_set.cpp +++ b/src/string_set.cpp @@ -2,6 +2,13 @@ struct StringSetEntry { u32 hash; MapIndex next; String value; + + operator String const() const noexcept { + return this->value; + } + operator String const &() const noexcept { + return this->value; + } }; struct StringSet { @@ -226,18 +233,18 @@ gb_internal gb_inline void string_set_clear(StringSet *s) { } -gb_internal StringSetEntry *begin(StringSet &m) { +gb_internal StringSetEntry *begin(StringSet &m) noexcept { return m.entries.data; } -gb_internal StringSetEntry const *begin(StringSet const &m) { +gb_internal StringSetEntry const *begin(StringSet const &m) noexcept { return m.entries.data; } -gb_internal StringSetEntry *end(StringSet &m) { +gb_internal StringSetEntry *end(StringSet &m) noexcept { return m.entries.data + m.entries.count; } -gb_internal StringSetEntry const *end(StringSet const &m) { +gb_internal StringSetEntry const *end(StringSet const &m) noexcept { return m.entries.data + m.entries.count; }
\ No newline at end of file |