diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2019-01-22 12:15:23 +0100 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2019-01-22 12:17:26 +0100 |
commit | 70a52d6bd8c45630ca90e945fc4d716fe9114010 (patch) | |
tree | ea207203553e6ee3da682cb2a4d915475e26f1ed | |
parent | 5d4b0377b99ddc4112b8ffb2b787eac0b383081c (diff) |
Convert all other enum class consts to static constexpr
Fixes https://github.com/harfbuzz/harfbuzz/issues/1553
-rw-r--r-- | src/hb-cff-interp-common.hh | 2 | ||||
-rw-r--r-- | src/hb-iter.hh | 2 | ||||
-rw-r--r-- | src/hb-machinery.hh | 12 | ||||
-rw-r--r-- | src/hb-open-type.hh | 8 | ||||
-rw-r--r-- | src/hb-set-digest.hh | 4 | ||||
-rw-r--r-- | src/hb-set.hh | 10 | ||||
-rw-r--r-- | src/hb-vector.hh | 2 |
7 files changed, 20 insertions, 20 deletions
diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index 7b0b829f..72e9e06c 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 c83ccb39..c4ab26dc 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 f1ac8489..f09c2456 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 <typename Context, typename Return, unsigned int MaxDebugDepth> struct hb_dispatch_context_t { - enum { max_debug_depth = MaxDebugDepth }; + static constexpr unsigned max_debug_depth = MaxDebugDepth; typedef Return return_t; template <typename T, typename F> 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 67af16fc..6abb8986 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -356,7 +356,7 @@ template <typename Type> 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 <typename Type, typename LenType=HBUINT16> 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<Type> template <typename Type, typename LenType=HBUINT16> 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 <typename Type> 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 9f49af17..7ec275e4 100644 --- a/src/hb-set-digest.hh +++ b/src/hb-set-digest.hh @@ -48,8 +48,8 @@ template <typename mask_t, unsigned int shift> 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 81b9064d..64a13638 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<elt_t, PAGE_BITS / 8> 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 587a85fb..2fd739b5 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -36,7 +36,7 @@ template <typename Type> 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 (); } |