diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index 7b0b829f1..72e9e06c8 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -477,7 +477,7 @@ struct stack_t unsigned int get_count () const { return count; } bool is_empty () const { return count == 0; } - enum { kSizeLimit = LIMIT }; + static constexpr unsigned kSizeLimit = LIMIT; protected: bool error; diff --git a/src/hb-iter.hh b/src/hb-iter.hh index c83ccb39b..c4ab26dc0 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -48,7 +48,7 @@ struct hb_iter_t typedef Iter iter_t; typedef iter_t const_iter_t; typedef Item item_t; - enum { item_size = hb_static_size (Item) }; + static constexpr unsigned item_size = hb_static_size (Item); private: /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index f1ac84895..f09c24564 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -97,19 +97,19 @@ static inline Type& StructAfter(TObject &X) #define DEFINE_SIZE_STATIC(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)) \ unsigned int get_size () const { return (size); } \ - enum { null_size = (size) }; \ - enum { min_size = (size) }; \ + static constexpr unsigned null_size = (size); \ + static constexpr unsigned min_size = (size); \ enum { static_size = (size) } #define DEFINE_SIZE_UNION(size, _member) \ DEFINE_COMPILES_ASSERTION ((void) this->u._member.static_size) \ DEFINE_INSTANCE_ASSERTION (sizeof(this->u._member) == (size)) \ - enum { null_size = (size) }; \ + static constexpr unsigned null_size = (size); \ enum { min_size = (size) } #define DEFINE_SIZE_MIN(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \ - enum { null_size = (size) }; \ + static constexpr unsigned null_size = (size); \ enum { min_size = (size) } #define DEFINE_SIZE_UNBOUNDED(size) \ @@ -119,7 +119,7 @@ static inline Type& StructAfter(TObject &X) #define DEFINE_SIZE_ARRAY(size, array) \ DEFINE_COMPILES_ASSERTION ((void) (array)[0].static_size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof ((array)[0])) \ - enum { null_size = (size) }; \ + static constexpr unsigned null_size = (size); \ enum { min_size = (size) } #define DEFINE_SIZE_ARRAY_SIZED(size, array) \ @@ -134,7 +134,7 @@ static inline Type& StructAfter(TObject &X) template struct hb_dispatch_context_t { - enum { max_debug_depth = MaxDebugDepth }; + static constexpr unsigned max_debug_depth = MaxDebugDepth; typedef Return return_t; template bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; } diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 67af16fcb..6abb89862 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -356,7 +356,7 @@ template struct UnsizedArrayOf { typedef Type item_t; - enum { item_size = hb_static_size (Type) }; + static constexpr unsigned item_size = hb_static_size (Type); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); @@ -512,7 +512,7 @@ template struct ArrayOf { typedef Type item_t; - enum { item_size = hb_static_size (Type) }; + static constexpr unsigned item_size = hb_static_size (Type); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType); @@ -682,7 +682,7 @@ struct OffsetListOf : OffsetArrayOf template struct HeadlessArrayOf { - enum { item_size = Type::static_size }; + static constexpr unsigned item_size = Type::static_size; HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (HeadlessArrayOf, Type, LenType); @@ -891,7 +891,7 @@ struct VarSizedBinSearchHeader template struct VarSizedBinSearchArrayOf { - enum { item_size = Type::static_size }; + static constexpr unsigned item_size = Type::static_size; HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (VarSizedBinSearchArrayOf, Type); diff --git a/src/hb-set-digest.hh b/src/hb-set-digest.hh index 9f49af178..7ec275e41 100644 --- a/src/hb-set-digest.hh +++ b/src/hb-set-digest.hh @@ -48,8 +48,8 @@ template struct hb_set_digest_lowest_bits_t { - enum { mask_bytes = sizeof (mask_t) }; - enum { mask_bits = sizeof (mask_t) * 8 }; + static constexpr unsigned mask_bytes = sizeof (mask_t); + static constexpr unsigned mask_bits = sizeof (mask_t) * 8; enum { num_bits = 0 + (mask_bytes >= 1 ? 3 : 0) + (mask_bytes >= 2 ? 1 : 0) diff --git a/src/hb-set.hh b/src/hb-set.hh index 81b9064d5..64a136385 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -161,7 +161,7 @@ struct hb_set_t } typedef unsigned long long elt_t; - enum { PAGE_BITS = 512 }; + static constexpr unsigned PAGE_BITS = 512; static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, ""); static unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } @@ -169,10 +169,10 @@ struct hb_set_t typedef hb_vector_size_t vector_t; - enum { ELT_BITS = sizeof (elt_t) * 8 }; - enum { ELT_MASK = ELT_BITS - 1 }; - enum { BITS = sizeof (vector_t) * 8 }; - enum { MASK = BITS - 1 }; + static constexpr unsigned ELT_BITS = sizeof (elt_t) * 8; + static constexpr unsigned ELT_MASK = ELT_BITS - 1; + static constexpr unsigned BITS = sizeof (vector_t) * 8; + static constexpr unsigned MASK = BITS - 1; static_assert ((unsigned) PAGE_BITS == (unsigned) BITS, ""); elt_t &elt (hb_codepoint_t g) { return v[(g & MASK) / ELT_BITS]; } diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 587a85fb8..2fd739b5c 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -36,7 +36,7 @@ template struct hb_vector_t { typedef Type item_t; - enum { item_size = hb_static_size (Type) }; + static constexpr unsigned item_size = hb_static_size (Type); HB_NO_COPY_ASSIGN_TEMPLATE (hb_vector_t, Type); hb_vector_t () { init (); }