From 5da341ce92352860fb43296cdeb7ed4141ff2864 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 27 Jun 2022 13:29:22 -0600 Subject: [PATCH] [map] Another try at hiding minus1 To fix https://github.com/harfbuzz/harfbuzz/issues/3684 --- src/hb-map.hh | 8 +++++++- src/hb-static.cc | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hb-map.hh b/src/hb-map.hh index ad52e69fe..5efad8d20 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -34,6 +34,8 @@ * hb_hashmap_t */ +extern HB_INTERNAL const hb_codepoint_t minus_1; + template struct hb_hashmap_t @@ -80,7 +82,11 @@ struct hb_hashmap_t static inline const V& default_value () { return Null(V); }; template - static inline const V& default_value () { static const V minus_1 = -1; return minus_1; }; + static inline const V& default_value () + { + static_assert (hb_is_same (V, hb_codepoint_t), ""); + return minus_1; + }; void clear () { diff --git a/src/hb-static.cc b/src/hb-static.cc index 7cc51be61..5c5ecce88 100644 --- a/src/hb-static.cc +++ b/src/hb-static.cc @@ -53,6 +53,9 @@ DEFINE_NULL_NAMESPACE_BYTES (AAT, SettingName) = {0xFF,0xFF, 0xFF,0xFF}; const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF}; +/* hb_map_t */ + +const hb_codepoint_t minus_1 = -1; /* hb_face_t */