Skip to content

Commit 73540cb

Browse files
committed
[range.adaptors] Extend the changes from P1456R1 to also apply to
take_while_view, drop_view, drop_while_view, and elements_view. These are covered by the direction proposed in the paper, but were inadvertently omitted from the list of things to change in the wording.
1 parent bcb6dae commit 73540cb

File tree

2 files changed

+41
-48
lines changed

2 files changed

+41
-48
lines changed

papers/nxxxx.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ CWG motion 2: [P1234R5 "Paper name"](http://wg21.link/p1234r5), resolving 3 NB c
4343

4444
...
4545

46+
### LWG motion 11
47+
48+
The description of this paper specifies that:
49+
50+
> each such `base()` member [of a range adaptor, that returns a copy of the underlying view]
51+
> be replaced to by two overloads:
52+
> a `const`-qualified overload that requires the type of the underlying view to model CopyConstructible, and
53+
> a `&&`-qualified overload that extracts the underlying view from the adaptor
54+
55+
but the wording changes omitted explicit editing instructions
56+
to make these changes to the
57+
`take_while_view`, `drop_view`, `drop_while_view` and `elements_view`
58+
range adaptors, which were added by [P1035R7](http://wg21.link/p1035r7)
59+
(2019-07 LWG Motion 23), after R0 of this paper was authored.
60+
61+
Consistent with the proposal in the paper,
62+
and after consulting the paper authors and the LWG chair,
63+
the corresponding changes were also applied to the five additional range adaptors.
64+
4665
## Disposition of editorial NB comments on C++ 2020 CD1
4766

4867
Listed below are draft disposition for all comments that were

source/ranges.tex

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4013,6 +4013,9 @@
40134013
\rSec3[range.take.while.view]{Class template \tcode{take_while_view}}
40144014

40154015
\indexlibraryglobal{take_while_view}%
4016+
\indexlibrarymember{base}{take_while_view}%
4017+
\indexlibrarymember{begin}{take_while_view}%
4018+
\indexlibrarymember{end}{take_while_view}%
40164019
\begin{codeblock}
40174020
namespace std::ranges {
40184021
template<view R, class Pred>
@@ -4028,7 +4031,9 @@
40284031
take_while_view() = default;
40294032
constexpr take_while_view(R base, Pred pred);
40304033

4031-
constexpr R base() const;
4034+
constexpr R base() const& requires copy_constructible<R> { return base_; }
4035+
constexpr R base() && { return std::move(base_); }
4036+
40324037
constexpr const Pred& pred() const;
40334038

40344039
constexpr auto begin() requires (!@\placeholder{simple-view}@<R>)
@@ -4061,17 +4066,6 @@
40614066
\tcode{pred_} with \tcode{std::move(pred)}.
40624067
\end{itemdescr}
40634068

4064-
\indexlibrarymember{base}{take_while_view}%
4065-
\begin{itemdecl}
4066-
constexpr R base() const;
4067-
\end{itemdecl}
4068-
4069-
\begin{itemdescr}
4070-
\pnum
4071-
\effects
4072-
Equivalent to: \tcode{return base_;}
4073-
\end{itemdescr}
4074-
40754069
\indexlibrarymember{pred}{take_while_view}%
40764070
\begin{itemdecl}
40774071
constexpr const Pred& pred() const;
@@ -4177,6 +4171,9 @@
41774171
\rSec3[range.drop.view]{Class template \tcode{drop_view}}
41784172

41794173
\indexlibraryglobal{drop_view}%
4174+
\indexlibrarymember{base}{drop_view}%
4175+
\indexlibrarymember{end}{drop_view}%
4176+
\indexlibrarymember{size}{drop_view}%
41804177
\begin{codeblock}
41814178
namespace std::ranges {
41824179
template<view R>
@@ -4185,7 +4182,8 @@
41854182
drop_view() = default;
41864183
constexpr drop_view(R base, range_difference_t<R> count);
41874184

4188-
constexpr R base() const;
4185+
constexpr R base() const& requires copy_constructible<R> { return base_; }
4186+
constexpr R base() && { return std::move(base_); }
41894187

41904188
constexpr auto begin()
41914189
requires (!(@\placeholder{simple-view}@<R> && random_access_range<R>));
@@ -4241,17 +4239,6 @@
42414239
\tcode{count_} with \tcode{count}.
42424240
\end{itemdescr}
42434241

4244-
\indexlibrarymember{base}{drop_view}%
4245-
\begin{itemdecl}
4246-
constexpr R base() const;
4247-
\end{itemdecl}
4248-
4249-
\begin{itemdescr}
4250-
\pnum
4251-
\effects
4252-
Equivalent to: \tcode{return base_;}
4253-
\end{itemdescr}
4254-
42554242
\indexlibrarymember{begin}{drop_view}%
42564243
\begin{itemdecl}
42574244
constexpr auto begin()
@@ -4311,6 +4298,8 @@
43114298
\rSec3[range.drop.while.view]{Class template \tcode{drop_while_view}}
43124299

43134300
\indexlibraryglobal{drop_while_view}%
4301+
\indexlibrarymember{base}{drop_while_view}%
4302+
\indexlibrarymember{end}{drop_while_view}%
43144303
\begin{codeblock}
43154304
namespace std::ranges {
43164305
template<view R, class Pred>
@@ -4321,7 +4310,9 @@
43214310
drop_while_view() = default;
43224311
constexpr drop_while_view(R base, Pred pred);
43234312

4324-
constexpr R base() const;
4313+
constexpr R base() const& requires copy_constructible<R> { return base_; }
4314+
constexpr R base() && { return std::move(base_); }
4315+
43254316
constexpr const Pred& pred() const;
43264317

43274318
constexpr auto begin();
@@ -4351,17 +4342,6 @@
43514342
\tcode{pred_} with \tcode{std::move(pred)}.
43524343
\end{itemdescr}
43534344

4354-
\indexlibrarymember{base}{drop_while_view}%
4355-
\begin{itemdecl}
4356-
constexpr R base() const;
4357-
\end{itemdecl}
4358-
4359-
\begin{itemdescr}
4360-
\pnum
4361-
\effects
4362-
Equivalent to: \tcode{return base_;}
4363-
\end{itemdescr}
4364-
43654345
\indexlibrarymember{pred}{drop_while_view}%
43664346
\begin{itemdecl}
43674347
constexpr const Pred& pred() const;
@@ -5992,6 +5972,10 @@
59925972
\rSec3[range.elements.view]{Class template \tcode{elements_view}}
59935973

59945974
\indexlibraryglobal{elements_view}%
5975+
\indexlibrarymember{base}{elements_view}%
5976+
\indexlibrarymember{begin}{elements_view}%
5977+
\indexlibrarymember{end}{elements_view}%
5978+
\indexlibrarymember{size}{elements_view}%
59955979
\begin{codeblock}
59965980
namespace std::ranges {
59975981
template<class T, size_t N>
@@ -6012,7 +5996,8 @@
60125996
elements_view() = default;
60135997
constexpr explicit elements_view(R base);
60145998

6015-
constexpr R base() const;
5999+
constexpr R base() const& requires copy_constructible<R> { return base_; }
6000+
constexpr R base() && { return std::move(base_); }
60166001

60176002
constexpr auto begin() requires (!@\placeholder{simple-view}@<R>)
60186003
{ return iterator<false>(ranges::begin(base_)); }
@@ -6050,17 +6035,6 @@
60506035
Initializes \tcode{base_} with \tcode{std::move(base)}.
60516036
\end{itemdescr}
60526037

6053-
\indexlibrarymember{base}{elements_view}%
6054-
\begin{itemdecl}
6055-
constexpr R base() const;
6056-
\end{itemdecl}
6057-
6058-
\begin{itemdescr}
6059-
\pnum
6060-
\effects
6061-
Equivalent to: \tcode{return base_;}
6062-
\end{itemdescr}
6063-
60646038
\rSec3[range.elements.iterator]{Class template \tcode{elements_view::iterator}}
60656039

60666040
\indexlibraryglobal{elements_view::iterator}%

0 commit comments

Comments
 (0)