diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 05c98ef20..bc170b054 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -83,7 +83,8 @@ static inline constexpr uint16_t hb_uint16_swap (uint16_t v) static inline constexpr uint32_t hb_uint32_swap (uint32_t v) { return (hb_uint16_swap (v) << 16) | hb_uint16_swap (v >> 16); } -template struct BEInt; +template +struct BEInt; template struct BEInt { @@ -124,14 +125,16 @@ struct BEInt template struct BEInt { + static_assert (!hb_is_signed (Type), ""); public: BEInt () = default; constexpr BEInt (Type V) : v {uint8_t ((V >> 16) & 0xFF), - uint8_t ((V >> 8) & 0xFF), - uint8_t ((V ) & 0xFF)} {} + uint8_t ((V >> 8) & 0xFF), + uint8_t ((V ) & 0xFF)} {} + constexpr operator Type () const { return (v[0] << 16) - + (v[1] << 8) - + (v[2] ); } + + (v[1] << 8) + + (v[2] ); } private: uint8_t v[3]; }; template diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 28353e4e5..067107965 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -53,14 +53,18 @@ namespace OT { */ /* Integer types in big-endian order and no alignment requirement */ -template +template > struct IntType { typedef Type type; - typedef hb_conditional wide_type; - IntType& operator = (wide_type i) { v = i; return *this; } - operator wide_type () const { return v; } + IntType () = default; + explicit constexpr IntType (Wide V) : v {V} {} + IntType& operator = (Wide i) { v = i; return *this; } + operator Wide () const { return v; } + bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; } bool operator != (const IntType &o) const { return !(*this == o); }