Skip to content

Commit

Permalink
Don't enable ordinalCount() or bitCount() for bitset enums
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Nov 22, 2023
1 parent 414357a commit d4399c5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
10 changes: 0 additions & 10 deletions packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ enum class Errata : uint32_t {

YG_DEFINE_ENUM_FLAG_OPERATORS(Errata)

template <>
constexpr inline int32_t ordinalCount<Errata>() {
return 6;
}

template <>
constexpr inline int32_t bitCount<Errata>() {
return 3;
}

constexpr inline Errata scopedEnum(YGErrata unscoped) {
return static_cast<Errata>(unscoped);
}
Expand Down
10 changes: 0 additions & 10 deletions packages/react-native/ReactCommon/yoga/yoga/enums/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ enum class PrintOptions : uint32_t {

YG_DEFINE_ENUM_FLAG_OPERATORS(PrintOptions)

template <>
constexpr inline int32_t ordinalCount<PrintOptions>() {
return 3;
}

template <>
constexpr inline int32_t bitCount<PrintOptions>() {
return 2;
}

constexpr inline PrintOptions scopedEnum(YGPrintOptions unscoped) {
return static_cast<PrintOptions>(unscoped);
}
Expand Down

0 comments on commit d4399c5

Please sign in to comment.