Skip to content

Commit

Permalink
fix some mistakes in wording
Browse files Browse the repository at this point in the history
  • Loading branch information
huixie90 committed Sep 24, 2023
1 parent 572eb2d commit 3367270
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
21 changes: 11 additions & 10 deletions concat.md
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ namespace std::ranges {

constexpr auto end() requires(!(@_simple-view_@<Views> && ...));

constexpr auto end() const requires(range<const Views>&&...);
constexpr auto end() const
requires((range<const Views> && ...) && @_concatable_@<const Views...>);

constexpr auto size() requires(sized_range<Views>&&...);

Expand Down Expand Up @@ -823,7 +824,7 @@ concept @_concat-is-random-access_@ = @*see below*@; // exposition only

:::bq

[3]{.pnum} Let `Fs` be the pack that consists of all elements of `Rs` except the last, then `@_concat-is-random-access_@` is equivalent to:
[3]{.pnum} Let `Fs` be the pack that consists of all elements of `Rs` except the last element, then `@_concat-is-random-access_@` is equivalent to:

```cpp
template <bool Const, class... Rs>
Expand Down Expand Up @@ -882,7 +883,8 @@ return it;

```cpp
constexpr auto end() requires(!(@_simple-view_@<Views> && ...));
constexpr auto end() const requires(range<const Views>&&...);
constexpr auto end() const
requires((range<const Views> && ...) && @_concatable_@<const Views...>);
```
:::bq
Expand Down Expand Up @@ -1014,7 +1016,7 @@ namespace std::ranges{

friend constexpr auto operator<=>(const @_iterator_@& x, const @_iterator_@& y)
requires (@*all-random-access*@<Const, Views...> &&
(three_way_comparable<@_maybe-const_@<Const, Views>> &&...));
(three_way_comparable<iterator_t<@_maybe-const_@<Const, Views>>> && ...));

friend constexpr @_iterator_@ operator+(const @_iterator_@& it, difference_type n)
requires @_concat-is-random-access_@<Const, Views...>;
Expand Down Expand Up @@ -1185,7 +1187,7 @@ explicit constexpr @_iterator_@(
```cpp
constexpr @_iterator_@(@_iterator_@<!Const> it)
requires Const &&
(convertible_to<iterator_t<Views>, iterator_t<const Views>>&&...);
(convertible_to<iterator_t<Views>, iterator_t<const Views>> && ...);
```

:::bq
Expand Down Expand Up @@ -1398,7 +1400,7 @@ friend constexpr bool operator>=(const @_iterator_@& x, const @_iterator_@& y)
requires @*all-random-access*@<Const, Views...>;
friend constexpr auto operator<=>(const @_iterator_@& x, const @_iterator_@& y)
requires (@*all-random-access*@<Const, Views...> &&
(three_way_comparable<@_maybe-const_@<Const, Views>> &&...));
(three_way_comparable<iterator_t<@_maybe-const_@<Const, Views>>> && ...));
```
:::bq
Expand Down Expand Up @@ -1428,7 +1430,7 @@ friend constexpr @_iterator_@ operator+(const @_iterator_@& it, difference_type
[30]{.pnum} *Effects*: Equivalent to:

```cpp
return @_iterator_@{it} += n;
return @_iterator_@(it) += n;
```

:::
Expand Down Expand Up @@ -1458,7 +1460,7 @@ friend constexpr @_iterator_@ operator-(const @_iterator_@& it, difference_type
[32]{.pnum} *Effects*: Equivalent to:

```cpp
return @*iterator*@{it} -= n;
return @*iterator*@(it) -= n;
```

:::
Expand Down Expand Up @@ -1579,8 +1581,7 @@ return std::visit(
((is_nothrow_invocable_v<decltype(ranges::iter_move),
const iterator_t<@_maybe-const_@<Const, Views>>&> &&
is_nothrow_convertible_v<range_rvalue_reference_t<@_maybe-const_@<Const, Views>>,
common_reference_t<range_rvalue_reference_t<
@_maybe-const_@<Const, Views>>...>>) &&...)
@*concat-rvalue-reference-t*@<@_maybe-const_@<Const, Views>...>>) && ...)
```

:::
Expand Down
13 changes: 7 additions & 6 deletions impl/concat/concat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ class concat_view : public view_interface<concat_view<Views...>> {
friend constexpr auto
operator<=>(const iterator& x, const iterator& y) requires(
(random_access_range<__maybe_const<Const, Views>> &&
three_way_comparable<__maybe_const<Const, Views>>)&&...) {
three_way_comparable<iterator_t<__maybe_const<Const, Views>>>)&&...) {
return x.it_ <=> y.it_;
}

friend constexpr iterator operator+(const iterator& it,
difference_type n) requires
xo::concat_is_random_access<Const, Views...> {
return iterator{it} += n;
return iterator(it) += n;
}

friend constexpr iterator operator+(difference_type n,
Expand All @@ -487,7 +487,7 @@ class concat_view : public view_interface<concat_view<Views...>> {
friend constexpr iterator operator-(const iterator& it,
difference_type n) requires
xo::concat_is_random_access<Const, Views...> {
return iterator{it} -= n;
return iterator(it) -= n;
}

friend constexpr difference_type operator-(const iterator& x,
Expand Down Expand Up @@ -567,8 +567,7 @@ class concat_view : public view_interface<concat_view<Views...>> {
const iterator_t<__maybe_const<Const, Views>>&> &&
std::is_nothrow_convertible_v<
range_rvalue_reference_t<__maybe_const<Const, Views>>,
common_reference_t<range_rvalue_reference_t<
__maybe_const<Const, Views>>...>>)&&...)) {
xo::concat_rvalue_reference_t<__maybe_const<Const, Views>...>>)&&...)) {
return std::visit(
[](auto const& i) -> xo::concat_rvalue_reference_t<
__maybe_const<Const, Views>...> { //
Expand Down Expand Up @@ -628,7 +627,9 @@ class concat_view : public view_interface<concat_view<Views...>> {
}
}

constexpr auto end() const requires(range<const Views>&&...) {
constexpr auto end() const requires((range<const Views>&&...) &&
xo::concatable<const Views...>)
{
using LastView = xo::back<const Views...>;
if constexpr (common_range<LastView>) {
constexpr auto N = sizeof...(Views);
Expand Down
11 changes: 11 additions & 0 deletions impl/concat/test/basics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,3 +757,14 @@ TEST_POINT("size") {
auto cv2 = std::ranges::concat_view(std::views::all(v1), std::views::all(v1));
CHECK(cv2.size() == 4);
}

TEST_POINT("spaceship")
{
int a1[] = {1,2};
int a2[] = {3,4};
auto v1 = std::views::concat(a1,a2);

auto it = v1.begin();

[[maybe_unused]] auto b = it <=> it;
}

0 comments on commit 3367270

Please sign in to comment.