public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: Patrick Palka <ppalka@redhat.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	 "libstdc++" <libstdc++@gcc.gnu.org>,
	Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH 2/2] libstdc++: Implement range_adaptor_closure from P2387R3 [PR108827]
Date: Tue, 18 Apr 2023 09:57:19 +0100	[thread overview]
Message-ID: <CACb0b4kAjORe9anH=gkp1pWvoKxyofizUCHAoR2rZHbiixPwug@mail.gmail.com> (raw)
In-Reply-To: <CAH6eHdRxgH7vrAxvJRyMwsBKo_DTDWqzXKhcrOb726FfO2CWRw@mail.gmail.com>

On Mon, 17 Apr 2023 at 08:26, Jonathan Wakely via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> On Mon, 17 Apr 2023, 05:28 Patrick Palka via Libstdc++, <
> libstdc++@gcc.gnu.org> wrote:
>
> > On Fri, 14 Apr 2023, Patrick Palka wrote:
> >
> > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
> > >
> > >       PR libstdc++/108827
> > >
> > > libstdc++-v3/ChangeLog:
> > >
> > >       * include/bits/ranges_cmp.h (__cpp_lib_ranges): Bump value
> > >       for C++23.
> > >       * include/std/ranges (range_adaptor_closure): Define for C++23.
> > >       * include/std/version (__cpp_lib_ranges): Bump value for
> > >       C++23.
> > >       * testsuite/std/ranges/version_c++23.cc: Bump expected value
> > >       of __cpp_lib_ranges.
> > >       * testsuite/std/ranges/range_adaptor_closure.cc: New test.
> >
> > Here's a standalone version of this patch (not dependent on the first
> > patch in the series) it terms of the current non-CRTP representation
> > of _RangeAdaptorClosure:
> >
>
> OK, thanks for separating this from the other change.

I'd like RM approval to push this C++23-only change to gcc-13 as well as trunk.

