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
[range.cartesian.view] Fix cartesian-product-is-common #5768
Conversation
This feels like it needs an LWG issue. Could you please file one? |
I don't think it's worth LWG. template <class R>
concept cartesian-product-common-arg = // exposition only
common_range<R> || (sized_range<R> && random_access_range<R>);
template <class First, class... Vs>
concept cartesian-product-is-common = // exposition only
cartesian-product-common-arg<Const, First>>; This is mentioned in #5750, and the reporter believes that the intent of the paper should have been to define it as template<class First, class... Vs>
concept cartesian-product-is-common = // exposition only
(cartesian-product-common-arg<First> && ... &&
cartesian-product-common-arg<Vs>); which has been merged into the draft. However, according to the description of
And according to the implementation section of the paper for
From the above context derivation, the merged fix is obviously not the intention of the paper. I think the fix that is closest to the intention of the paper should be template <class First, class... Vs>
concept cartesian-product-is-common = // exposition only
cartesian-product-common-arg<First>; And this pull request just removes the unused Can we ask the author for their opinion? |
Paging @griwes and @TartanLlama My feeling is that this needs an LWG issue. |
See 8275c19 for the previous editorial-deemed fix, but we should take a closer look. |
No, the words in the paper are not a mistake. We only use a sentinel for the first range in the end iterator; for the rest of the ranges, we use an iterator, because in the end iterator we are storing begin(), not end(). So only the first range needs to be common for cartesian product to be common. |
@griwes: Thanks! What about the |
Scratch that, we don't have a Const argument for this concept, I believe this maybe-const is done by the users of this concept. |
As for |
@griwes Would you perhaps be able to send a PR with the correct and intended wording? |
Not at the present, I'm on vacation :) I believe the intented wording shouldn't have the const part, but it also should use the common-arg helper concept only on the first argument. I'd also be happy to have an LWG discussion as to whether we should drop the parameter pack from is-common or not. |
OK, I can make that change. So we go back to the original, but drop the |
Yeah, that sounds correct to me. |
@griwes, thanks for taking the time out from your vacation to advise. |
This is as I guessed.
template <class First, class... Vs>
concept cartesian-product-is-common = // exposition only
cartesian-product-common-arg<First>; In fact, at first glance, I thought it was an editing error because it looks like the fold expression was left out, which is why it was removed from the pull request since I believe this will reduce confusion for people who haven't read the original paper. template <class First, class...>
concept cartesian-product-is-common = // exposition only
cartesian-product-common-arg<First>; This more clearly expresses the intent of ignoring non-first views. |
I think this should be correct.
(In fact, I implemented
cartesian_product_view
after the pre-version p2374r3 was published. From my experience, the constraints here should only be aimed atFirst
)