diff --git a/src/ptr_map.cpp b/src/ptr_map.cpp index 19ba37085..932f05d69 100644 --- a/src/ptr_map.cpp +++ b/src/ptr_map.cpp @@ -13,16 +13,22 @@ enum : MapIndex { MAP_SENTINEL = ~(MapIndex)0 }; template struct PtrMapConstant { - static constexpr void const *TOMBSTONE = reinterpret_cast(~(uintptr)0); + static gb_inline T const TOMBSTONE() { + return (T)reinterpret_cast(~(uintptr)0); + } }; template <> struct PtrMapConstant { - static constexpr u64 TOMBSTONE = ~(u64)0; + static gb_inline u64 const TOMBSTONE() { + return ~(u64)0; + } }; template <> struct PtrMapConstant { - static constexpr i64 TOMBSTONE = ~(i64)0; + static gb_inline i64 const TOMBSTONE() { + return ~(i64)0; + } }; template @@ -113,7 +119,7 @@ gb_internal void map__insert(PtrMap *h, K key, V const &value) { MapIndex original_index = index; do { auto *entry = h->entries+index; - if (!entry->key || entry->key == PtrMapConstant::TOMBSTONE) { + if (!entry->key || entry->key == PtrMapConstant::TOMBSTONE()) { entry->key = key; entry->value = value; h->count += 1; @@ -161,7 +167,7 @@ gb_internal void map_reserve(PtrMap *h, isize cap) { for (u32 i = 0; i < h->capacity; i++) { auto *entry = h->entries+i; if (entry->key && - entry->key != PtrMapConstant::TOMBSTONE) { + entry->key != PtrMapConstant::TOMBSTONE()) { map__insert(&new_h, entry->key, entry->value); } } @@ -271,7 +277,7 @@ template gb_internal void map_remove(PtrMap *h, K key) { MapIndex found_index = 0; if (map_try_get(h, key, &found_index)) { - h->entries[found_index].key = cast(K)PtrMapConstant::TOMBSTONE; + h->entries[found_index].key = cast(K)PtrMapConstant::TOMBSTONE(); h->count -= 1; } } @@ -381,7 +387,7 @@ struct PtrMapIterator { return *this; } PtrMapEntry *entry = map->entries+index; - if (entry->key && entry->key != PtrMapConstant::TOMBSTONE) { + if (entry->key && entry->key != PtrMapConstant::TOMBSTONE()) { return *this; } } @@ -418,7 +424,7 @@ gb_internal PtrMapIterator begin(PtrMap &m) noexcept { MapIndex index = 0; while (index < m.capacity) { auto key = m.entries[index].key; - if (key && key != PtrMapConstant::TOMBSTONE) { + if (key && key != PtrMapConstant::TOMBSTONE()) { break; } index++; @@ -434,7 +440,7 @@ gb_internal PtrMapIterator const begin(PtrMap const &m) noexcept { MapIndex index = 0; while (index < m.capacity) { auto key = m.entries[index].key; - if (key && key != PtrMapConstant::TOMBSTONE) { + if (key && key != PtrMapConstant::TOMBSTONE()) { break; } index++;