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

Automatically unpack tuples in map/filter etc #225

Open
tcbrindle opened this issue Dec 4, 2024 · 0 comments
Open

Automatically unpack tuples in map/filter etc #225

tcbrindle opened this issue Dec 4, 2024 · 0 comments

Comments

@tcbrindle
Copy link
Owner

tcbrindle commented Dec 4, 2024

Today's Advent of Code was a reminder that even with flux::unpack, working with sequences which yield tuples can be really ugly:

screenshot

To avoid this, we could automatically unpack tuples in sequence adaptors where possible, allowing users to write something like

auto seq = flux::zip(get_vector(), get_string())
                  .map([](int i, char c) { ... });

that is, without needing to wrap the lambda in flux::unpack.

I think the best way to do this is to add our own flux::invoke(f, args...) which:

  • First tries std::invoke(f, args...)
  • If that fails, and if the args... pack has exactly one element, tries again with std::invoke(unpack(f), args...)

We'd also need corresponding versions of invoke_result_t and the invocable concept.

If we make this change, it would also be worth looking at the codegen of e.g cartesian_product_map and zip_map vs cartesian_product.map and zip.map to see whether it's worth keeping the former around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant