diff --git a/src/hb-map.hh b/src/hb-map.hh index 9ffa83a8a..bbb1bef5d 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -34,11 +34,9 @@ * hb_hashmap_t */ -/* TODO if K/V is signed integer, -1 is not a good default. - * Don't know how to get to -MAX using bit work. */ template + K kINVALID = hb_is_pointer (K) ? 0 : hb_is_signed (K) ? hb_int_min (K) : (K) -1, + V vINVALID = hb_is_pointer (V) ? 0 : hb_is_signed (V) ? hb_int_min (V) : (V) -1> struct hb_hashmap_t { HB_DELETE_COPY_ASSIGN (hb_hashmap_t); diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 0dcf79320..bb67b03a8 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -138,6 +138,12 @@ template <> struct hb_is_signed { enum { value = false }; }; template <> struct hb_is_signed { enum { value = false }; }; #define hb_is_signed(T) hb_is_signed::value +template struct hb_int_min { static constexpr T value = 0; }; +template <> struct hb_int_min { static constexpr char value = CHAR_MIN; }; +template <> struct hb_int_min { static constexpr int value = INT_MIN; }; +template <> struct hb_int_min { static constexpr long value = LONG_MIN; }; +#define hb_int_min(T) hb_int_min::value + template struct hb_signedness_int; template <> struct hb_signedness_int { typedef unsigned int value; }; template <> struct hb_signedness_int { typedef signed int value; }; diff --git a/src/hb-ot-cff1-table.cc b/src/hb-ot-cff1-table.cc index 5132801bf..1d97e5444 100644 --- a/src/hb-ot-cff1-table.cc +++ b/src/hb-ot-cff1-table.cc @@ -26,7 +26,6 @@ #include "hb-ot-cff1-table.hh" #include "hb-cff1-interp-cs.hh" -#include using namespace CFF; diff --git a/src/hb-ot-cff2-table.cc b/src/hb-ot-cff2-table.cc index 15cdbaa85..d2463d785 100644 --- a/src/hb-ot-cff2-table.cc +++ b/src/hb-ot-cff2-table.cc @@ -26,7 +26,6 @@ #include "hb-ot-cff2-table.hh" #include "hb-cff2-interp-cs.hh" -#include using namespace CFF; diff --git a/src/hb.hh b/src/hb.hh index ee35c4dd9..0336ed568 100644 --- a/src/hb.hh +++ b/src/hb.hh @@ -167,8 +167,7 @@ #include "hb-aat.h" #define HB_AAT_H_IN -#include "hb-aat.h" - +#include #include #include #include