From 2ca40ee0ade0dea330cb8f2d40fdb61cae55fa3b Mon Sep 17 00:00:00 2001 From: huixie90 Date: Sun, 24 Sep 2023 14:57:09 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20huixie90?= =?UTF-8?q?/cpp=5Fpapers@3367270021472db83eed1b300733e03cac6854ff=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- concat.md | 21 ++++++++++---------- generated/concat.html | 39 +++++++++++++++++++------------------ impl/concat/concat.hpp | 13 +++++++------ impl/concat/test/basics.cpp | 11 +++++++++++ 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/concat.md b/concat.md index 3e356f6..9048347 100644 --- a/concat.md +++ b/concat.md @@ -750,7 +750,8 @@ namespace std::ranges { constexpr auto end() requires(!(@_simple-view_@ && ...)); - constexpr auto end() const requires(range&&...); + constexpr auto end() const + requires((range && ...) && @_concatable_@); constexpr auto size() requires(sized_range&&...); @@ -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 @@ -882,7 +883,8 @@ return it; ```cpp constexpr auto end() requires(!(@_simple-view_@ && ...)); -constexpr auto end() const requires(range&&...); +constexpr auto end() const + requires((range && ...) && @_concatable_@); ``` :::bq @@ -1014,7 +1016,7 @@ namespace std::ranges{ friend constexpr auto operator<=>(const @_iterator_@& x, const @_iterator_@& y) requires (@*all-random-access*@ && - (three_way_comparable<@_maybe-const_@> &&...)); + (three_way_comparable>> && ...)); friend constexpr @_iterator_@ operator+(const @_iterator_@& it, difference_type n) requires @_concat-is-random-access_@; @@ -1185,7 +1187,7 @@ explicit constexpr @_iterator_@( ```cpp constexpr @_iterator_@(@_iterator_@ it) requires Const && - (convertible_to, iterator_t>&&...); + (convertible_to, iterator_t> && ...); ``` :::bq @@ -1398,7 +1400,7 @@ friend constexpr bool operator>=(const @_iterator_@& x, const @_iterator_@& y) requires @*all-random-access*@; friend constexpr auto operator<=>(const @_iterator_@& x, const @_iterator_@& y) requires (@*all-random-access*@ && - (three_way_comparable<@_maybe-const_@> &&...)); + (three_way_comparable>> && ...)); ``` :::bq @@ -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; ``` ::: @@ -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; ``` ::: @@ -1579,8 +1581,7 @@ return std::visit( ((is_nothrow_invocable_v>&> && is_nothrow_convertible_v>, - common_reference_t>...>>) &&...) + @*concat-rvalue-reference-t*@<@_maybe-const_@...>>) && ...) ``` ::: diff --git a/generated/concat.html b/generated/concat.html index 48d22cd..0c3abe4 100644 --- a/generated/concat.html +++ b/generated/concat.html @@ -1373,16 +1373,17 @@

?.?.?.2 constexpr auto end() requires(!(simple-view<Views> && ...)); - constexpr auto end() const requires(range<const Views>&&...); - - constexpr auto size() requires(sized_range<Views>&&...); - - constexpr auto size() const requires(sized_range<const Views>&&...); - }; - - template <class... R> - concat_view(R&&...) -> concat_view<views::all_t<R>...>; -} + constexpr auto end() const + requires((range<const Views> && ...) && concatable<const Views...>); + + constexpr auto size() requires(sized_range<Views>&&...); + + constexpr auto size() const requires(sized_range<const Views>&&...); + }; + + template <class... R> + concat_view(R&&...) -> concat_view<views::all_t<R>...>; +}
template <class... Rs>
 concept concat-indirectly-readable = see below; // exposition only
@@ -1430,7 +1431,7 @@

?.?.?.2

3 Let Fs be the pack that consists of all elements of Rs except the -last, then +last element, then concat-is-random-access is equivalent to:

template <bool Const, class... Rs>
@@ -1473,7 +1474,8 @@ 

?.?.?.2 return it;

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...>);

7 Effects: Let @@ -1595,7 +1597,7 @@

?.?. 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...>; @@ -1760,7 +1762,7 @@

?.?.

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>> && ...);

8 Effects: Initializes @@ -1900,7 +1902,7 @@

?.?. 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>>> && ...));

26 Preconditions: x.it_.valueless_by_exception() @@ -1920,7 +1922,7 @@

?.?. is false.

30 Effects: Equivalent to:

-
return iterator{it} += n;
+
return iterator(it) += n;

friend constexpr iterator operator+(difference_type n, const iterator& it)
     requires concat-is-random-access<Const, Views...>;
@@ -1934,7 +1936,7 @@

?.?.

32 Effects: Equivalent to:

-
return iterator{it} -= n;
+
return iterator(it) -= n;
friend constexpr difference_type operator-(const iterator& x, const iterator& y) 
     requires concat-is-random-access<Const, Views...>;
@@ -2028,8 +2030,7 @@

?.?.
((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>...>>) && ...)
friend constexpr void iter_swap(const iterator& x, const iterator& y) noexcept(see below)
     requires see below;
diff --git a/impl/concat/concat.hpp b/impl/concat/concat.hpp index 2abcda8..e444afb 100644 --- a/impl/concat/concat.hpp +++ b/impl/concat/concat.hpp @@ -468,14 +468,14 @@ class concat_view : public view_interface> { friend constexpr auto operator<=>(const iterator& x, const iterator& y) requires( (random_access_range<__maybe_const> && - three_way_comparable<__maybe_const>)&&...) { + three_way_comparable>>)&&...) { return x.it_ <=> y.it_; } friend constexpr iterator operator+(const iterator& it, difference_type n) requires xo::concat_is_random_access { - return iterator{it} += n; + return iterator(it) += n; } friend constexpr iterator operator+(difference_type n, @@ -487,7 +487,7 @@ class concat_view : public view_interface> { friend constexpr iterator operator-(const iterator& it, difference_type n) requires xo::concat_is_random_access { - return iterator{it} -= n; + return iterator(it) -= n; } friend constexpr difference_type operator-(const iterator& x, @@ -567,8 +567,7 @@ class concat_view : public view_interface> { const iterator_t<__maybe_const>&> && std::is_nothrow_convertible_v< range_rvalue_reference_t<__maybe_const>, - common_reference_t>...>>)&&...)) { + xo::concat_rvalue_reference_t<__maybe_const...>>)&&...)) { return std::visit( [](auto const& i) -> xo::concat_rvalue_reference_t< __maybe_const...> { // @@ -628,7 +627,9 @@ class concat_view : public view_interface> { } } - constexpr auto end() const requires(range&&...) { + constexpr auto end() const requires((range&&...) && + xo::concatable) + { using LastView = xo::back; if constexpr (common_range) { constexpr auto N = sizeof...(Views); diff --git a/impl/concat/test/basics.cpp b/impl/concat/test/basics.cpp index 3f6fdd5..8bbc068 100644 --- a/impl/concat/test/basics.cpp +++ b/impl/concat/test/basics.cpp @@ -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; +}