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