|
641 | 641 |
|
642 | 642 | template<class I>
|
643 | 643 | struct in_found_result;
|
| 644 | + |
| 645 | + template<class O, class T> |
| 646 | + struct out_value_result; |
644 | 647 | }
|
645 | 648 |
|
646 | 649 | // \ref{alg.nonmodifying}, non-modifying sequence operations
|
|
1815 | 1818 | shift_left(ExecutionPolicy&& exec, // see \ref{algorithms.parallel.overloads}
|
1816 | 1819 | ForwardIterator first, ForwardIterator last,
|
1817 | 1820 | typename iterator_traits<ForwardIterator>::difference_type n);
|
| 1821 | + |
| 1822 | + namespace ranges { |
| 1823 | + template<@\libconcept{permutable}@ I, @\libconcept{sentinel_for}@<I> S> |
| 1824 | + constexpr subrange<I> shift_left(I first, S last, iter_difference_t<I> n); |
| 1825 | + template<@\libconcept{forward_range}@ R> |
| 1826 | + requires @\libconcept{permutable}@<iterator_t<R>> |
| 1827 | + constexpr borrowed_subrange_t<R> shift_left(R&& r, range_difference_t<R> n); |
| 1828 | + } |
| 1829 | + |
1818 | 1830 | template<class ForwardIterator>
|
1819 | 1831 | constexpr ForwardIterator
|
1820 | 1832 | shift_right(ForwardIterator first, ForwardIterator last,
|
|
1825 | 1837 | ForwardIterator first, ForwardIterator last,
|
1826 | 1838 | typename iterator_traits<ForwardIterator>::difference_type n);
|
1827 | 1839 |
|
| 1840 | + namespace ranges { |
| 1841 | + template<@\libconcept{permutable}@ I, @\libconcept{sentinel_for}@<I> S> |
| 1842 | + constexpr subrange<I> shift_right(I first, S last, iter_difference_t<I> n); |
| 1843 | + template<@\libconcept{forward_range}@ R> |
| 1844 | + requires @\libconcept{permutable}@<iterator_t<R>> |
| 1845 | + constexpr borrowed_subrange_t<R> shift_right(R&& r, range_difference_t<R> n); |
| 1846 | + } |
| 1847 | + |
1828 | 1848 | // \ref{alg.sorting}, sorting and related operations
|
1829 | 1849 | // \ref{alg.sort}, sorting
|
1830 | 1850 | template<class RandomAccessIterator>
|
|
2741 | 2761 | ForwardIterator first, ForwardIterator last,
|
2742 | 2762 | Compare comp);
|
2743 | 2763 |
|
2744 |
| - namespace ranges { |
| 2764 | + namespace ranges { |
2745 | 2765 | template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity,
|
2746 | 2766 | @\libconcept{indirect_strict_weak_order}@<projected<I, Proj>> Comp = ranges::less>
|
2747 | 2767 | constexpr I max_element(I first, S last, Comp comp = {}, Proj proj = {});
|
|
3037 | 3057 | return {std::move(in), found};
|
3038 | 3058 | }
|
3039 | 3059 | };
|
| 3060 | + |
| 3061 | + template<class O, class T> |
| 3062 | + struct out_value_result { |
| 3063 | + [[no_unique_address]] O out; |
| 3064 | + [[no_unique_address]] T value; |
| 3065 | + |
| 3066 | + template<class O2, class T2> |
| 3067 | + requires @\libconcept{convertible_to}@<const O&, O2> && @\libconcept{convertible_to}@<const T&, T2> |
| 3068 | + constexpr operator out_value_result<O2, T2>() const & { |
| 3069 | + return {out, value}; |
| 3070 | + } |
| 3071 | + |
| 3072 | + template<class O2, class T2> |
| 3073 | + requires @\libconcept{convertible_to}@<O, O2> && @\libconcept{convertible_to}@<T, T2> |
| 3074 | + constexpr operator out_value_result<O2, T2>() && { |
| 3075 | + return {std::move(out), std::move(value)}; |
| 3076 | + } |
| 3077 | + }; |
3040 | 3078 | }
|
3041 | 3079 | \end{codeblock}
|
3042 | 3080 |
|
|
6003 | 6041 | ForwardIterator
|
6004 | 6042 | shift_left(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
|
6005 | 6043 | typename iterator_traits<ForwardIterator>::difference_type n);
|
| 6044 | + |
| 6045 | +template<@\libconcept{permutable}@ I, @\libconcept{sentinel_for}@<I> S> |
| 6046 | + constexpr subrange<I> ranges::shift_left(I first, S last, iter_difference_t<I> n); |
| 6047 | +template<@\libconcept{forward_range}@ R> |
| 6048 | + requires @\libconcept{permutable}@<iterator_t<R>> |
| 6049 | + constexpr borrowed_subrange_t<R> ranges::shift_left(R&& r, range_difference_t<R> n) |
6006 | 6050 | \end{itemdecl}
|
6007 | 6051 |
|
6008 | 6052 | \begin{itemdescr}
|
6009 | 6053 | \pnum
|
6010 | 6054 | \expects
|
6011 | 6055 | \tcode{n >= 0} is \tcode{true}.
|
6012 |
| -The type of \tcode{*first} meets |
6013 |
| -the \oldconcept{MoveAssignable} requirements. |
| 6056 | +For the overloads in namespace \tcode{std}, |
| 6057 | +the type of \tcode{*first} meets the \oldconcept{MoveAssignable} requirements. |
6014 | 6058 |
|
6015 | 6059 | \pnum
|
6016 | 6060 | \effects
|
|
6019 | 6063 | from position \tcode{first + n + i}
|
6020 | 6064 | into position \tcode{first + i}
|
6021 | 6065 | for each non-negative integer \tcode{i < (last - first) - n}.
|
6022 |
| -In the first overload case, does so in order starting |
| 6066 | +For the overloads without an \tcode{ExecutionPolicy} template parameter, |
| 6067 | +does so in order starting |
6023 | 6068 | from \tcode{i = 0} and proceeding to \tcode{i = (last - first) - n - 1}.
|
6024 | 6069 |
|
6025 | 6070 | \pnum
|
6026 | 6071 | \returns
|
6027 |
| -\tcode{first + (last - first - n)} |
| 6072 | +Let \exposid{NEW_LAST} be \tcode{first + (last - first - n)} |
6028 | 6073 | if \tcode{n < last - first},
|
6029 | 6074 | otherwise \tcode{first}.
|
| 6075 | +\begin{itemize} |
| 6076 | +\item |
| 6077 | +\exposid{NEW_LAST} for the overloads in namespace \tcode{std}. |
| 6078 | +\item |
| 6079 | +\tcode{\{first, \exposid{NEW_LAST}\}} |
| 6080 | +for the overloads in namespace \tcode{ranges}. |
| 6081 | +\end{itemize} |
6030 | 6082 |
|
6031 | 6083 | \pnum
|
6032 | 6084 | \complexity
|
|
6043 | 6095 | ForwardIterator
|
6044 | 6096 | shift_right(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
|
6045 | 6097 | typename iterator_traits<ForwardIterator>::difference_type n);
|
| 6098 | + |
| 6099 | +template<@\libconcept{permutable}@ I, @\libconcept{sentinel_for}@<I> S> |
| 6100 | + constexpr subrange<I> ranges::shift_right(I first, S last, iter_difference_t<I> n); |
| 6101 | +template<@\libconcept{forward_range}@ R> |
| 6102 | + requires @\libconcept{permutable}@<iterator_t<R>> |
| 6103 | + constexpr borrowed_subrange_t<R> ranges::shift_right(R&& r, range_difference_t<R> n); |
6046 | 6104 | \end{itemdecl}
|
6047 | 6105 |
|
6048 | 6106 | \begin{itemdescr}
|
6049 | 6107 | \pnum
|
6050 | 6108 | \expects
|
6051 | 6109 | \tcode{n >= 0} is \tcode{true}.
|
6052 |
| -The type of \tcode{*first} meets |
6053 |
| -the \oldconcept{MoveAssignable} requirements. |
6054 |
| -\tcode{ForwardIterator} meets |
| 6110 | +For the overloads in namespace \tcode{std}, |
| 6111 | +the type of \tcode{*first} meets the \oldconcept{MoveAssignable} requirements, |
| 6112 | +and \tcode{ForwardIterator} meets |
6055 | 6113 | the \oldconcept{BidirectionalIterator} requirements\iref{bidirectional.iterators} or
|
6056 | 6114 | the \oldconcept{ValueSwap\-pable} requirements.
|
6057 | 6115 |
|
|
6061 | 6119 | Otherwise, moves the element
|
6062 | 6120 | from position \tcode{first + i} into position \tcode{first + n + i}
|
6063 | 6121 | for each non-negative integer \tcode{i < (last - first) - n}.
|
6064 |
| -In the first overload case, if \tcode{ForwardIterator} meets |
6065 |
| -the \oldconcept{BidirectionalIterator} requirements, |
6066 |
| -does so in order starting |
6067 |
| -from \tcode{i = (last - first) - n - 1} and proceeding to \tcode{i = 0}. |
| 6122 | +Does so in order starting |
| 6123 | +from \tcode{i = (last - first) - n - 1} and proceeding to \tcode{i = 0} if: |
| 6124 | +\begin{itemize} |
| 6125 | +\item |
| 6126 | +for the overload in namespace \tcode{std} |
| 6127 | +without an \tcode{ExecutionPolicy} template parameter, |
| 6128 | +\tcode{Forward\-Iterator} meets the \oldconcept{BidirectionalIterator} requirements, |
| 6129 | +\item |
| 6130 | +for the overloads in namespace \tcode{ranges}, |
| 6131 | +\tcode{I} models \libconcept{bidirectional_iterator}. |
| 6132 | +\end{itemize} |
6068 | 6133 |
|
6069 | 6134 | \pnum
|
6070 | 6135 | \returns
|
6071 |
| -\tcode{first + n} |
6072 |
| -if \tcode{n < last - first}, |
| 6136 | +Let \exposid{NEW_FIRST} be \tcode{first + n} if \tcode{n < last - first}, |
6073 | 6137 | otherwise \tcode{last}.
|
| 6138 | +\begin{itemize} |
| 6139 | +\item |
| 6140 | +\exposid{NEW_FIRST} for the overloads in namespace \tcode{std}. |
| 6141 | +\item |
| 6142 | +\tcode{\{\exposid{NEW_FIRST}, last\}} |
| 6143 | +for the overloads in namespace \tcode{ranges}. |
| 6144 | +\end{itemize} |
6074 | 6145 |
|
6075 | 6146 | \pnum
|
6076 | 6147 | \complexity
|
|
9104 | 9175 | template<class ForwardIterator, class T>
|
9105 | 9176 | constexpr void iota(ForwardIterator first, ForwardIterator last, T value);
|
9106 | 9177 |
|
| 9178 | + namespace ranges { |
| 9179 | + template<class O, class T> |
| 9180 | + using iota_result = out_value_result<O, T>; |
| 9181 | + |
| 9182 | + template<@\libconcept{input_or_output_iterator}@ O, @\libconcept{sentinel_for}@<O> S, @\libconcept{weakly_incrementable}@ T> |
| 9183 | + requires @\libconcept{indirectly_writable}@<O, const T&> |
| 9184 | + constexpr iota_result<O, T> iota(O first, S last, T value); |
| 9185 | + |
| 9186 | + template<@\libconcept{weakly_incrementable}@ T, @\libconcept{output_range}@<const T&> R> |
| 9187 | + constexpr iota_result<borrowed_iterator_t<R>, T> iota(R&& r, T value); |
| 9188 | + } |
| 9189 | + |
9107 | 9190 | // \ref{numeric.ops.gcd}, greatest common divisor
|
9108 | 9191 | template<class M, class N>
|
9109 | 9192 | constexpr common_type_t<M, N> gcd(M m, N n);
|
|
10105 | 10188 | Exactly \tcode{last - first} increments and assignments.
|
10106 | 10189 | \end{itemdescr}
|
10107 | 10190 |
|
| 10191 | +\indexlibraryglobal{iota}% |
| 10192 | +\begin{itemdecl} |
| 10193 | +template<@\libconcept{input_or_output_iterator}@ O, @\libconcept{sentinel_for}@<O> S, @\libconcept{weakly_incrementable}@ T> |
| 10194 | + requires @\libconcept{indirectly_writable}@<O, const T&> |
| 10195 | + constexpr ranges::iota_result<O, T> ranges::iota(O first, S last, T value); |
| 10196 | +template<@\libconcept{weakly_incrementable}@ T, @\libconcept{output_range}@<const T&> R> |
| 10197 | + constexpr ranges::iota_result<borrowed_iterator_t<R>, T> ranges::iota(R&& r, T value); |
| 10198 | +\end{itemdecl} |
| 10199 | + |
| 10200 | +\begin{itemdescr} |
| 10201 | +\pnum |
| 10202 | +\effects |
| 10203 | +Equivalent to: |
| 10204 | +\begin{codeblock} |
| 10205 | +while (first != last) { |
| 10206 | + *first = as_const(value); |
| 10207 | + ++first; |
| 10208 | + ++value; |
| 10209 | +} |
| 10210 | +return {std::move(first), std::move(value)}; |
| 10211 | +\end{codeblock} |
| 10212 | +\end{itemdescr} |
| 10213 | + |
10108 | 10214 | \rSec2[numeric.ops.gcd]{Greatest common divisor}
|
10109 | 10215 |
|
10110 | 10216 | \indexlibraryglobal{gcd}%
|
|
0 commit comments