More static constexpr
authorBehdad Esfahbod <behdad@behdad.org>
Fri, 25 Jan 2019 15:08:25 +0000 (16:08 +0100)
committerBehdad Esfahbod <behdad@behdad.org>
Fri, 25 Jan 2019 15:08:25 +0000 (16:08 +0100)
src/hb-machinery.hh
src/hb-set-digest.hh

index ccad561..b22c238 100644 (file)
@@ -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 ()); } \
index 7ec275e..b97526f 100644 (file)
@@ -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), "");