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_map.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_map.cpp')
| -rw-r--r-- | src/string_map.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/string_map.cpp b/src/string_map.cpp index b5db63e90..74a16de73 100644 --- a/src/string_map.cpp +++ b/src/string_map.cpp @@ -1,6 +1,13 @@ struct StringHashKey { u32 hash; String string; + + operator String() const noexcept { + return this->string; + } + operator String const &() const noexcept { + return this->string; + } }; gb_internal gb_inline StringHashKey string_hash_string(String const &s) { @@ -283,11 +290,11 @@ gb_internal gb_inline void string_map_clear(StringMap<T> *h) { template <typename T> -gb_internal StringMapEntry<T> *begin(StringMap<T> &m) { +gb_internal StringMapEntry<T> *begin(StringMap<T> &m) noexcept { return m.entries.data; } template <typename T> -gb_internal StringMapEntry<T> const *begin(StringMap<T> const &m) { +gb_internal StringMapEntry<T> const *begin(StringMap<T> const &m) noexcept { return m.entries.data; } @@ -298,6 +305,6 @@ gb_internal StringMapEntry<T> *end(StringMap<T> &m) { } template <typename T> -gb_internal StringMapEntry<T> const *end(StringMap<T> const &m) { +gb_internal StringMapEntry<T> const *end(StringMap<T> const &m) noexcept { return m.entries.data + m.entries.count; }
\ No newline at end of file |