diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 55c92841f..446d87e28 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -128,7 +128,7 @@ struct BEInt template struct BEInt { - static_assert (!hb_is_signed (Type), ""); + static_assert (!std::is_signed::value, ""); public: BEInt () = default; constexpr BEInt (Type V) : v {uint8_t ((V >> 16) & 0xFF), @@ -218,7 +218,7 @@ struct impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, hb_deref (v).hash ()) template constexpr auto + hb_enable_if (std::is_integral::value)> constexpr auto impl (const T& v, hb_priority<0>) const HB_AUTO_RETURN ( /* Knuth's multiplicative method: */ @@ -808,7 +808,7 @@ hb_ceil_to_4 (unsigned int v) template static inline bool hb_in_range (T u, T lo, T hi) { - static_assert (!hb_is_signed::value, ""); + static_assert (!std::is_signed::value, ""); /* The casts below are important as if T is smaller than int, * the subtract results will become a signed int! */ diff --git a/src/hb-map.hh b/src/hb-map.hh index c14a52af0..790457f26 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -35,8 +35,8 @@ */ template + K kINVALID = hb_is_pointer (K) ? 0 : std::is_signed::value ? hb_int_min (K) : (K) -1, + V vINVALID = hb_is_pointer (V) ? 0 : std::is_signed::value ? hb_int_min (V) : (V) -1> struct hb_hashmap_t { hb_hashmap_t () { init (); } @@ -59,8 +59,8 @@ struct hb_hashmap_t hb_copy (o, *this); } - static_assert (hb_is_integral (K) || hb_is_pointer (K), ""); - static_assert (hb_is_integral (V) || hb_is_pointer (V), ""); + static_assert (std::is_integral::value || hb_is_pointer (K), ""); + static_assert (std::is_integral::value || hb_is_pointer (V), ""); struct item_t { diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 2a6f90a43..3808d917b 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -220,50 +220,6 @@ struct hb_reference_wrapper /* Type traits */ -template -using hb_is_integral = hb_bool_constant< - hb_is_same (hb_decay, char) || - hb_is_same (hb_decay, signed char) || - hb_is_same (hb_decay, unsigned char) || - hb_is_same (hb_decay, signed int) || - hb_is_same (hb_decay, unsigned int) || - hb_is_same (hb_decay, signed short) || - hb_is_same (hb_decay, unsigned short) || - hb_is_same (hb_decay, signed long) || - hb_is_same (hb_decay, unsigned long) || - hb_is_same (hb_decay, signed long long) || - hb_is_same (hb_decay, unsigned long long) || - false ->; -#define hb_is_integral(T) hb_is_integral::value -template -using hb_is_floating_point = hb_bool_constant< - hb_is_same (hb_decay, float) || - hb_is_same (hb_decay, double) || - hb_is_same (hb_decay, long double) || - false ->; -#define hb_is_floating_point(T) hb_is_floating_point::value -template -using hb_is_arithmetic = hb_bool_constant< - hb_is_integral (T) || - hb_is_floating_point (T) || - false ->; -#define hb_is_arithmetic(T) hb_is_arithmetic::value - - -template struct hb_is_signed_; -template struct hb_is_signed_ : hb_false_type {}; -template struct hb_is_signed_ : hb_bool_constant<(T) -1 < (T) 0> {}; -template struct hb_is_signed : hb_is_signed_ {}; -#define hb_is_signed(T) hb_is_signed::value -template struct hb_is_unsigned_; -template struct hb_is_unsigned_ : hb_false_type {}; -template struct hb_is_unsigned_ : hb_bool_constant<(T) 0 < (T) -1> {}; -template struct hb_is_unsigned : hb_is_unsigned_ {}; -#define hb_is_unsigned(T) hb_is_unsigned::value - template struct hb_int_min; template <> struct hb_int_min : hb_integral_constant {}; template <> struct hb_int_min : hb_integral_constant {}; diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index d3712f045..1504584f1 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -64,7 +64,7 @@ struct IntType IntType& operator = (Type i) { v = i; return *this; } /* For reason we define cast out operator for signed/unsigned, instead of Type, see: * https://github.com/harfbuzz/harfbuzz/pull/2875/commits/09836013995cab2b9f07577a179ad7b024130467 */ - operator hb_conditional () const { return v; } + operator hb_conditional::value, signed, unsigned> () const { return v; } bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; } bool operator != (const IntType &o) const { return !(*this == o); } @@ -86,7 +86,7 @@ struct IntType return pb->cmp (*pa); } template ::value && sizeof (Type2) < sizeof (int) && sizeof (Type) < sizeof (int))> int cmp (Type2 a) const diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh index 77bad06b8..7b83fe1a2 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh @@ -376,7 +376,7 @@ struct hb_serialize_context_t err (HB_SERIALIZE_ERROR_OTHER); link.width = sizeof (T); - link.is_signed = hb_is_signed (hb_unwrap_type (T)); + link.is_signed = std::is_signed::value; link.whence = (unsigned) whence; link.position = (const char *) &ofs - current->head; link.bias = bias; diff --git a/src/test-meta.cc b/src/test-meta.cc index c6715ac58..0fb2385af 100644 --- a/src/test-meta.cc +++ b/src/test-meta.cc @@ -95,9 +95,6 @@ main (int argc, char **argv) static_assert (hb_is_base_of (X, const Y), ""); static_assert (!hb_is_base_of (Y, X), ""); - static_assert (hb_is_signed (hb_unwrap_type (U>>)), ""); - static_assert (hb_is_unsigned (hb_unwrap_type (U>>>)), ""); - /* TODO Add more meaningful tests. */ return 0;