[map] Fix iter_ref () and test it

This commit is contained in:
Behdad Esfahbod 2022-06-03 01:30:27 -06:00
parent a42c624fca
commit 88f00ecb84
2 changed files with 4 additions and 2 deletions

View File

@ -94,7 +94,7 @@ struct hb_hashmap_t
bool operator == (const K &o) { return hb_deref (key) == hb_deref (o); }
bool operator == (const item_t &o) { return *this == o.key; }
hb_pair_t<K, V> get_pair() const { return hb_pair_t<K, V> (key, value); }
hb_pair_t<const K &, const V &> get_pair_ref() const { return hb_pair_t<const K, const V &> (key, value); }
hb_pair_t<const K &, const V &> get_pair_ref() const { return hb_pair_t<const K &, const V &> (key, value); }
uint32_t total_hash () const
{ return (hash * 31) + hb_hash (value); }
@ -286,7 +286,7 @@ struct hb_hashmap_t
(
+ hb_array (items, mask ? mask + 1 : 0)
| hb_filter (&item_t::is_real)
| hb_map (&item_t::get_pair)
| hb_map (&item_t::get_pair_ref)
)
auto keys () const HB_AUTO_RETURN
(

View File

@ -194,6 +194,7 @@ main (int argc, char **argv)
m.get (hb::shared_ptr<hb_set_t> ());
m.get (hb::shared_ptr<hb_set_t> (hb_set_get_empty ()));
m.iter ();
}
/* Test hb::unique_ptr. */
hb_hash (hb::unique_ptr<hb_set_t> ());
@ -202,6 +203,7 @@ main (int argc, char **argv)
m.get (hb::unique_ptr<hb_set_t> ());
m.get (hb::unique_ptr<hb_set_t> (hb_set_get_empty ()));
m.iter_ref ();
}
return 0;