From d4399c5f15bdf926903043c2448bc7461bb6a3f9 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 22 Nov 2023 11:06:31 -0800 Subject: [PATCH] Don't enable `ordinalCount()` or `bitCount()` for bitset enums Summary: Bitfield enums are not sequential, so use of these functions on these enums would be invalid. I looked at whether we could trivially move `bitCount` to template based on `ordinalCount`. `bitCount` must be constexpr, since we use it directly as a bit-field size constant. `log2` and `ceil` to be constexpr, which isn't here until C++ 26. Reviewed By: javache Differential Revision: D51518899 fbshipit-source-id: 256f15bbed517be6f90bf43baa43ce96e9259a71 --- .../react-native/ReactCommon/yoga/yoga/enums/Errata.h | 10 ---------- .../ReactCommon/yoga/yoga/enums/PrintOptions.h | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h b/packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h index 6a085bf58da825..134f5fffc012fe 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h +++ b/packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h @@ -26,16 +26,6 @@ enum class Errata : uint32_t { YG_DEFINE_ENUM_FLAG_OPERATORS(Errata) -template <> -constexpr inline int32_t ordinalCount() { - return 6; -} - -template <> -constexpr inline int32_t bitCount() { - return 3; -} - constexpr inline Errata scopedEnum(YGErrata unscoped) { return static_cast(unscoped); } diff --git a/packages/react-native/ReactCommon/yoga/yoga/enums/PrintOptions.h b/packages/react-native/ReactCommon/yoga/yoga/enums/PrintOptions.h index c61fbc6383a279..90d0043c74a4dd 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/enums/PrintOptions.h +++ b/packages/react-native/ReactCommon/yoga/yoga/enums/PrintOptions.h @@ -23,16 +23,6 @@ enum class PrintOptions : uint32_t { YG_DEFINE_ENUM_FLAG_OPERATORS(PrintOptions) -template <> -constexpr inline int32_t ordinalCount() { - return 3; -} - -template <> -constexpr inline int32_t bitCount() { - return 2; -} - constexpr inline PrintOptions scopedEnum(YGPrintOptions unscoped) { return static_cast(unscoped); }