[meta] Use more std type_traits
diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 55c9284..446d87e 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh
@@ -128,7 +128,7 @@ template <typename Type> struct BEInt<Type, 3> { - static_assert (!hb_is_signed (Type), ""); + static_assert (!std::is_signed<Type>::value, ""); public: BEInt () = default; constexpr BEInt (Type V) : v {uint8_t ((V >> 16) & 0xFF), @@ -218,7 +218,7 @@ impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, hb_deref (v).hash ()) template <typename T, - hb_enable_if (hb_is_integral (T))> constexpr auto + hb_enable_if (std::is_integral<T>::value)> constexpr auto impl (const T& v, hb_priority<0>) const HB_AUTO_RETURN ( /* Knuth's multiplicative method: */ @@ -808,7 +808,7 @@ template <typename T> static inline bool hb_in_range (T u, T lo, T hi) { - static_assert (!hb_is_signed<T>::value, ""); + static_assert (!std::is_signed<T>::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 c14a52a..790457f 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh
@@ -35,8 +35,8 @@ */ template <typename K, typename V, - 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> + K kINVALID = hb_is_pointer (K) ? 0 : std::is_signed<K>::value ? hb_int_min (K) : (K) -1, + V vINVALID = hb_is_pointer (V) ? 0 : std::is_signed<V>::value ? hb_int_min (V) : (V) -1> struct hb_hashmap_t { hb_hashmap_t () { init (); } @@ -59,8 +59,8 @@ 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<K>::value || hb_is_pointer (K), ""); + static_assert (std::is_integral<V>::value || hb_is_pointer (V), ""); struct item_t {
diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 2a6f90a..3808d91 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh
@@ -220,50 +220,6 @@ /* Type traits */ -template <typename T> -using hb_is_integral = hb_bool_constant< - hb_is_same (hb_decay<T>, char) || - hb_is_same (hb_decay<T>, signed char) || - hb_is_same (hb_decay<T>, unsigned char) || - hb_is_same (hb_decay<T>, signed int) || - hb_is_same (hb_decay<T>, unsigned int) || - hb_is_same (hb_decay<T>, signed short) || - hb_is_same (hb_decay<T>, unsigned short) || - hb_is_same (hb_decay<T>, signed long) || - hb_is_same (hb_decay<T>, unsigned long) || - hb_is_same (hb_decay<T>, signed long long) || - hb_is_same (hb_decay<T>, unsigned long long) || - false ->; -#define hb_is_integral(T) hb_is_integral<T>::value -template <typename T> -using hb_is_floating_point = hb_bool_constant< - hb_is_same (hb_decay<T>, float) || - hb_is_same (hb_decay<T>, double) || - hb_is_same (hb_decay<T>, long double) || - false ->; -#define hb_is_floating_point(T) hb_is_floating_point<T>::value -template <typename T> -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<T>::value - - -template <typename T, bool is_arithmetic> struct hb_is_signed_; -template <typename T> struct hb_is_signed_<T, false> : hb_false_type {}; -template <typename T> struct hb_is_signed_<T, true> : hb_bool_constant<(T) -1 < (T) 0> {}; -template <typename T> struct hb_is_signed : hb_is_signed_<T, hb_is_arithmetic (T)> {}; -#define hb_is_signed(T) hb_is_signed<T>::value -template <typename T, bool is_arithmetic> struct hb_is_unsigned_; -template <typename T> struct hb_is_unsigned_<T, false> : hb_false_type {}; -template <typename T> struct hb_is_unsigned_<T, true> : hb_bool_constant<(T) 0 < (T) -1> {}; -template <typename T> struct hb_is_unsigned : hb_is_unsigned_<T, hb_is_arithmetic (T)> {}; -#define hb_is_unsigned(T) hb_is_unsigned<T>::value - template <typename T> struct hb_int_min; template <> struct hb_int_min<char> : hb_integral_constant<char, CHAR_MIN> {}; template <> struct hb_int_min<signed char> : hb_integral_constant<signed char, SCHAR_MIN> {};
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index d3712f0..1504584 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh
@@ -64,7 +64,7 @@ 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<hb_is_signed (Type), signed, unsigned> () const { return v; } + operator hb_conditional<std::is_signed<Type>::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 @@ return pb->cmp (*pa); } template <typename Type2, - hb_enable_if (hb_is_integral (Type2) && + hb_enable_if (std::is_integral<Type2>::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 77bad06..7b83fe1 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh
@@ -376,7 +376,7 @@ 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<hb_unwrap_type (T)>::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 c6715ac..0fb2385 100644 --- a/src/test-meta.cc +++ b/src/test-meta.cc
@@ -95,9 +95,6 @@ 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<U<U<int>>>)), ""); - static_assert (hb_is_unsigned (hb_unwrap_type (U<U<U<U<unsigned>>>>)), ""); - /* TODO Add more meaningful tests. */ return 0;