From f39809752909f193a9c60f4357a88ea1c3ce1162 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 25 Jan 2019 16:08:25 +0100 Subject: [PATCH] More static constexpr --- src/hb-machinery.hh | 10 +++++----- src/hb-set-digest.hh | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index ccad561b7..b22c2389c 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -115,28 +115,28 @@ static inline Type& StructAfter(TObject &X) unsigned int get_size () const { return (size); } \ static constexpr unsigned null_size = (size); \ static constexpr unsigned min_size = (size); \ - enum { static_size = (size) } + static constexpr unsigned 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)) \ static constexpr unsigned null_size = (size); \ - enum { min_size = (size) } + static constexpr unsigned min_size = (size) #define DEFINE_SIZE_MIN(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \ static constexpr unsigned null_size = (size); \ - enum { min_size = (size) } + static constexpr unsigned min_size = (size) #define DEFINE_SIZE_UNBOUNDED(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \ - enum { min_size = (size) } + static constexpr unsigned min_size = (size) #define DEFINE_SIZE_ARRAY(size, array) \ DEFINE_COMPILES_ASSERTION ((void) (array)[0].static_size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof ((array)[0])) \ static constexpr unsigned null_size = (size); \ - enum { min_size = (size) } + static constexpr unsigned min_size = (size) #define DEFINE_SIZE_ARRAY_SIZED(size, array) \ unsigned int get_size () const { return (size - (array).min_size + (array).get_size ()); } \ diff --git a/src/hb-set-digest.hh b/src/hb-set-digest.hh index 7ec275e41..b97526f77 100644 --- a/src/hb-set-digest.hh +++ b/src/hb-set-digest.hh @@ -50,13 +50,13 @@ struct hb_set_digest_lowest_bits_t { 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) - + (mask_bytes >= 4 ? 1 : 0) - + (mask_bytes >= 8 ? 1 : 0) - + (mask_bytes >= 16? 1 : 0) - + 0 }; + static constexpr unsigned num_bits = 0 + + (mask_bytes >= 1 ? 3 : 0) + + (mask_bytes >= 2 ? 1 : 0) + + (mask_bytes >= 4 ? 1 : 0) + + (mask_bytes >= 8 ? 1 : 0) + + (mask_bytes >= 16? 1 : 0) + + 0; static_assert ((shift < sizeof (hb_codepoint_t) * 8), ""); static_assert ((shift + num_bits <= sizeof (hb_codepoint_t) * 8), "");