public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, jwakely@redhat.com
Subject: Re: [PATCH] libstdc++: LWG 3301 transform_view::iterator has incorrect iterator_category
Date: Mon, 24 Feb 2020 23:39:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.22.395.2002241836090.1709@idea> (raw)
In-Reply-To: <20200224232643.851356-2-ppalka@redhat.com>

On Mon, 24 Feb 2020, Patrick Palka wrote:

> libstdc++-v3/ChangeLog:
> 
> 	LWG 3301 transform_view::_Iterator has incorrect iterator_category
> 	* include/std/ranges (transform_view::_Iterator::_S_iter_cat): Adjust
> 	determination of iterator_category as per LWG 3301.
> 	* testsuite/std/ranges/adaptors/transform.cc: Augment test.
> ---
>  libstdc++-v3/include/std/ranges               | 16 +++++++++----
>  .../std/ranges/adaptors/transform.cc          | 24 +++++++++++++++++++
>  2 files changed, 35 insertions(+), 5 deletions(-)
> 
> diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
> index ab8fbaca38f..aed90e9710e 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -1570,12 +1570,18 @@ namespace views
>  	  static constexpr auto
>  	  _S_iter_cat()
>  	  {
> -	    using _Cat
> -              = typename iterator_traits<_Base_iter>::iterator_category;
> -	    if constexpr (derived_from<_Cat, contiguous_iterator_tag>)
> -	      return random_access_iterator_tag{};
> +	    using _Res = invoke_result_t<_Fp&, range_reference_t<_Base>>;

Consider this line fixed to use 'typename'.

> +	    if constexpr (is_lvalue_reference_v<_Res>)
> +	      {
> +		using _Cat
> +		  = typename iterator_traits<_Base_iter>::iterator_category;
> +		if constexpr (derived_from<_Cat, contiguous_iterator_tag>)
> +		  return random_access_iterator_tag{};
> +		else
> +		  return _Cat{};
> +	      }
>  	    else
> -	      return _Cat{};
> +	      return input_iterator_tag{};
>  	  }
>  
>  	  static constexpr decltype(auto)
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc
> index ad51fffb43d..0845febe2cf 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc
> @@ -77,10 +77,34 @@ test03()
>    VERIFY( ranges::equal(v, (int[]){1,2,3,4,5}) );
>  }
>  
> +void
> +test04()
> +{
> +  // LWG 3302

Consider this comment fixed to say 3301.

  reply	other threads:[~2020-02-24 23:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-24 23:27 [PATCH] libstdc++: LWG 3292 iota_view is under-constrained Patrick Palka
2020-02-24 23:26 ` [PATCH] libstdc++: LWG 3301 transform_view::iterator has incorrect iterator_category Patrick Palka
2020-02-24 23:39   ` Patrick Palka [this message]
2020-02-25 17:24     ` Jonathan Wakely
2020-02-25 18:16       ` Patrick Palka
2020-02-24 23:27 ` [PATCH] libstdc++: LWG 3397 basic_istream_view::iterator should not provide iterator_category Patrick Palka
2020-02-25 17:21   ` Jonathan Wakely
2020-02-24 23:27 ` [PATCH] libstdc++: LWG 3313 join_view::iterator::operator-- is incorrectly constrained Patrick Palka
2020-02-25 17:21   ` Jonathan Wakely
2020-02-24 23:27 ` [PATCH] libstdc++: LWG 3325 Constrain return type of transformation function for transform_view Patrick Palka
2020-02-25 17:22   ` Jonathan Wakely
2020-02-25 17:20 ` [PATCH] libstdc++: LWG 3292 iota_view is under-constrained 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=alpine.DEB.2.22.395.2002241836090.1709@idea \
    --to=ppalka@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /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).