Skip to content

Commit 00b61e5

Browse files
authored
Merge 2019-07 LWG Motion 1
P1724R0 C++ Standard Library Issues to be moved in Cologne) Fixes #3005.
2 parents b52cea1 + 4a657ca commit 00b61e5

File tree

9 files changed

+245
-104
lines changed

9 files changed

+245
-104
lines changed

source/algorithms.tex

Lines changed: 92 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262
\tcode{for_each_result},
263263
\tcode{minmax_result},
264264
\tcode{mismatch_result},
265+
\tcode{next_permutation_result},
265266
\tcode{copy_result}, and
266267
\tcode{partition_copy_result}
267268
have the template parameters, data members, and special members specified below.
@@ -1533,19 +1534,19 @@
15331534
namespace ranges {
15341535
template<Permutable I, Sentinel<I> S, class T, class Proj = identity>
15351536
requires IndirectRelation<ranges::equal_to, projected<I, Proj>, const T*>
1536-
constexpr I remove(I first, S last, const T& value, Proj proj = {});
1537+
constexpr subrange<I> remove(I first, S last, const T& value, Proj proj = {});
15371538
template<ForwardRange R, class T, class Proj = identity>
15381539
requires Permutable<iterator_t<R>> &&
15391540
IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
1540-
constexpr safe_iterator_t<R>
1541+
constexpr safe_subrange_t<R>
15411542
remove(R&& r, const T& value, Proj proj = {});
15421543
template<Permutable I, Sentinel<I> S, class Proj = identity,
15431544
IndirectUnaryPredicate<projected<I, Proj>> Pred>
1544-
constexpr I remove_if(I first, S last, Pred pred, Proj proj = {});
1545+
constexpr subrange<I> remove_if(I first, S last, Pred pred, Proj proj = {});
15451546
template<ForwardRange R, class Proj = identity,
15461547
IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
15471548
requires Permutable<iterator_t<R>>
1548-
constexpr safe_iterator_t<R>
1549+
constexpr safe_subrange_t<R>
15491550
remove_if(R&& r, Pred pred, Proj proj = {});
15501551
}
15511552

@@ -1618,11 +1619,11 @@
16181619
namespace ranges {
16191620
template<Permutable I, Sentinel<I> S, class Proj = identity,
16201621
IndirectRelation<projected<I, Proj>> C = ranges::equal_to>
1621-
constexpr I unique(I first, S last, C comp = {}, Proj proj = {});
1622+
constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {});
16221623
template<ForwardRange R, class Proj = identity,
16231624
IndirectRelation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
16241625
requires Permutable<iterator_t<R>>
1625-
constexpr safe_iterator_t<R>
1626+
constexpr safe_subrange_t<R>
16261627
unique(R&& r, C comp = {}, Proj proj = {});
16271628
}
16281629

@@ -1767,13 +1768,11 @@
17671768
namespace ranges {
17681769
template<RandomAccessIterator I, Sentinel<I> S, class Gen>
17691770
requires Permutable<I> &&
1770-
UniformRandomBitGenerator<remove_reference_t<Gen>> &&
1771-
ConvertibleTo<invoke_result_t<Gen&>, iter_difference_t<I>>
1771+
UniformRandomBitGenerator<remove_reference_t<Gen>>
17721772
I shuffle(I first, S last, Gen&& g);
17731773
template<RandomAccessRange R, class Gen>
17741774
requires Permutable<iterator_t<R>> &&
1775-
UniformRandomBitGenerator<remove_reference_t<Gen>> &&
1776-
ConvertibleTo<invoke_result_t<Gen&>, iter_difference_t<iterator_t<R>>>
1775+
UniformRandomBitGenerator<remove_reference_t<Gen>>
17771776
safe_iterator_t<R> shuffle(R&& r, Gen&& g);
17781777
}
17791778

@@ -1907,11 +1906,13 @@
19071906
Compare comp);
19081907

