Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[libc++] Implement views::join_with #65536

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

Open
wants to merge 49 commits into
base: main
Choose a base branch
from

Conversation

JMazurkiewicz
Copy link
Contributor

@JMazurkiewicz JMazurkiewicz commented Sep 6, 2023

@github-actions github-actions bot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 6, 2023
@JMazurkiewicz JMazurkiewicz force-pushed the libcxx/ranges/join_with branch 5 times, most recently from 3259db4 to 0481670 Compare September 8, 2023 00:07
@JMazurkiewicz JMazurkiewicz force-pushed the libcxx/ranges/join_with branch from 0481670 to f113229 Compare September 8, 2023 15:11
@ldionne ldionne assigned var-const and huixie90 and unassigned var-const Sep 13, 2023
@ldionne ldionne requested a review from huixie90 September 15, 2023 20:55
@ldionne
Copy link
Member

ldionne commented Sep 15, 2023

@JMazurkiewicz Please ping us when this is ready to review and make it a non-draft.

@philnik777 philnik777 added the ranges Issues related to `<ranges>` label Oct 6, 2023
ldionne pushed a commit that referenced this pull request Oct 24, 2023
This patch adds a mention that the following papers are in progress:

* P2770R0: #66033
* P2441R2 and P2711R1: #65536
@JMazurkiewicz JMazurkiewicz force-pushed the libcxx/ranges/join_with branch from f113229 to 1835f68 Compare February 2, 2024 23:57
Copy link

github-actions bot commented Feb 3, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@JMazurkiewicz JMazurkiewicz marked this pull request as ready for review February 4, 2024 14:58
@JMazurkiewicz JMazurkiewicz requested a review from a team as a code owner February 4, 2024 14:58
@H-G-Hristov
Copy link
Contributor

H-G-Hristov commented May 10, 2024

I guess with constexpr variant this cool feature can be finalized now :)

@JMazurkiewicz JMazurkiewicz force-pushed the libcxx/ranges/join_with branch 3 times, most recently from a84985a to fcdf64a Compare May 14, 2024 14:38
@JMazurkiewicz JMazurkiewicz force-pushed the libcxx/ranges/join_with branch 3 times, most recently from 54a741c to a9a1031 Compare May 22, 2024 23:17
@JMazurkiewicz JMazurkiewicz force-pushed the libcxx/ranges/join_with branch from a9a1031 to 9406093 Compare June 5, 2024 09:49
@Zingam
Copy link
Contributor

Zingam commented Jan 18, 2025

@JMazurkiewicz At the top you mention that this PR completed several papers. Do you need to add additional GitHub issues to the list that this PR closes/fixes/?

@JMazurkiewicz
Copy link
Contributor Author

Ping @huixie90

Copy link
Contributor

@huixie90 huixie90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some nits. Thanks very much for the patch!

@@ -47,6 +47,9 @@ Implemented Papers
- P1222R4: A Standard ``flat_set`` (`Github <https://github.com/llvm/llvm-project/issues/105193>`__)
- P2897R7: ``aligned_accessor``: An mdspan accessor expressing pointer over-alignment (`Github <https://github.com/llvm/llvm-project/issues/118372>`__)
- P3247R2: Deprecate the notion of trivial types (`Github <https://github.com/llvm/llvm-project/issues/118387>`__)
- P2441R2: ``views::join_with`` (`Github <https://github.com/llvm/llvm-project/issues/105185>`__)
- P2711R1: Making multi-param constructors of ``views`` ``explicit`` (`Github <https://github.com/llvm/llvm-project/issues/105252>`__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is this paper completely done? I saw P2441R2 has multiple changes in different views

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the rest of P2711 is already done in libc++ 17.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm. I think it was my first contribution.


[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }

[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason why [[__nodiscard__]] is used rather than [[nodiscard]]?

also I notice that we don't add [[nodiscard]] in ranges library yet. not that I am against nodiscard, but I am not sure what we generally do in this case. For example, begin can be mutating and there might be a legitimate use case where begin is called explicitly to cache the results and discard it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ldionne I wonder what is the policy in Libc++ for adding no_discard

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the non-ugly spelling. Re. policy, we have https://libcxx.llvm.org/CodingGuidelines.html#apply-nodiscard-where-relevant. In this case I think it's fine. This would most likely fall under "only observe a value" or "is most likely a misuse of the function". While it's technically possible that someone might call begin() to cache something, this would definitely require a comment in code, and having to add a void cast seems fine to me in that case.

struct __join_with_view_iterator_category {};

template <class _Base, class _PatternBase, class _InnerBase>
requires is_reference_v<range_reference_t<_Base>> && forward_range<_Base> && forward_range<_InnerBase>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_reference_v<range_reference_t<_Base>> is still correct but the spec is using is_reference_v<InnerBase> , which is simpler

template <bool _OtherConst>
requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr bool __equal_to(const __iterator<_OtherConst>& __x) const {
return __x.__get_outer() == __end_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason to have this member function? is it just for the private access? if so, i would recommend to just have a static member function to access the private member of iterator. it is quite verbose here with the complex requires expression

@ldionne ldionne added pending-ci Merging the PR is only pending completion of CI and removed pending-ci Merging the PR is only pending completion of CI labels May 12, 2025
@ldionne
Copy link
Member

ldionne commented May 12, 2025

Sorry for the churn about the pending-ci tag -- I missed that there were still a few comments to resolve before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. ranges Issues related to `<ranges>`
Projects
None yet
9 participants