From 61c04384256390d3ef5d0fd576bd2bc2fb34624e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 20 Jul 2022 14:43:58 -0600 Subject: [PATCH] [map] Allow geting non-const value pointer out with has() --- src/hb-map.hh | 3 ++- src/test-map.cc | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hb-map.hh b/src/hb-map.hh index 6af018552..8ff7b2d7c 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -219,7 +219,8 @@ struct hb_hashmap_t /* Has interface. */ typedef const V& value_t; value_t operator [] (K k) const { return get (k); } - bool has (K key, const V **vp = nullptr) const + template + bool has (K key, VV **vp = nullptr) const { if (unlikely (!items)) return false; diff --git a/src/test-map.cc b/src/test-map.cc index 8cabf53bd..473e8f4f6 100644 --- a/src/test-map.cc +++ b/src/test-map.cc @@ -217,6 +217,10 @@ main (int argc, char **argv) hb_hashmap_t>> m; m.get (0); + const hb::unique_ptr> *v1; + m.has (0, &v1); + hb::unique_ptr> *v2; + m.has (0, &v2); } return 0;