>
>
>
> > -- >8 --
> >
> > Subject: [PATCH] libstdc++: Implement range_adaptor_closure from P2387R3
> >  [PR108827]
> >
> > Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
> >
> >         PR libstdc++/108827
> >
> > libstdc++-v3/ChangeLog:
> >
> >         * include/bits/ranges_cmp.h (__cpp_lib_ranges): Bump value
> >         for C++23.
> >         * include/std/ranges (range_adaptor_closure): Define for C++23.
> >         * include/std/version (__cpp_lib_ranges): Bump value for
> >         C++23.
> >         * testsuite/std/ranges/version_c++23.cc: Bump expected value
> >         of __cpp_lib_ranges.
> >         * testsuite/std/ranges/range_adaptor_closure.cc: New test.
> > ---
> >  libstdc++-v3/include/bits/ranges_cmp.h        |  4 ++
> >  libstdc++-v3/include/std/ranges               |  8 ++++
> >  libstdc++-v3/include/std/version              |  3 ++
> >  .../std/ranges/range_adaptor_closure.cc       | 46 +++++++++++++++++++
> >  .../testsuite/std/ranges/version_c++23.cc     |  2 +-
> >  5 files changed, 62 insertions(+), 1 deletion(-)
> >  create mode 100644
> > libstdc++-v3/testsuite/std/ranges/range_adaptor_closure.cc
> >
> > diff --git a/libstdc++-v3/include/bits/ranges_cmp.h
> > b/libstdc++-v3/include/bits/ranges_cmp.h
> > index 85c1a77ccf7..6710d829a37 100644
> > --- a/libstdc++-v3/include/bits/ranges_cmp.h
> > +++ b/libstdc++-v3/include/bits/ranges_cmp.h
> > @@ -57,7 +57,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >
> >  #ifdef __cpp_lib_concepts
> >  // Define this here, included by all the headers that need to define it.
> > +#if __cplusplus > 202002L
> > +#define __cpp_lib_ranges 202202L
> > +#else
> >  #define __cpp_lib_ranges 202110L
> > +#endif
> >
> >  namespace ranges
> >  {
> > diff --git a/libstdc++-v3/include/std/ranges
> > b/libstdc++-v3/include/std/ranges
> > index 1714f3fb16c..c4d4d85bf90 100644
> > --- a/libstdc++-v3/include/std/ranges
> > +++ b/libstdc++-v3/include/std/ranges
> > @@ -1122,6 +1122,14 @@ namespace views::__adaptor
> >      };
> >  } // namespace views::__adaptor
> >
> > +#if __cplusplus > 202002L
> > +  template<typename _Derived>
> > +    requires is_class_v<_Derived> && same_as<_Derived,
> > remove_cv_t<_Derived>>
> > +    class range_adaptor_closure
> > +    : public views::__adaptor::_RangeAdaptorClosure
> > +    { };
> > +#endif
> > +
> >    template<range _Range> requires is_object_v<_Range>
> >      class ref_view : public view_interface<ref_view<_Range>>
> >      {
> > diff --git a/libstdc++-v3/include/std/version
> > b/libstdc++-v3/include/std/version
> > index 027e5711ec5..02ead8f1443 100644
> > --- a/libstdc++-v3/include/std/version
> > +++ b/libstdc++-v3/include/std/version
> > @@ -265,8 +265,10 @@
> >  #define __cpp_lib_interpolate 201902L
> >  #if __cpp_lib_concepts
> >  # define __cpp_lib_move_iterator_concept 202207L
> > +#if __cplusplus <= 202002L // N.B. updated value in C++23
> >  # define __cpp_lib_ranges 202110L
> >  #endif
> > +#endif
> >  #define __cpp_lib_shift 201806L
> >
> >  #if _GLIBCXX_HOSTED
> > @@ -330,6 +332,7 @@
> >  #define __cpp_lib_reference_from_temporary 202202L
> >  #define __cpp_lib_to_underlying 202102L
> >  #define __cpp_lib_unreachable 202202L
> > +#define __cpp_lib_ranges 202202L
> >  #define __cpp_lib_ranges_zip 202110L
> >  #define __cpp_lib_ranges_chunk 202202L
> >  #define __cpp_lib_ranges_slide 202202L
> > diff --git a/libstdc++-v3/testsuite/std/ranges/range_adaptor_closure.cc
> > b/libstdc++-v3/testsuite/std/ranges/range_adaptor_closure.cc
> > new file mode 100644
> > index 00000000000..6221f071331
> > --- /dev/null
> > +++ b/libstdc++-v3/testsuite/std/ranges/range_adaptor_closure.cc
> > @@ -0,0 +1,46 @@
> > +// { dg-options "-std=gnu++23" }
> > +// { dg-do run { target c++23 } }
> > +
> > +#include <ranges>
> > +#include <algorithm>
> > +#include <testsuite_hooks.h>
> > +
> > +namespace ranges = std::ranges;
> > +namespace views = std::views;
> > +
> > +struct _Negate : ranges::range_adaptor_closure<_Negate>
> > +{
> > +  template<ranges::viewable_range _Range>
> > +  constexpr auto
> > +  operator()(_Range&& __r) const
> > +  requires requires { views::transform(std::declval<_Range>(),
> > std::negate{}); }
> > +  { return views::transform(std::forward<_Range>(__r), std::negate{}); }
> > +};
> > +
> > +constexpr _Negate negate;
> > +
> > +constexpr bool
> > +test01()
> > +{
> > +  int x[] = {1, 2, 3};
> > +  VERIFY( ranges::equal(x | negate, (int[]){-1, -2, -3}) );
> > +  VERIFY( ranges::equal(x | negate | negate, x) );
> > +  VERIFY( ranges::equal(x | (negate | negate), x) );
> > +  VERIFY( ranges::equal(x | views::reverse | negate, x | negate |
> > views::reverse) );
> > +  VERIFY( ranges::equal(x | (views::reverse | negate), x | (negate |
> > views::reverse)) );
> > +#if 0
> > +  // These asserts currently fail for the same reason as the disabled
> > asserts
> > +  // in std/ranges/adaptors/all.cc.
> > +  static_assert( sizeof(negate | views::reverse | views::join) == 1 );
> > +  static_assert( sizeof(views::reverse | negate | views::join) == 1 );
> > +  static_assert( sizeof(views::reverse | views::join | negate) == 1 );
> > +#endif
> > +
> > +  return true;
> > +}
> > +
> > +int
> > +main()
> > +{
> > +  static_assert(test01());
> > +}
> > diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> > b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> > index 04609bb602c..e8342fa986a 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> > @@ -4,7 +4,7 @@
> >  #include <version>
> >
> >  #if __STDC_HOSTED__
> > -# if __cpp_lib_ranges != 202110L
> > +# if __cpp_lib_ranges != 202202L
> >  #  error "Feature-test macro __cpp_lib_ranges has wrong value in
> > <version>"
> >  # endif
> >  #endif
> > --
> > 2.40.0.335.g9857273be0
> >
> >
>


  reply	other threads:[~2023-04-18  8:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 19:45 [PATCH 1/2] libstdc++: Convert _RangeAdaptorClosure into a CRTP class [PR108827] Patrick Palka
2023-04-14 19:45 ` [PATCH 2/2] libstdc++: Implement range_adaptor_closure from P2387R3 [PR108827] Patrick Palka
2023-04-17  3:27   ` Patrick Palka
2023-04-17  7:26     ` Jonathan Wakely
2023-04-18  8:57       ` Jonathan Wakely [this message]
2023-04-18  8:59         ` Jakub Jelinek
2023-04-17  3:24 ` [PATCH 1/2] libstdc++: Convert _RangeAdaptorClosure into a CRTP class [PR108827] Patrick Palka
2023-08-16 16:05   ` Patrick Palka
2023-08-16 17:32     ` Jonathan Wakely

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='CACb0b4kAjORe9anH=gkp1pWvoKxyofizUCHAoR2rZHbiixPwug@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jwakely.gcc@gmail.com \
    --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).