Skip to content

[libc++][ranges] P3059R2: Making user-defined constructors of view iterators/sentinels private - #193891

Merged
Zingam merged 33 commits into
llvm:mainfrom
H-G-Hristov:hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private
Jul 30, 2026
Merged

[libc++][ranges] P3059R2: Making user-defined constructors of view iterators/sentinels private#193891
Zingam merged 33 commits into
llvm:mainfrom
H-G-Hristov:hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private

Conversation

@H-G-Hristov

@H-G-Hristov H-G-Hristov commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Implements https://wg21.link/P3059R2 (DR)

Closes #189599

  1. Made constructors of iterator and sentinel types of the following views private:
  • iota_view
  • basic_istream_view
  • filter_view
  • transform_view
  • take_view
  • take_while_view
  • join_view
  • lazy_split_view
  • split_view
  • elements_view
  1. Updated all relevant tests to fix the usages of the now private constructor, including:
    1. Removed now obsolete tests (files and cases).
    2. Updated all relevant tests to get the iterators and the sentinels via begin() and end(), wherever applicable .
    3. Added test cases to confirm that P3059R2 was implemented properly.
    4. Minor other (necessary) tweaks.

@github-actions

github-actions Bot commented Apr 24, 2026

Copy link
Copy Markdown

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

@Zingam Zingam added ranges Issues related to `<ranges>` c++29 labels Jul 11, 2026
@H-G-Hristov
H-G-Hristov force-pushed the hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private branch 2 times, most recently from 7499890 to 8284cc0 Compare July 17, 2026 18:28
@Zingam Zingam added c++26 and removed c++29 labels Jul 20, 2026
Zingam pushed a commit that referenced this pull request Jul 20, 2026
@H-G-Hristov
H-G-Hristov force-pushed the hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private branch from c70379e to 19f8cb6 Compare July 20, 2026 09:28
Comment thread libcxx/test/std/ranges/range.adaptors/range.elements/iterator/base.pass.cpp Outdated
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 20, 2026
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jul 20, 2026
H-G-Hristov added a commit to H-G-Hristov/llvm-project that referenced this pull request Jul 20, 2026
Zingam pushed a commit that referenced this pull request Jul 20, 2026
@H-G-Hristov
H-G-Hristov force-pushed the hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private branch from 56482d8 to 7c2c8f1 Compare July 20, 2026 21:04
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jul 20, 2026
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 20, 2026
@H-G-Hristov
H-G-Hristov force-pushed the hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private branch from f0e3fd0 to 95ea87f Compare July 21, 2026 18:49
@Zingam Zingam changed the title WIP [libc++][ranges] P3059R2: Making user-defined constructors of view iterators/sentinels private [libc++][ranges] P3059R2: Making user-defined constructors of view iterators/sentinels private Jul 22, 2026
@H-G-Hristov
H-G-Hristov force-pushed the hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private branch from 95ea87f to db256d5 Compare July 22, 2026 06:16
@Zingam

Zingam commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

The current CI failures appear unrelated.

@Zingam
Zingam marked this pull request as ready for review July 22, 2026 07:58
@Zingam
Zingam requested a review from a team as a code owner July 22, 2026 07:58
@H-G-Hristov
H-G-Hristov force-pushed the hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private branch from 78f944f to 98ad281 Compare July 22, 2026 07:59
ldionne pushed a commit that referenced this pull request Jul 22, 2026
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jul 22, 2026
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 22, 2026
@H-G-Hristov
H-G-Hristov force-pushed the hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private branch from 034d1ad to f5c82b2 Compare July 30, 2026 10:03
@Zingam

Zingam commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@frederick-vs-ja Thank you. I'd like to do an NFC follow-up to this PR to use concepts, instead of type traits consistently and add the necessary includes, which are missing here and there too.

