Prefer constexpr to preprocessor conditionals when checking endianness
[folly.git] / folly / experimental / EventCount.h
index e0f5a94d6975988ce885c264f0632a69e0d8062e..7c491542013f0b4e474456384d9a558193af859c 100644 (file)
@@ -126,13 +126,7 @@ class EventCount {
   static_assert(sizeof(uint32_t) == 4, "bad platform");
   static_assert(sizeof(uint64_t) == 8, "bad platform");
 
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-  static constexpr size_t kEpochOffset = 1;
-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-  static constexpr size_t kEpochOffset = 0;  // in units of sizeof(int)
-#else
-# error Your machine uses a weird endianness!
-#endif
+  static constexpr size_t kEpochOffset = kIsLittleEndian ? 1 : 0;
 
   // val_ stores the epoch in the most significant 32 bits and the
   // waiter count in the least significant 32 bits.