Convert all other enum class consts to static constexpr
Fixes https://github.com/harfbuzz/harfbuzz/issues/1553
diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh
index 7b0b829..72e9e06 100644
--- a/src/hb-cff-interp-common.hh
+++ b/src/hb-cff-interp-common.hh
@@ -477,7 +477,7 @@
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 c83ccb3..c4ab26d 100644
--- a/src/hb-iter.hh
+++ b/src/hb-iter.hh
@@ -48,7 +48,7 @@
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 f1ac848..f09c245 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -97,19 +97,19 @@
#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 @@
#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 @@
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 67af16f..6abb898 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -356,7 +356,7 @@
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 @@
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 @@
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 @@
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 9f49af1..7ec275e 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 81b9064..64a1363 100644
--- a/src/hb-set.hh
+++ b/src/hb-set.hh
@@ -161,7 +161,7 @@
}
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 @@
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 587a85f..2fd739b 100644
--- a/src/hb-vector.hh
+++ b/src/hb-vector.hh
@@ -36,7 +36,7 @@
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 (); }