diff --git a/src/library/phash_map.h b/src/library/phash_map.h index 9f7a295b5a..bf372bdd0e 100644 --- a/src/library/phash_map.h +++ b/src/library/phash_map.h @@ -30,6 +30,10 @@ public: default_map_entry() {} default_map_entry(key_value const & d, unsigned h):parent(d, h) {} static default_map_entry mk_deleted() { return default_map_entry(false); } + default_map_entry & operator=(default_map_entry const & src) { + parent::operator=(src); + return *this; + } }; template @@ -97,7 +101,7 @@ public: } template - void for_each(F && f) { + void for_each(F && f) const { m_table.for_each([&](key_value const & e) { f(e.m_key, e.m_value); }); diff --git a/src/library/phashtable.h b/src/library/phashtable.h index ae15b14b81..9489283f65 100644 --- a/src/library/phashtable.h +++ b/src/library/phashtable.h @@ -59,6 +59,16 @@ public: new (&m_data) T(d); m_state = Used; } + + default_hash_entry & operator=(default_hash_entry const & src) { + if (is_used()) + m_data.~T(); + m_hash = src.m_hash; + m_state = src.m_state; + if (m_state == Used) + new (&m_data) T(src.get_data()); + return *this; + } }; template @@ -194,7 +204,7 @@ public: #undef INSERT_LOOP_BODY template - void for_each(F && fn) { + void for_each(F && fn) const { m_table.for_each([&](entry const & e) { if (e.is_used()) { fn(e.get_data());