Allow all set entry types to be implicitly cast to their key/value type to allow for easier iteration

This commit is contained in:
gingerBill
2023-01-03 12:18:35 +00:00
parent 252be0fb41
commit 747a11a954
8 changed files with 50 additions and 50 deletions

View File

@@ -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;
}