public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	"libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH] libstdc++: Fix typo in views::as_const's operator() [PR109525]
Date: Mon, 17 Apr 2023 09:23:16 +0200	[thread overview]
Message-ID: <CAH6eHdRoOCLmVn_h_Jc5FZh+0tt6C3bp9kSfRt-BXKJ2cY5New@mail.gmail.com> (raw)
In-Reply-To: <20230417034553.2646005-1-ppalka@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3552 bytes --]

OK

On Mon, 17 Apr 2023, 05:46 Patrick Palka via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

>         PR libstdc++/109525
>
> libstdc++-v3/ChangeLog:
>
>         * include/std/ranges (views::_AsConst::operator()): Add
>         missing const to constant_range test.
>         * testsuite/std/ranges/adaptors/as_const/1.cc (test02):
>         Improve formatting.  Adjust expected type of v2.
>         (test03): New test.
> ---
>  libstdc++-v3/include/std/ranges               |  2 +-
>  .../std/ranges/adaptors/as_const/1.cc         | 37 ++++++++++++-------
>  2 files changed, 24 insertions(+), 15 deletions(-)
>
> diff --git a/libstdc++-v3/include/std/ranges
> b/libstdc++-v3/include/std/ranges
> index 283d757faa4..1714f3fb16c 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -9025,7 +9025,7 @@ namespace views::__adaptor
>           return ref_view(static_cast<const element_type&>
>                           (std::forward<_Range>(__r).base()));
>         else if constexpr (is_lvalue_reference_v<_Range>
> -                          && constant_range<_Tp>
> +                          && constant_range<const _Tp>
>                            && !view<_Tp>)
>           return ref_view(static_cast<const _Tp&>(__r));
>         else
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc
> b/libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc
> index d04645f047e..ac1be7440e4 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc
> @@ -5,6 +5,7 @@
>  #include <algorithm>
>  #include <span>
>  #include <utility>
> +#include <vector>
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>
> @@ -36,29 +37,37 @@ test01()
>  constexpr bool
>  test02()
>  {
> -  std::same_as<ranges::empty_view<const int>> auto v1
> -    = views::empty<int> | views::as_const;
> -
>    int x[] = {1, 2, 3};
> -  std::same_as<ranges::as_const_view<ranges::ref_view<int[3]>>> auto v2
> -    = x | views::as_const;
> -  std::same_as<ranges::ref_view<const int[3]>> auto v3
> -    = std::as_const(x) | views::as_const;
> -  std::same_as<ranges::ref_view<const int[3]>> auto v4
> -    = std::as_const(x) | views::all | views::as_const;
> -  std::same_as<std::span<const int>> auto v5
> -    = std::span{x, x+3} | views::as_const;
> -
> -
> std::same_as<ranges::as_const_view<ranges::chunk_view<ranges::ref_view<int[3]>>>>
> auto v6
> -     = x | views::chunk(2) | views::as_const;
> +  std::same_as<ranges::empty_view<const int>>
> +    auto v1 = views::empty<int> | views::as_const;
> +  std::same_as<ranges::ref_view<const int[3]>>
> +    auto v2 = x | views::as_const;
> +  std::same_as<ranges::ref_view<const int[3]>>
> +    auto v3 = std::as_const(x) | views::as_const;
> +  std::same_as<ranges::ref_view<const int[3]>>
> +    auto v4 = std::as_const(x) | views::all | views::as_const;
> +  std::same_as<std::span<const int>>
> +    auto v5 = std::span{x, x+3} | views::as_const;
> +
> std::same_as<ranges::as_const_view<ranges::chunk_view<ranges::ref_view<int[3]>>>>
> +    auto v6 = x | views::chunk(2) | views::as_const;
>    VERIFY( v6.size() == 2 );
>
>    return true;
>  }
>
> +void
> +test03()
> +{
> +  // PR libstdc++/109525
> +  std::vector<int> v;
> +  std::same_as<ranges::ref_view<const std::vector<int>>>
> +    auto r = views::as_const(v);
> +}
> +
>  int
>  main()
>  {
>    static_assert(test01());
>    static_assert(test02());
> +  test03();
>  }
> --
> 2.40.0.335.g9857273be0
>
>

  reply	other threads:[~2023-04-17  7:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17  3:45 Patrick Palka
2023-04-17  7:23 ` Jonathan Wakely [this message]
2023-04-18  8:57   ` Jonathan Wakely
2023-04-18  9:00     ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdRoOCLmVn_h_Jc5FZh+0tt6C3bp9kSfRt-BXKJ2cY5New@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).