19091908
namespace ranges {
1909+
template<class I, class O> using partial_sort_copy_result = copy_result<I, O>;
1910+
19101911
template<InputIterator I1, Sentinel<I1> S1, RandomAccessIterator I2, Sentinel<I2> S2,
19111912
class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
19121913
requires IndirectlyCopyable<I1, I2> && Sortable<I2, Comp, Proj2> &&
19131914
IndirectStrictWeakOrder<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
1914-
constexpr I2
1915+
constexpr partial_sort_copy_result<I1, I2>
19151916
partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
19161917
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
19171918
template<InputRange R1, RandomAccessRange R2, class Comp = ranges::less,
@@ -1920,7 +1921,7 @@
19201921
Sortable<iterator_t<R2>, Comp, Proj2> &&
19211922
IndirectStrictWeakOrder<Comp, projected<iterator_t<R1>, Proj1>,
19221923
projected<iterator_t<R2>, Proj2>>
1923-
constexpr safe_iterator_t<R2>
1924+
constexpr partial_sort_copy_result<safe_iterator_t<R1>, safe_iterator_t<R2>>
19241925
partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
19251926
Proj1 proj1 = {}, Proj2 proj2 = {});
19261927
}
@@ -2115,12 +2116,12 @@
21152116
namespace ranges {
21162117
template<Permutable I, Sentinel<I> S, class Proj = identity,
21172118
IndirectUnaryPredicate<projected<I, Proj>> Pred>
2118-
constexpr I
2119+
constexpr subrange<I>
21192120
partition(I first, S last, Pred pred, Proj proj = {});
21202121
template<ForwardRange R, class Proj = identity,
21212122
IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
21222123
requires Permutable<iterator_t<R>>
2123-
constexpr safe_iterator_t<R>
2124+
constexpr safe_subrange_t<R>
21242125
partition(R&& r, Pred pred, Proj proj = {});
21252126
}
21262127

@@ -2138,11 +2139,11 @@
21382139
template<BidirectionalIterator I, Sentinel<I> S, class Proj = identity,
21392140
IndirectUnaryPredicate<projected<I, Proj>> Pred>
21402141
requires Permutable<I>
2141-
I stable_partition(I first, S last, Pred pred, Proj proj = {});
2142+
subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {});
21422143
template<BidirectionalRange R, class Proj = identity,
21432144
IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
21442145
requires Permutable<iterator_t<R>>
2145-
safe_iterator_t<R> stable_partition(R&& r, Pred pred, Proj proj = {});
2146+
safe_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {});
21462147
}
21472148

21482149
template<class InputIterator, class OutputIterator1,
@@ -2852,15 +2853,21 @@
28522853
BidirectionalIterator last, Compare comp);
28532854

28542855
namespace ranges {
2856+
template<class I>
2857+
struct next_permutation_result {
2858+
bool found;
2859+
I in;
2860+
};
2861+
28552862
template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
28562863
class Proj = identity>
28572864
requires Sortable<I, Comp, Proj>
2858-
constexpr bool
2865+
constexpr next_permutation_result<I>
28592866
next_permutation(I first, S last, Comp comp = {}, Proj proj = {});
28602867
template<BidirectionalRange R, class Comp = ranges::less,
28612868
class Proj = identity>
28622869
requires Sortable<iterator_t<R>, Comp, Proj>
2863-
constexpr bool
2870+
constexpr next_permutation_result<safe_iterator_t<R>>
28642871
next_permutation(R&& r, Comp comp = {}, Proj proj = {});
28652872
}
28662873

@@ -2872,15 +2879,18 @@
28722879
BidirectionalIterator last, Compare comp);
28732880

