Skip to content

Commit

Permalink
pre-v1.0f-update
Browse files Browse the repository at this point in the history
  • Loading branch information
dakka committed Apr 5, 2024
1 parent 5ae8b7d commit 46dff13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ It can be observed that there is only one copy of the scoped or unscoped enum va
| [gcc](https://gcc.gnu.org/projects/cxx-status.html) | `11`, `12`, `13`| `std::format` not complete in `11`, `12` | `<= 10` |
| [clang](https://clang.llvm.org/cxx_status.html) | `15`, `16`| Catch2 needs `cxx_std_20` in `15` | `<= 14` |
| [msvc](https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance) | `16`, `17` | Visual Studio 2019,2022, latest `17.9.5`| `<= 16.9`|
| [xcode](https://developer.apple.com/support/xcode/) | `15` | Some clang issues| `<= 14`|
| [xcode](https://developer.apple.com/support/xcode/) | `15` | Some issues with `constexpr`, workarounds| `<= 14`|

[^1]:&copy; 2024 Fix8 Market Technologies Pty Ltd, David L. Dight.
[^2]:&copy; 2019 - 2024 Daniil Goncharov
5 changes: 3 additions & 2 deletions include/fix8/conjure_enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class conjure_enum final

#if defined(__clang__) && defined(__apple_build_version__) // std::count_if not constexpr in xcode/clang
template<std::size_t N>
static constexpr auto count_if_constexpr(const std::array<bool, N>& valid) noexcept
static constexpr auto count_if_constexpr(const bool (&valid)[N]) noexcept
{
std::size_t cnt{};
for(std::size_t nn{}; nn < N; ++nn)
Expand All @@ -195,10 +195,11 @@ class conjure_enum final
template<std::size_t... I>
static constexpr auto _values(std::index_sequence<I...>) noexcept
{
constexpr std::array<bool, sizeof...(I)> valid { is_valid<static_cast<T>(enum_min_value + I)>()... };
#if defined(__clang__) && defined(__apple_build_version__)
constexpr bool valid[sizeof...(I)] { is_valid<static_cast<T>(enum_min_value + I)>()... };
constexpr auto num_valid { count_if_constexpr(valid) };
#else
constexpr std::array<bool, sizeof...(I)> valid { is_valid<static_cast<T>(enum_min_value + I)>()... };
constexpr auto num_valid { std::count_if(valid.cbegin(), valid.cend(), [](bool val) noexcept { return val; }) };
#endif
static_assert(num_valid > 0, "conjure_enum requires non-empty enum");
Expand Down

0 comments on commit 46dff13

Please sign in to comment.