From 14077ac72763d0b1d8dbc303d55aae08fcfa5924 Mon Sep 17 00:00:00 2001 From: Hui Date: Fri, 9 Jun 2023 10:49:08 +0100 Subject: [PATCH] iter_swap wording and operator-(default_sentinel, x) wording --- concat.md | 90 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/concat.md b/concat.md index 90eeb60..993d1be 100644 --- a/concat.md +++ b/concat.md @@ -17,6 +17,7 @@ toc: true - Fixed conversions of `difference` types - Redesign `iter_swap` +- Relax `random_access_range` constraints - Various wording fixes ## R2 @@ -351,8 +352,11 @@ went with the second constraint. In this paper, both are supported. ## Random Access Range -`concat_view` can be `random_access_range` if all the underlying ranges model -`random_access_range` and `sized_range`. +`concat_view` can model `random_access_range` if the underlying ranges satisfy +the following conditions: + +- Every underlying range models `random_access_range` +- All except the last range model `sized_range` ## Sized Range @@ -632,7 +636,7 @@ concept @_concatable_@ = requires { // exposition only ```cpp template -concept @_concat-is-bidirectional_@ = @*see below*@; // exposition only +concept @_concat-is-random-access_@ = @*see below*@; // exposition only ``` :::bq @@ -643,9 +647,18 @@ concept @_concat-is-bidirectional_@ = @*see below*@; // exposition only template concept @_concat-is-random-access_@ = // exposition only (@*all-random-access*@ && ...) && - (sized_range<@*maybe-const*@> && ...) + (sized_range<@*maybe-const*@> && ...); +``` + +::: + +```cpp +template +concept @_concat-is-bidirectional_@ = @*see below*@; // exposition only ``` +:::bq + [4]{.pnum} Let `V` be the last element of `Rs`, and `Fs` be the pack that consists of all elements of `Rs` except `V`, then `@_concat-is-bidirectional_@` is equivalent to: ```cpp @@ -834,10 +847,10 @@ namespace std::ranges{ requires @_concat-is-random-access_@; friend constexpr difference_type operator-(const @_iterator_@& x, default_sentinel_t) - requires @_concat-is-random-access_@; + requires @*see below*@; friend constexpr difference_type operator-(default_sentinel_t, const @_iterator_@& x) - requires @_concat-is-random-access_@; + requires @*see below*@; friend constexpr decltype(auto) iter_move(const iterator& it) noexcept(@*see below*@); @@ -1318,7 +1331,7 @@ denote `y.@*it_*@.index()` ```cpp friend constexpr difference_type operator-(const @_iterator_@& x, default_sentinel_t) - requires @_concat-is-random-access_@; + requires @*see below*@; ``` :::bq @@ -1336,21 +1349,33 @@ otherwise, equivalent to return -(static_cast(@*d~x~*@) + static_cast(s)); ``` +[37]{.pnum} *Remarks*: Let `V` be the last element of Pack `Views`, the expression in the requires-clause is equivalent to: + +```cpp +(@_concat-is-random-access_@ && sized_range<@*maybe-const*@>) +``` + ::: ```cpp friend constexpr difference_type operator-(default_sentinel_t, const @_iterator_@& x) - requires @_concat-is-random-access_@; + requires @*see below*@; ``` :::bq -[37]{.pnum} *Effects*: Equivalent to: +[38]{.pnum} *Effects*: Equivalent to: ```cpp return -(x - default_sentinel); ``` +[39]{.pnum} *Remarks*: Let `V` be the last element of Pack `Views`, the expression in the requires-clause is equivalent to: + +```cpp +(@_concat-is-random-access_@ && sized_range<@*maybe-const*@>) +``` + ::: ```cpp @@ -1359,9 +1384,9 @@ friend constexpr decltype(auto) iter_move(const iterator& it) noexcept(@*see bel :::bq -[38]{.pnum} *Preconditions*: `it.@*it_*@.valueless_by_exception()` is `false`. +[40]{.pnum} *Preconditions*: `it.@*it_*@.valueless_by_exception()` is `false`. -[39]{.pnum} *Effects*: Equivalent to: +[41]{.pnum} *Effects*: Equivalent to: ```cpp return std::visit( @@ -1372,7 +1397,7 @@ return std::visit( it.@*it_*@); ``` -[40]{.pnum} *Remarks*: The exception specification is equivalent to: +[42]{.pnum} *Remarks*: The exception specification is equivalent to: ```cpp ((is_nothrow_invocable_v) { + ranges::iter_swap(it1, it2); + } else { + ranges::swap(*x, *y); + } + }, + x.@*it_*@, y.@*it_*@); ``` -[43]{.pnum} *Remarks*: The exception specification is `true` if and -only if: For every combination of two types `X` and `Y` in the set of all types -in the parameter pack `iterator_t<@_maybe-const_@>>...`, -`is_nothrow_invocable_v` is true. +[45]{.pnum} *Remarks*: Let `N` be the logcial `AND` of the following expressions: -[44]{.pnum} *Remarks*: The expression in the requires-clause is `true` if and -only if: For every combination of two types `X` and `Y` in the set of all types -in the parameter pack `iterator_t<@_maybe-const_@>>...`, -`indirectly_swappable` is modelled. +```cpp +noexcept(ranges::iter_swap(std::get<@*i*@>(x.@*it_*@), std::get<@*i*@>(y.@*it_*@))) +``` -requires(indirectly_swappable>> && ... && - swappable_with...>, - xo::concat_reference_t<__maybe_const...>>) +for every integer 0 <= @*i*@ < `sizeof...(Views)`, the exception specification is equavalent to +```cpp +noexcept(ranges::swap(*x, *y)) && N +``` + +[46]{.pnum} *Remarks*: The expression in the requires-clause is equivalent to + +```cpp +(indirectly_swappable>> && ... && + swappable_with<@*concat-reference-t*@<@*maybe-const*@...>, + @*concat-reference-t*@<@*maybe-const*@...>>) +``` :::