tcbrindle/flux

Projection with any() ?

calebtt opened this issue · 2 comments

Replacing some of my ranges filter stuff with flux made it around 25% faster, but I am unable to use flux::proj() for a projection with any():

return ! std::ranges::any_of(mappingsList, [](const auto vk) { return vk == 0; }, &CBActionMap::ButtonVirtualKeycode);
attempt:
return !flux::ref(mappingsList).any([](const auto vk) { return vk == 0; }, flux::proj(std::equal{}, &CBActionMap::ButtonVirtualKeycode));

Documentation doesn't really refer to flux::proj() much at all, beyond a couple instances of it's usage.

Nevermind, this works:

return !flux::ref(mappingsList).any(flux::proj([](const auto vk) { return vk == 0; },&CBActionMap::ButtonVirtualKeycode));

Replacing some of my ranges filter stuff with flux made it around 25% faster

That's great to hear!

Documentation doesn't really refer to flux::proj() much at all, beyond a couple instances of it's usage.

Yeah, there's lots of stuff missing from the documentation at the moment, it definitely needs improvement

Nevermind, this works:

return !flux::ref(mappingsList).any(flux::proj([](const auto vk) { return vk == 0; },&CBActionMap::ButtonVirtualKeycode));

Glad to hear you figured it out! If you're interested, I think the following should be equivalent but is a bit shorter and perhaps more readable: (the generated code should be the same though)

return flux::all(mappingsList, flux::proj(flux::pred::nonzero, &CBActionMap::ButtonVirtualKeycode));

If you have any more questions about Flux please let me know :)