From 485f043211ad21d6b0d926505f41c772330890a1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 20 Jul 2022 14:34:55 -0600 Subject: [PATCH] [map] Enable using hashmap with unique_ptr --- src/hb-map.hh | 11 +++++++++++ src/test-map.cc | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/src/hb-map.hh b/src/hb-map.hh index 71d45c106..df72821c1 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -479,4 +479,15 @@ void hb_hashmap_destroy (hb_hashmap_t* map) hb_free (map); } +namespace hb { + +template +struct vtable> +{ + static constexpr auto destroy = hb_hashmap_destroy; +}; + +} + + #endif /* HB_MAP_HH */ diff --git a/src/test-map.cc b/src/test-map.cc index fb52d14fe..8cabf53bd 100644 --- a/src/test-map.cc +++ b/src/test-map.cc @@ -212,6 +212,12 @@ main (int argc, char **argv) m.keys_ref (); m.values_ref (); } + /* Test more complex unique_ptr's. */ + { + hb_hashmap_t>> m; + + m.get (0); + } return 0; }