|
262 | 262 | \tcode{for_each_result},
|
263 | 263 | \tcode{minmax_result},
|
264 | 264 | \tcode{mismatch_result},
|
| 265 | +\tcode{next_permutation_result}, |
265 | 266 | \tcode{copy_result}, and
|
266 | 267 | \tcode{partition_copy_result}
|
267 | 268 | have the template parameters, data members, and special members specified below.
|
|
1533 | 1534 | namespace ranges {
|
1534 | 1535 | template<Permutable I, Sentinel<I> S, class T, class Proj = identity>
|
1535 | 1536 | 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 = {}); |
1537 | 1538 | template<ForwardRange R, class T, class Proj = identity>
|
1538 | 1539 | requires Permutable<iterator_t<R>> &&
|
1539 | 1540 | IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
|
1540 |
| - constexpr safe_iterator_t<R> |
| 1541 | + constexpr safe_subrange_t<R> |
1541 | 1542 | remove(R&& r, const T& value, Proj proj = {});
|
1542 | 1543 | template<Permutable I, Sentinel<I> S, class Proj = identity,
|
1543 | 1544 | 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 = {}); |
1545 | 1546 | template<ForwardRange R, class Proj = identity,
|
1546 | 1547 | IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
|
1547 | 1548 | requires Permutable<iterator_t<R>>
|
1548 |
| - constexpr safe_iterator_t<R> |
| 1549 | + constexpr safe_subrange_t<R> |
1549 | 1550 | remove_if(R&& r, Pred pred, Proj proj = {});
|
1550 | 1551 | }
|
1551 | 1552 |
|
|
1618 | 1619 | namespace ranges {
|
1619 | 1620 | template<Permutable I, Sentinel<I> S, class Proj = identity,
|
1620 | 1621 | 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 = {}); |
1622 | 1623 | template<ForwardRange R, class Proj = identity,
|
1623 | 1624 | IndirectRelation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
|
1624 | 1625 | requires Permutable<iterator_t<R>>
|
1625 |
| - constexpr safe_iterator_t<R> |
| 1626 | + constexpr safe_subrange_t<R> |
1626 | 1627 | unique(R&& r, C comp = {}, Proj proj = {});
|
1627 | 1628 | }
|
1628 | 1629 |
|
|
1767 | 1768 | namespace ranges {
|
1768 | 1769 | template<RandomAccessIterator I, Sentinel<I> S, class Gen>
|
1769 | 1770 | 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>> |
1772 | 1772 | I shuffle(I first, S last, Gen&& g);
|
1773 | 1773 | template<RandomAccessRange R, class Gen>
|
1774 | 1774 | 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>> |
1777 | 1776 | safe_iterator_t<R> shuffle(R&& r, Gen&& g);
|
1778 | 1777 | }
|
1779 | 1778 |
|
|
1907 | 1906 | Compare comp);
|
1908 | 1907 |
|
1909 | 1908 | namespace ranges {
|
| 1909 | + template<class I, class O> using partial_sort_copy_result = copy_result<I, O>; |
| 1910 | + |
1910 | 1911 | template<InputIterator I1, Sentinel<I1> S1, RandomAccessIterator I2, Sentinel<I2> S2,
|
1911 | 1912 | class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
|
1912 | 1913 | requires IndirectlyCopyable<I1, I2> && Sortable<I2, Comp, Proj2> &&
|
1913 | 1914 | IndirectStrictWeakOrder<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
|
1914 |
| - constexpr I2 |
| 1915 | + constexpr partial_sort_copy_result<I1, I2> |
1915 | 1916 | partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
|
1916 | 1917 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
1917 | 1918 | template<InputRange R1, RandomAccessRange R2, class Comp = ranges::less,
|
|
1920 | 1921 | Sortable<iterator_t<R2>, Comp, Proj2> &&
|
1921 | 1922 | IndirectStrictWeakOrder<Comp, projected<iterator_t<R1>, Proj1>,
|
1922 | 1923 | 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>> |
1924 | 1925 | partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
|
1925 | 1926 | Proj1 proj1 = {}, Proj2 proj2 = {});
|
1926 | 1927 | }
|
|
2115 | 2116 | namespace ranges {
|
2116 | 2117 | template<Permutable I, Sentinel<I> S, class Proj = identity,
|
2117 | 2118 | IndirectUnaryPredicate<projected<I, Proj>> Pred>
|
2118 |
| - constexpr I |
| 2119 | + constexpr subrange<I> |
2119 | 2120 | partition(I first, S last, Pred pred, Proj proj = {});
|
2120 | 2121 | template<ForwardRange R, class Proj = identity,
|
2121 | 2122 | IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
|
2122 | 2123 | requires Permutable<iterator_t<R>>
|
2123 |
| - constexpr safe_iterator_t<R> |
| 2124 | + constexpr safe_subrange_t<R> |
2124 | 2125 | partition(R&& r, Pred pred, Proj proj = {});
|
2125 | 2126 | }
|
2126 | 2127 |
|
|
2138 | 2139 | template<BidirectionalIterator I, Sentinel<I> S, class Proj = identity,
|
2139 | 2140 | IndirectUnaryPredicate<projected<I, Proj>> Pred>
|
2140 | 2141 | 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 = {}); |
2142 | 2143 | template<BidirectionalRange R, class Proj = identity,
|
2143 | 2144 | IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
|
2144 | 2145 | 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 = {}); |
2146 | 2147 | }
|
2147 | 2148 |
|
2148 | 2149 | template<class InputIterator, class OutputIterator1,
|
|
2852 | 2853 | BidirectionalIterator last, Compare comp);
|
2853 | 2854 |
|
2854 | 2855 | namespace ranges {
|
| 2856 | + template<class I> |
| 2857 | + struct next_permutation_result { |
| 2858 | + bool found; |
| 2859 | + I in; |
| 2860 | + }; |
| 2861 | + |
2855 | 2862 | template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
|
2856 | 2863 | class Proj = identity>
|
2857 | 2864 | requires Sortable<I, Comp, Proj>
|
2858 |
| - constexpr bool |
| 2865 | + constexpr next_permutation_result<I> |
2859 | 2866 | next_permutation(I first, S last, Comp comp = {}, Proj proj = {});
|
2860 | 2867 | template<BidirectionalRange R, class Comp = ranges::less,
|
2861 | 2868 | class Proj = identity>
|
2862 | 2869 | requires Sortable<iterator_t<R>, Comp, Proj>
|
2863 |
| - constexpr bool |
| 2870 | + constexpr next_permutation_result<safe_iterator_t<R>> |
2864 | 2871 | next_permutation(R&& r, Comp comp = {}, Proj proj = {});
|
2865 | 2872 | }
|
2866 | 2873 |
|
|
2872 | 2879 | BidirectionalIterator last, Compare comp);
|
2873 | 2880 |
|
2874 | 2881 | namespace ranges {
|
| 2882 | + template<class I> |
| 2883 | + using prev_permutation_result = next_permutation_result<I>; |
| 2884 | + |
2875 | 2885 | template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
|
2876 | 2886 | class Proj = identity>
|
2877 | 2887 | requires Sortable<I, Comp, Proj>
|
2878 |
| - constexpr bool |
| 2888 | + constexpr prev_permutation_result<I> |
2879 | 2889 | prev_permutation(I first, S last, Comp comp = {}, Proj proj = {});
|
2880 | 2890 | template<BidirectionalRange R, class Comp = ranges::less,
|
2881 | 2891 | class Proj = identity>
|
2882 | 2892 | requires Sortable<iterator_t<R>, Comp, Proj>
|
2883 |
| - constexpr bool |
| 2893 | + constexpr prev_permutation_result<safe_iterator_t<R>> |
2884 | 2894 | prev_permutation(R&& r, Comp comp = {}, Proj proj = {});
|
2885 | 2895 | }
|
2886 | 2896 | }
|
|
4959 | 4969 |
|
4960 | 4970 | template<Permutable I, Sentinel<I> S, class T, class Proj = identity>
|
4961 | 4971 | 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 = {}); |
4963 | 4973 | template<ForwardRange R, class T, class Proj = identity>
|
4964 | 4974 | requires Permutable<iterator_t<R>> &&
|
4965 | 4975 | IndirectRelation<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
|
4966 |
| - constexpr safe_iterator_t<R> |
| 4976 | + constexpr safe_subrange_t<R> |
4967 | 4977 | ranges::remove(R&& r, const T& value, Proj proj = {});
|
4968 | 4978 | template<Permutable I, Sentinel<I> S, class Proj = identity,
|
4969 | 4979 | 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 = {}); |
4971 | 4981 | template<ForwardRange R, class Proj = identity,
|
4972 | 4982 | IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
|
4973 | 4983 | requires Permutable<iterator_t<R>>
|
4974 |
| - constexpr safe_iterator_t<R> |
| 4984 | + constexpr safe_subrange_t<R> |
4975 | 4985 | ranges::remove_if(R&& r, Pred pred, Proj proj = {});
|
4976 | 4986 | \end{itemdecl}
|
4977 | 4987 |
|
|
4998 | 5008 |
|
4999 | 5009 | \pnum
|
5000 | 5010 | \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} |
5002 | 5016 |
|
5003 | 5017 | \pnum
|
5004 | 5018 | \remarks
|
|
5134 | 5148 |
|
5135 | 5149 | template<Permutable I, Sentinel<I> S, class Proj = identity,
|
5136 | 5150 | 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 = {}); |
5138 | 5152 | template<ForwardRange R, class Proj = identity,
|
5139 | 5153 | IndirectRelation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
|
5140 | 5154 | requires Permutable<iterator_t<R>>
|
5141 |
| - constexpr safe_iterator_t<R> |
| 5155 | + constexpr safe_subrange_t<R> |
5142 | 5156 | ranges::unique(R&& r, C comp = {}, Proj proj = {});
|
5143 | 5157 | \end{itemdecl}
|
5144 | 5158 |
|
|
5173 | 5187 |
|
5174 | 5188 | \pnum
|
5175 | 5189 | \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} |
5177 | 5195 |
|
5178 | 5196 | \pnum
|
5179 | 5197 | \complexity
|
|
6053 | 6071 | class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
|
6054 | 6072 | requires IndirectlyCopyable<I1, I2> && Sortable<I2, Comp, Proj2> &&
|
6055 | 6073 | IndirectStrictWeakOrder<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
|
6056 |
| - constexpr I2 |
| 6074 | + constexpr ranges::partial_sort_copy_result<I1, I2> |
6057 | 6075 | ranges::partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
|
6058 | 6076 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
6059 | 6077 | template<InputRange R1, RandomAccessRange R2, class Comp = ranges::less,
|
|
6062 | 6080 | Sortable<iterator_t<R2>, Comp, Proj2> &&
|
6063 | 6081 | IndirectStrictWeakOrder<Comp, projected<iterator_t<R1>, Proj1>,
|
6064 | 6082 | 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>> |
6066 | 6084 | ranges::partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
|
6067 | 6085 | Proj1 proj1 = {}, Proj2 proj2 = {});
|
6068 | 6086 | \end{itemdecl}
|
|
6110 | 6128 |
|
6111 | 6129 | \pnum
|
6112 | 6130 | \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} |
6114 | 6138 |
|
6115 | 6139 | \pnum
|
6116 | 6140 | \complexity
|
|
6598 | 6622 |
|
6599 | 6623 | template<Permutable I, Sentinel<I> S, class Proj = identity,
|
6600 | 6624 | IndirectUnaryPredicate<projected<I, Proj>> Pred>
|
6601 |
| - constexpr I |
| 6625 | + constexpr subrange<I> |
6602 | 6626 | ranges::partition(I first, S last, Pred pred, Proj proj = {});
|
6603 | 6627 | template<ForwardRange R, class Proj = identity,
|
6604 | 6628 | IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
|
6605 | 6629 | requires Permutable<iterator_t<R>>
|
6606 |
| - constexpr safe_iterator_t<R> |
| 6630 | + constexpr safe_subrange_t<R> |
6607 | 6631 | ranges::partition(R&& r, Pred pred, Proj proj = {});
|
6608 | 6632 | \end{itemdecl}
|
6609 | 6633 |
|
|
6626 | 6650 |
|
6627 | 6651 | \pnum
|
6628 | 6652 | \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 |
6630 | 6654 | \tcode{true} for every iterator \tcode{j} in \range{first}{i} and
|
6631 | 6655 | \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 | + |
6632 | 6662 |
|
6633 | 6663 | \pnum
|
6634 | 6664 | \complexity Let $N = \tcode{last - first}$:
|
|
6662 | 6692 | template<BidirectionalIterator I, Sentinel<I> S, class Proj = identity,
|
6663 | 6693 | IndirectUnaryPredicate<projected<I, Proj>> Pred>
|
6664 | 6694 | 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 = {}); |
6666 | 6696 | template<BidirectionalRange R, class Proj = identity,
|
6667 | 6697 | IndirectUnaryPredicate<projected<iterator_t<R>, Proj>> Pred>
|
6668 | 6698 | 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 = {}); |
6670 | 6700 | \end{itemdecl}
|
6671 | 6701 |
|
6672 | 6702 | \begin{itemdescr}
|
|
6691 | 6721 |
|
6692 | 6722 | \pnum
|
6693 | 6723 | \returns
|
6694 |
| -An iterator \tcode{i} |
| 6724 | +Let \tcode{i} be an iterator |
6695 | 6725 | such that for every iterator \tcode{j} in \range{first}{i},
|
6696 | 6726 | $E(\tcode{*j})$ is \tcode{true},
|
6697 | 6727 | 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 | + |
6699 | 6735 |
|
6700 | 6736 | \pnum
|
6701 | 6737 | \complexity
|
|
8430 | 8466 | template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
|
8431 | 8467 | class Proj = identity>
|
8432 | 8468 | requires Sortable<I, Comp, Proj>
|
8433 |
| - constexpr bool |
| 8469 | + constexpr ranges::next_permutation_result<I> |
8434 | 8470 | ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {});
|
8435 | 8471 | template<BidirectionalRange R, class Comp = ranges::less,
|
8436 | 8472 | class Proj = identity>
|
8437 | 8473 | requires Sortable<iterator_t<R>, Comp, Proj>
|
8438 |
| - constexpr bool |
| 8474 | + constexpr ranges::next_permutation_result<safe_iterator_t<R>> |
8439 | 8475 | ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {});
|
8440 | 8476 | \end{itemdecl}
|
8441 | 8477 |
|
|
8463 | 8499 |
|
8464 | 8500 | \pnum
|
8465 | 8501 | \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} |
8467 | 8509 |
|
8468 | 8510 | \pnum
|
8469 | 8511 | \complexity
|
|
8483 | 8525 | template<BidirectionalIterator I, Sentinel<I> S, class Comp = ranges::less,
|
8484 | 8526 | class Proj = identity>
|
8485 | 8527 | requires Sortable<I, Comp, Proj>
|
8486 |
| - constexpr bool |
| 8528 | + constexpr ranges::prev_permutation_result<I> |
8487 | 8529 | ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {});
|
8488 | 8530 | template<BidirectionalRange R, class Comp = ranges::less,
|
8489 | 8531 | class Proj = identity>
|
8490 | 8532 | requires Sortable<iterator_t<R>, Comp, Proj>
|
8491 |
| - constexpr bool |
| 8533 | + constexpr ranges::prev_permutation_result<safe_iterator_t<R>> |
8492 | 8534 | ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {});
|
8493 | 8535 | \end{itemdecl}
|
8494 | 8536 |
|
|
8516 | 8558 |
|
8517 | 8559 | \pnum
|
8518 | 8560 | \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} |
8520 | 8568 |
|
8521 | 8569 | \pnum
|
8522 | 8570 | \complexity
|
|
0 commit comments