[map] Enable using hashmap with unique_ptr

This commit is contained in:
Behdad Esfahbod 2022-07-20 14:34:55 -06:00
parent 53fd4c9236
commit 485f043211
2 changed files with 17 additions and 0 deletions

View File

@ -479,4 +479,15 @@ void hb_hashmap_destroy (hb_hashmap_t<K, V>* map)
hb_free (map);
}
namespace hb {
template <typename K, typename V>
struct vtable<hb_hashmap_t<K, V>>
{
static constexpr auto destroy = hb_hashmap_destroy<K,V>;
};
}
#endif /* HB_MAP_HH */

View File

@ -212,6 +212,12 @@ main (int argc, char **argv)
m.keys_ref ();
m.values_ref ();
}
/* Test more complex unique_ptr's. */
{
hb_hashmap_t<int, hb::unique_ptr<hb_hashmap_t<int, int>>> m;
m.get (0);
}
return 0;
}