@Zingam
Zingam merged commit 11b58f0 into llvm:main Jul 30, 2026
84 checks passed
@H-G-Hristov
H-G-Hristov deleted the hgh/libcxx/P3059R2-Making-user-defined-constructors-of-view-iterators-sentinels-private branch July 30, 2026 15:33
Zingam pushed a commit that referenced this pull request Jul 31, 2026
…0 merge (#213062)

Consistency improvements and other small tweaks.

A follow-up to #193891 - the
changes were deferred to reduce the size of an already large and
approved PR.
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jul 31, 2026
… after P3050 merge (#213062)

Consistency improvements and other small tweaks.

A follow-up to llvm/llvm-project#193891 - the
changes were deferred to reduce the size of an already large and
approved PR.
nekoshirro pushed a commit to nekoshirro/Alchemist-LLVM that referenced this pull request Aug 1, 2026
…0 merge (#213062)

Consistency improvements and other small tweaks.

A follow-up to llvm/llvm-project#193891 - the
changes were deferred to reduce the size of an already large and
approved PR.
Signed-off-by: Hafidz Muzakky <ais.muzakky@gmail.com>
frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Aug 3, 2026
…0 merge (llvm#213062)

Consistency improvements and other small tweaks.

A follow-up to llvm#193891 - the
changes were deferred to reduce the size of an already large and
approved PR.
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Aug 3, 2026
… after P3050 merge (#213062)

Consistency improvements and other small tweaks.

A follow-up to llvm/llvm-project#193891 - the
changes were deferred to reduce the size of an already large and
approved PR.
jgreenbaum pushed a commit to jgreenbaum/llvm-project that referenced this pull request Aug 3, 2026
…erators/sentinels private (llvm#193891)

Implements https://wg21.link/P3059R2 (DR)

Closes llvm#189599

1. Made constructors of iterator and sentinel types of the following
views private:
  - `iota_view`
  - `basic_istream_view`
  - `filter_view`
  - `transform_view`
  - `take_view`
  - `take_while_view`
  - `join_view`
  - `lazy_split_view`
  - `split_view`
  - `elements_view`
2. Updated all relevant tests to fix the usages of the now private
constructor, including:
   1. Removed now obsolete tests (files and cases).
2. Updated all relevant tests to get the iterators and the sentinels via
`begin()` and `end()`, wherever applicable .
   3. Added test cases to confirm that P3059R2 was implemented properly.
   4. Minor other (necessary) tweaks.

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
Co-authored-by: A. Jiang <de34@live.cn>
jgreenbaum pushed a commit to jgreenbaum/llvm-project that referenced this pull request Aug 3, 2026
…0 merge (llvm#213062)

Consistency improvements and other small tweaks.

A follow-up to llvm#193891 - the
changes were deferred to reduce the size of an already large and
approved PR.
tfzee pushed a commit to tfzee/llvm-project that referenced this pull request Aug 6, 2026
…0 merge (llvm#213062)

Consistency improvements and other small tweaks.

A follow-up to llvm#193891 - the
changes were deferred to reduce the size of an already large and
approved PR.
frederick-vs-ja pushed a commit that referenced this pull request Aug 13, 2026
)

The previous test was dereferencing `begin()` iterator on empty view
which is UB, because `begin() == end()`.

A new test case was suggested in a post-merge feedback in #193891, which
verifies LWG3568 through constant evaluation. Such a `constexpr`
`basic_istream_view` variable can only be created if it is completely
initialized, including its exposition-only _`value_`_ member.

The existing test case is changed to use a non-empty stream and a
testing class type for which `operator>>` is no-op. The state of the
class object stored in `basic_istream_view` is unchanged even after the
initial `operator>>` call.

This avoids dereferencing a past-the-end iterator while testing LWG3568.
zhangweize9-cyber pushed a commit to zhangweize9-cyber/llvm-project that referenced this pull request Aug 16, 2026
…#215589)

The previous test was dereferencing `begin()` iterator on empty view
which is UB, because `begin() == end()`.

A new test case was suggested in a post-merge feedback in llvm#193891, which
verifies LWG3568 through constant evaluation. Such a `constexpr`
`basic_istream_view` variable can only be created if it is completely
initialized, including its exposition-only _`value_`_ member.

The existing test case is changed to use a non-empty stream and a
testing class type for which `operator>>` is no-op. The state of the
class object stored in `basic_istream_view` is unchanged even after the
initial `operator>>` call.

This avoids dereferencing a past-the-end iterator while testing LWG3568.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++26 libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. ranges Issues related to `<ranges>`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P3059R2: Making user-defined constructors of view iterators/sentinels private

3 participants