28742881
namespace ranges {
2882+
template<class I>
2883+
using prev_permutation_result = next_permutation_result<I>;
2884+
28752885
template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
28762886
class Proj = identity>
28772887
requires Sortable<I, Comp, Proj>
2878-
constexpr bool
2888+
constexpr prev_permutation_result<I>
28792889
prev_permutation(I first, S last, Comp comp = {}, Proj proj = {});
28802890
template<BidirectionalRange R, class Comp = ranges::less,
28812891
class Proj = identity>
28822892
requires Sortable<iterator_t<R>, Comp, Proj>
2883-
constexpr bool
2893+
constexpr prev_permutation_result<safe_iterator_t<R>>
28842894
prev_permutation(R&& r, Comp comp = {}, Proj proj = {});
28852895
}
28862896
}
@@ -4959,19 +4969,19 @@
49594969

49604970
template<Permutable I, Sentinel<I> S, class T, class Proj = identity>
49614971
requires IndirectRelation<ranges::equal_to, projected<I, Proj>, const T*>
4962-
constexpr I ranges::remove(I first, S last, const T& value, Proj proj = {});
4972+
constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {});
49634973
template<ForwardRange R, class T, class Proj = identity>
49644974
requires Permutable<iterator_t<R>> &&
49654975
IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
4966-
constexpr safe_iterator_t<R>
4976+
constexpr safe_subrange_t<R>
49674977
ranges::remove(R&& r, const T& value, Proj proj = {});
49684978
template<Permutable I, Sentinel<I> S, class Proj = identity,
49694979
IndirectUnaryPredicate<projected<I, Proj>> Pred>
4970-
constexpr I ranges::remove_if(I first, S last, Pred pred, Proj proj = {});
4980+
constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {});
49714981
template<ForwardRange R, class Proj = identity,
49724982
IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
49734983
requires Permutable<iterator_t<R>>
4974-
constexpr safe_iterator_t<R>
4984+
constexpr safe_subrange_t<R>
49754985
ranges::remove_if(R&& r, Pred pred, Proj proj = {});
49764986
\end{itemdecl}
49774987

@@ -4998,7 +5008,11 @@
49985008

49995009
\pnum
50005010
\returns
5001-
The end of the resulting range.
5011+
Let $j$ be the end of the resulting range. Returns:
5012+
\begin{itemize}
5013+
\item $j$ for the overloads in namespace \tcode{std}, or
5014+
\item \tcode{\{$j$, last\}} for the overloads in namespace \tcode{ranges}.
5015+
\end{itemize}
50025016

50035017
\pnum
50045018
\remarks
@@ -5134,11 +5148,11 @@
51345148

51355149
template<Permutable I, Sentinel<I> S, class Proj = identity,
51365150
IndirectRelation<projected<I, Proj>> C = ranges::equal_to>
5137-
constexpr I ranges::unique(I first, S last, C comp = {}, Proj proj = {});
5151+
constexpr subrange<I> ranges::unique(I first, S last, C comp = {}, Proj proj = {});
51385152
template<ForwardRange R, class Proj = identity,
51395153
IndirectRelation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
51405154
requires Permutable<iterator_t<R>>
5141-
constexpr safe_iterator_t<R>
5155+
constexpr safe_subrange_t<R>
51425156
ranges::unique(R&& r, C comp = {}, Proj proj = {});
51435157
\end{itemdecl}
51445158

@@ -5173,7 +5187,11 @@
51735187

51745188
\pnum
51755189
\returns
5176-
The end of the resulting range.
5190+
Let $j$ be the end of the resulting range. Returns:
5191+
\begin{itemize}
5192+
\item $j$ for the overloads in namespace \tcode{std}, or
5193+
\item \tcode{\{$j$, last\}} for the overloads in namespace \tcode{ranges}.
5194+
\end{itemize}
51775195

