Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev to Main pre 1.0e #7

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ It can be observed that there is only _one_ copy of the scoped enum value string
| :--- | :--- | :--- | ---: |
| [gcc](https://gcc.gnu.org/projects/cxx-status.html) | `11`, `12`, `13`, `14`| `std::format` not complete in `11`, `12` | `<= 10` |
| [clang](https://clang.llvm.org/cxx_status.html) | `15`, `16`, `17`, `18`| 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.10.2`| `<= 16.9`|
| [msvc](https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance) | `16`, `17` | Visual Studio 2019,2022, latest `17.10.3`| `<= 16.9`|
| [xcode](https://developer.apple.com/support/xcode/) | `15` | Apple LLVM 15.0.0, some issues with `constexpr`, workarounds| `<= 14`|

# 9. Compiler issues
Expand Down
23 changes: 6 additions & 17 deletions include/fix8/conjure_enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,9 @@ class conjure_enum
requires std::invocable<Fn&&, T, Args...>
[[maybe_unused]] static constexpr auto for_each_n(int n, Fn&& func, Args&&... args) noexcept
{
for (int ii{}; const auto ev : values)
{
if (ii++ < n)
std::invoke(std::forward<Fn>(func), ev, std::forward<Args>(args)...);
else
break;
}
const auto mnv { std::min(static_cast<int>(count()), n) };
for (int ii{}; ii < mnv; ++ii)
std::invoke(std::forward<Fn>(func), values[ii], std::forward<Args>(args)...);
return std::bind(std::forward<Fn>(func), std::placeholders::_1, std::forward<Args>(args)...);
}

Expand Down Expand Up @@ -697,16 +693,9 @@ class enum_bitset
requires std::invocable<Fn&&, T, Args...>
[[maybe_unused]] constexpr auto for_each_n(int n, Fn&& func, Args&&... args) noexcept
{
for (int ii{}; const auto ev : conjure_enum<T>::values)
{
if (test(ev))
{
if (ii++ < n)
std::invoke(std::forward<Fn>(func), ev, std::forward<Args>(args)...);
else
break;
}
}
for (int ii{}, jj{}; ii < static_cast<int>(countof) && jj < n; ++ii)
if (const auto ev{conjure_enum<T>::values[ii]}; test(ev))
std::invoke(std::forward<Fn>(func), ev, std::forward<Args>(args)...), ++jj;
return std::bind(std::forward<Fn>(func), std::placeholders::_1, std::forward<Args>(args)...);
}

Expand Down
17 changes: 6 additions & 11 deletions utests/edgetests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,18 @@ namespace TEST

namespace test::rsp::gd
{

class AFrame
{
public:
enum class PreFrames
{ one };
};
class AFrame
{
public:
enum class PreFrames { one };
};
}

namespace test::util
{
template <typename E>
[[nodiscard]]
constexpr size_t countOf()
{
return FIX8::conjure_enum<E>::count();
}
constexpr size_t countOf() { return FIX8::conjure_enum<E>::count(); }
}

//-----------------------------------------------------------------------------------------
Expand Down
8 changes: 5 additions & 3 deletions utests/unittests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,14 @@ TEST_CASE("for_each")
//-----------------------------------------------------------------------------------------
TEST_CASE("for_each_n")
{
int total{};
conjure_enum<component>::for_each_n(3, [](component val, int& tot)
int total{}, count{};
conjure_enum<component>::for_each_n(3, [](component val, int& tot, int& cnt)
{
tot += static_cast<int>(val);
}, std::ref(total));
++cnt;
}, std::ref(total), std::ref(count));
REQUIRE(total == 3);
REQUIRE(count == 3);

struct foo
{
Expand Down