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

error with cartesian_product_view using 2 views #22

Open
dixlorenz opened this issue Jan 5, 2024 · 0 comments
Open

error with cartesian_product_view using 2 views #22

dixlorenz opened this issue Jan 5, 2024 · 0 comments

Comments

@dixlorenz
Copy link

There is a bug with just 2 ranges:

for (auto &&[a, b, c] :
tl::views::cartesian_product(std::views::iota(0, 3), std::views::iota(0, 3), std::views::iota(0, 3)) |
std::views::transform([](auto val) { return val; }))
std::cout << a << ' ' << b << ' ' << c << '\n';

works fine, but:

for (auto &&[a, b] : tl::views::cartesian_product(std::views::iota(0, 3), std::views::iota(0, 3)) |
std::views::transform([](auto val) { return val; }))
std::cout << a << ' ' << b << '\n';

fails to compile because when cartesian_product only uses 2 ranges, tuple_transform returns a pair instead of a tuple and cartesian_product_view is not using that consistently. The iterator fails to be an input_iterator because it is not indirectly_readable, "common_reference_with<iter_reference_t<_In>&&, iter_value_t<_In>&> &&" fails because iter_reference_t uses a pair and iter_value_t uses a tuple. At least that's what I think is happening; once I eliminated the specialization for pair in tuple_or_pair_impl it works. That's definitely not a fix though, but I don't know where the actual bug lies.

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