51785196
\pnum
51795197
\complexity
@@ -6053,7 +6071,7 @@
60536071
class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
60546072
requires IndirectlyCopyable<I1, I2> && Sortable<I2, Comp, Proj2> &&
60556073
IndirectStrictWeakOrder<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
6056-
constexpr I2
6074+
constexpr ranges::partial_sort_copy_result<I1, I2>
60576075
ranges::partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
60586076
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
60596077
template<InputRange R1, RandomAccessRange R2, class Comp = ranges::less,
@@ -6062,7 +6080,7 @@
60626080
Sortable<iterator_t<R2>, Comp, Proj2> &&
60636081
IndirectStrictWeakOrder<Comp, projected<iterator_t<R1>, Proj1>,
60646082
projected<iterator_t<R2>, Proj2>>
6065-
constexpr safe_iterator_t<R2>
6083+
constexpr ranges::partial_sort_copy_result<safe_iterator_t<R1>, safe_iterator_t<R2>>
60666084
ranges::partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
60676085
Proj1 proj1 = {}, Proj2 proj2 = {});
60686086
\end{itemdecl}
@@ -6110,7 +6128,13 @@
61106128

61116129
\pnum
61126130
\returns
6113-
\tcode{result_first + $N$}.
6131+
\begin{itemize}
6132+
\item
6133+
\tcode{result_first + $N$} for the overloads in namespace \tcode{std}, or
6134+
\item
6135+
\tcode{\{last, result_first + $N$\}} for
6136+
the overloads in namespace \tcode{ranges}.
6137+
\end{itemize}
61146138

61156139
\pnum
61166140
\complexity
@@ -6598,12 +6622,12 @@
65986622

65996623
template<Permutable I, Sentinel<I> S, class Proj = identity,
66006624
IndirectUnaryPredicate<projected<I, Proj>> Pred>
6601-
constexpr I
6625+
constexpr subrange<I>
66026626
ranges::partition(I first, S last, Pred pred, Proj proj = {});
66036627
template<ForwardRange R, class Proj = identity,
66046628
IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
66056629
requires Permutable<iterator_t<R>>
6606-
constexpr safe_iterator_t<R>
6630+
constexpr safe_subrange_t<R>
66076631
ranges::partition(R&& r, Pred pred, Proj proj = {});
66086632
\end{itemdecl}
66096633

@@ -6626,9 +6650,15 @@
66266650

66276651
\pnum
66286652
\returns
6629-
An iterator \tcode{i} such that $E(\tcode{*j})$ is
6653+
Let \tcode{i} be an iterator such that $E(\tcode{*j})$ is
66306654
\tcode{true} for every iterator \tcode{j} in \range{first}{i} and
66316655
\tcode{false} for every iterator \tcode{j} in \range{i}{last}.
6656+
Returns:
6657+
\begin{itemize}
6658+
\item \tcode{i} for the overloads in namespace \tcode{std}, or
6659+
\item \tcode{\{i, last\}} for the overloads in namespace \tcode{ranges}.
6660+
\end{itemize}
6661+
66326662

66336663
\pnum
66346664
\complexity Let $N = \tcode{last - first}$:
@@ -6662,11 +6692,11 @@
66626692
template<BidirectionalIterator I, Sentinel<I> S, class Proj = identity,
66636693
IndirectUnaryPredicate<projected<I, Proj>> Pred>
66646694
requires Permutable<I>
6665-
I ranges::stable_partition(I first, S last, Pred pred, Proj proj = {});
6695+
subrange<I> ranges::stable_partition(I first, S last, Pred pred, Proj proj = {});
66666696
template<BidirectionalRange R, class Proj = identity,
66676697
IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
66686698
requires Permutable<iterator_t<R>>
6669-
safe_iterator_t<R> ranges::stable_partition(R&& r, Pred pred, Proj proj = {});
6699+
safe_subrange_t<R> ranges::stable_partition(R&& r, Pred pred, Proj proj = {});
66706700
\end{itemdecl}
66716701

66726702
\begin{itemdescr}
@@ -6691,11 +6721,17 @@
66916721

66926722
\pnum
66936723
\returns
6694-
An iterator \tcode{i}
6724+
Let \tcode{i} be an iterator
66956725
such that for every iterator \tcode{j} in \range{first}{i},
66966726
$E(\tcode{*j})$ is \tcode{true},
66976727
and for every iterator \tcode{j} in the range \range{i}{last},
6698-
$E(\tcode{*j})$ is \tcode{false},
6728+
$E(\tcode{*j})$ is \tcode{false}.
6729+
Returns:
6730+
\begin{itemize}
6731+
\item \tcode{i} for the overloads in namespace \tcode{std}, or
6732+
\item \tcode{\{i, last\}} for the overloads in namespace \tcode{ranges}.
6733+
\end{itemize}
6734+
66996735

67006736
\pnum
67016737
\complexity
@@ -8430,12 +8466,12 @@
84308466
template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
84318467
class Proj = identity>
84328468
requires Sortable<I, Comp, Proj>
8433-
constexpr bool
8469+
constexpr ranges::next_permutation_result<I>
84348470
ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {});
84358471
template<BidirectionalRange R, class Comp = ranges::less,
84368472
class Proj = identity>
84378473
requires Sortable<iterator_t<R>, Comp, Proj>
8438-
constexpr bool
8474+
constexpr ranges::next_permutation_result<safe_iterator_t<R>>
84398475
ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {});
84408476
\end{itemdecl}
84418477

@@ -8463,7 +8499,13 @@
84638499

84648500
\pnum
84658501
\returns
8466-
\tcode{true} if and only if a next permutation was found.
8502+
Let \tcode{B} be \tcode{true} if a next permutation was found and
8503+
otherwise \tcode{false}.
8504+
Returns:
8505+
\begin{itemize}
8506+
\item \tcode{B} for the overloads in namespace \tcode{std}, or
8507+
\item \tcode{\{ B, last \}} for the overloads in namespace \tcode{ranges}.
8508+
\end{itemize}
84678509

84688510
\pnum
84698511
\complexity
@@ -8483,12 +8525,12 @@
84838525
template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
84848526
class Proj = identity>
84858527
requires Sortable<I, Comp, Proj>
8486-
constexpr bool
8528+
constexpr ranges::prev_permutation_result<I>
84878529
ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {});
84888530
template<BidirectionalRange R, class Comp = ranges::less,
84898531
class Proj = identity>
84908532
requires Sortable<iterator_t<R>, Comp, Proj>
8491-
constexpr bool
8533+
constexpr ranges::prev_permutation_result<safe_iterator_t<R>>
84928534
ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {});
84938535
\end{itemdecl}
84948536

@@ -8516,7 +8558,13 @@
85168558

85178559
\pnum
85188560
\returns
8519-
\tcode{true} if and only if a previous permutation was found.
8561+
Let \tcode{B} be \tcode{true} if a previous permutation was found and
8562+
otherwise \tcode{false}.
8563+
Returns:
8564+
\begin{itemize}
8565+
\item \tcode{B} for the overloads in namespace \tcode{std}, or
8566+
\item \tcode{\{ B, last \}} for the overloads in namespace \tcode{ranges}.
8567+
\end{itemize}
85208568

85218569
\pnum
85228570
\complexity

source/concepts.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,11 @@
823823
const remove_reference_t<B>& b2, const bool a) {
824824
{ b1 } -> ConvertibleTo<bool>;
825825
{ !b1 } -> ConvertibleTo<bool>;
826-
{ b1 && a } -> Same<bool>;
827-
{ b1 || a } -> Same<bool>;
828826
{ b1 && b2 } -> Same<bool>;
827+
{ b1 && a } -> Same<bool>;
829828
{ a && b2 } -> Same<bool>;
830829
{ b1 || b2 } -> Same<bool>;
830+
{ b1 || a } -> Same<bool>;
831831
{ a || b2 } -> Same<bool>;
832832
{ b1 == b2 } -> ConvertibleTo<bool>;
833833
{ b1 == a } -> ConvertibleTo<bool>;

0 commit comments

Comments
 (0)