public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: LWG 3301 transform_view::iterator has incorrect iterator_category
  2020-02-24 23:27 [PATCH] libstdc++: LWG 3292 iota_view is under-constrained Patrick Palka
@ 2020-02-24 23:26 ` Patrick Palka
  2020-02-24 23:39   ` Patrick Palka
  2020-02-24 23:27 ` [PATCH] libstdc++: LWG 3397 basic_istream_view::iterator should not provide iterator_category Patrick Palka
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Patrick Palka @ 2020-02-24 23:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, jwakely, Patrick Palka

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>>;
+	    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
+    {
+      auto f = [] (int x) { return x; };
+      int x[] = {1,2,3,4,5};
+      auto v = x | views::transform(f);
+      auto i = v.begin();
+      using Cat = decltype(i)::iterator_category;
+      static_assert(std::same_as<Cat, std::input_iterator_tag>);
+    }
+
+    {
+      auto f = [] (int &x) -> int& { return x; };
+      int x[] = {1,2,3,4,5};
+      auto v = x | views::transform(f);
+      auto i = v.begin();
+      using Cat = decltype(i)::iterator_category;
+      static_assert(std::derived_from<Cat, std::forward_iterator_tag>);
+    }
+}
+
 int
 main()
 {
   test01();
   test02();
   test03();
+  test04();
 }
-- 
2.25.1.291.ge68e29171c

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] libstdc++: LWG 3292 iota_view is under-constrained
@ 2020-02-24 23:27 Patrick Palka
  2020-02-24 23:26 ` [PATCH] libstdc++: LWG 3301 transform_view::iterator has incorrect iterator_category Patrick Palka
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Patrick Palka @ 2020-02-24 23:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, jwakely, Patrick Palka

libstdc++-v3/ChangeLog:

	LWG 3292 iota_view is under-constrained
	* include/std/ranges (iota_view): Require that _Winc models semiregular
	  as per LWG 3292.
	* testsuite/std/ranges/iota/lwg3292_neg.cc: New test.
---
 libstdc++-v3/include/std/ranges               |  1 +
 .../testsuite/std/ranges/iota/lwg3292_neg.cc  | 40 +++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 libstdc++-v3/testsuite/std/ranges/iota/lwg3292_neg.cc

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 0b2057c9661..ab8fbaca38f 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -615,6 +615,7 @@ namespace ranges
   template<weakly_incrementable _Winc,
 	   semiregular _Bound = unreachable_sentinel_t>
     requires std::__detail::__weakly_eq_cmp_with<_Winc, _Bound>
+      && semiregular<_Winc>
     class iota_view : public view_interface<iota_view<_Winc, _Bound>>
     {
     private:
diff --git a/libstdc++-v3/testsuite/std/ranges/iota/lwg3292_neg.cc b/libstdc++-v3/testsuite/std/ranges/iota/lwg3292_neg.cc
new file mode 100644
index 00000000000..80c392729b3
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/ranges/iota/lwg3292_neg.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <sstream>
+#include <ranges>
+
+namespace ranges = std::ranges;
+namespace views = std::views;
+
+void
+test01()
+{
+  std::istringstream s("1 2 3 4 5");
+  auto v = ranges::istream_view<int>(s);
+  auto i = v.begin();
+  static_assert(!std::semiregular<decltype(i)>);
+  auto o = views::iota(std::move(i));
+  static_assert(false); // { dg-error "" }
+}
+
+// { dg-prune-output "no match" }
+// { dg-prune-output "deduction failed" }
+// { dg-prune-output "constraint failure" }
-- 
2.25.1.291.ge68e29171c

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] libstdc++: LWG 3325 Constrain return type of transformation function for transform_view
  2020-02-24 23:27 [PATCH] libstdc++: LWG 3292 iota_view is under-constrained Patrick Palka
                   ` (2 preceding siblings ...)
  2020-02-24 23:27 ` [PATCH] libstdc++: LWG 3313 join_view::iterator::operator-- is incorrectly constrained Patrick Palka
@ 2020-02-24 23:27 ` 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
  4 siblings, 1 reply; 12+ messages in thread
From: Patrick Palka @ 2020-02-24 23:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, jwakely, Patrick Palka

libstdc++-v3/ChangeLog:

	LWG 3325 Constrain return type of transformation function for
	transform_view
	* include/std/ranges (transform_view): Constrain the return type of the
	transformation function as per LWG 3325.
	* testsuite/std/ranges/adaptors/lwg3325_neg.cc: New test.
---
 libstdc++-v3/include/std/ranges               |  2 ++
 .../std/ranges/adaptors/lwg3325_neg.cc        | 35 +++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 libstdc++-v3/testsuite/std/ranges/adaptors/lwg3325_neg.cc

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index ffdd3367b05..442d1d08098 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -1540,6 +1540,8 @@ namespace views
   template<input_range _Vp, copy_constructible _Fp>
     requires view<_Vp> && is_object_v<_Fp>
       && regular_invocable<_Fp&, range_reference_t<_Vp>>
+      && std::__detail::__can_reference<invoke_result_t<_Fp&,
+							range_reference_t<_Vp>>>
     class transform_view : public view_interface<transform_view<_Vp, _Fp>>
     {
     private:
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3325_neg.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3325_neg.cc
new file mode 100644
index 00000000000..ac174714574
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3325_neg.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <ranges>
+
+namespace ranges = std::ranges;
+namespace views = std::views;
+
+void
+test01()
+{
+  auto f = [] (int x) { };
+  int x[] = {1};
+  auto v = ranges::transform_view{x, f}; // { dg-error "deduction failed|no match" }
+}
+
+// { dg-prune-output "constraint failure" }
+// { dg-prune-output "in requirements" }
-- 
2.25.1.291.ge68e29171c

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] libstdc++: LWG 3313 join_view::iterator::operator-- is incorrectly constrained
  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:27 ` [PATCH] libstdc++: LWG 3397 basic_istream_view::iterator should not provide iterator_category Patrick Palka
@ 2020-02-24 23:27 ` 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:20 ` [PATCH] libstdc++: LWG 3292 iota_view is under-constrained Jonathan Wakely
  4 siblings, 1 reply; 12+ messages in thread
From: Patrick Palka @ 2020-02-24 23:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, jwakely, Patrick Palka

libstdc++-v3/ChangeLog:

	LWG 3313 join_view::_Iterator::operator-- is incorrectly constrained
	* include/std/ranges (join_view::_Iterator::operator--): Require that
	range_reference_t<_Base> models common_range.
	* testsuite/std/ranges/adaptors/lwg3313_neg.cc: New test.
---
 libstdc++-v3/include/std/ranges               |  2 +
 .../std/ranges/adaptors/lwg3313_neg.cc        | 40 +++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 libstdc++-v3/testsuite/std/ranges/adaptors/lwg3313_neg.cc

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index aed90e9710e..ffdd3367b05 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -2399,6 +2399,7 @@ namespace views
 	  operator--()
 	    requires _S_ref_is_glvalue && bidirectional_range<_Base>
 	      && bidirectional_range<range_reference_t<_Base>>
+	      && common_range<range_reference_t<_Base>>
 	  {
 	    if (_M_outer == ranges::end(_M_parent->_M_base))
 	      _M_inner = ranges::end(*--_M_outer);
@@ -2412,6 +2413,7 @@ namespace views
 	  operator--(int)
 	    requires _S_ref_is_glvalue && bidirectional_range<_Base>
 	      && bidirectional_range<range_reference_t<_Base>>
+	      && common_range<range_reference_t<_Base>>
 	  {
 	    auto __tmp = *this;
 	    --*this;
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3313_neg.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3313_neg.cc
new file mode 100644
index 00000000000..054df92554b
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3313_neg.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <array>
+#include <iterator>
+#include <ranges>
+
+namespace ranges = std::ranges;
+namespace views = std::views;
+
+void
+test01()
+{
+  int x[] = {1};
+  auto rx = ranges::subrange{std::counted_iterator(x,1), std::default_sentinel};
+  std::array<decltype(rx), 5> y = {rx, rx, rx, rx, rx,};
+  auto v = y | views::join;
+  auto i = v.begin();
+  ++i;
+  ++i;
+  --i; // { dg-error "no match" }
+  i--; // { dg-error "" }
+}
-- 
2.25.1.291.ge68e29171c

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] libstdc++: LWG 3397 basic_istream_view::iterator should not provide iterator_category
  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:27 ` 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
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Patrick Palka @ 2020-02-24 23:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, jwakely, Patrick Palka

libstdc++-v3/ChangeLog:

	LWG 3397 basic_istream_view::iterator should not provide
	iterator_category
	* include/std/ranges (basic_istream_view:_Iterator::iterator_category):
	Rename to ...
	(basic_istream_view:_Iterator::iterator_concept): ... this.
	* testsuite/std/ranges/istream_view.cc: Augment test.
---
 libstdc++-v3/include/std/ranges                  |  2 +-
 .../testsuite/std/ranges/istream_view.cc         | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 442d1d08098..a7f4da957ef 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -971,7 +971,7 @@ namespace views
       struct _Iterator
       {
       public:
-	using iterator_category = input_iterator_tag;
+	using iterator_concept = input_iterator_tag;
 	using difference_type = ptrdiff_t;
 	using value_type = _Val;
 
diff --git a/libstdc++-v3/testsuite/std/ranges/istream_view.cc b/libstdc++-v3/testsuite/std/ranges/istream_view.cc
index 1729459bce3..f74e05e347a 100644
--- a/libstdc++-v3/testsuite/std/ranges/istream_view.cc
+++ b/libstdc++-v3/testsuite/std/ranges/istream_view.cc
@@ -68,10 +68,26 @@ test03()
   VERIFY( ranges::equal(v, (int[]){0,1,2,3,4}) );
 }
 
+template<typename T>
+concept has_iterator_category = requires { typename T::iterator_category; };
+
+void
+test04()
+{
+  std::istringstream s("12345");
+  auto v = ranges::istream_view<char>(s);
+  // LWG 3397
+  using It = ranges::iterator_t<decltype(v)>;
+  static_assert(!has_iterator_category<It>);
+  static_assert(std::input_iterator<It>);
+  static_assert(!std::forward_iterator<It>);
+}
+
 int
 main()
 {
   test01();
   test02();
   test03();
+  test04();
 }
-- 
2.25.1.291.ge68e29171c

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] libstdc++: LWG 3301 transform_view::iterator has incorrect iterator_category
  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
  2020-02-25 17:24     ` Jonathan Wakely
  0 siblings, 1 reply; 12+ messages in thread
From: Patrick Palka @ 2020-02-24 23:39 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++, jwakely

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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] libstdc++: LWG 3292 iota_view is under-constrained
  2020-02-24 23:27 [PATCH] libstdc++: LWG 3292 iota_view is under-constrained Patrick Palka
                   ` (3 preceding siblings ...)
  2020-02-24 23:27 ` [PATCH] libstdc++: LWG 3325 Constrain return type of transformation function for transform_view Patrick Palka
@ 2020-02-25 17:20 ` Jonathan Wakely
  4 siblings, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2020-02-25 17:20 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On 24/02/20 18:26 -0500, Patrick Palka wrote:
>libstdc++-v3/ChangeLog:
>
>	LWG 3292 iota_view is under-constrained
>	* include/std/ranges (iota_view): Require that _Winc models semiregular
>	  as per LWG 3292.
>	* testsuite/std/ranges/iota/lwg3292_neg.cc: New test.

OK.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] libstdc++: LWG 3397 basic_istream_view::iterator should not provide iterator_category
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2020-02-25 17:21 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On 24/02/20 18:26 -0500, Patrick Palka wrote:
>libstdc++-v3/ChangeLog:
>
>	LWG 3397 basic_istream_view::iterator should not provide
>	iterator_category
>	* include/std/ranges (basic_istream_view:_Iterator::iterator_category):
>	Rename to ...
>	(basic_istream_view:_Iterator::iterator_concept): ... this.
>	* testsuite/std/ranges/istream_view.cc: Augment test.

OK.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] libstdc++: LWG 3313 join_view::iterator::operator-- is incorrectly constrained
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2020-02-25 17:21 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On 24/02/20 18:26 -0500, Patrick Palka wrote:
>libstdc++-v3/ChangeLog:
>
>	LWG 3313 join_view::_Iterator::operator-- is incorrectly constrained
>	* include/std/ranges (join_view::_Iterator::operator--): Require that
>	range_reference_t<_Base> models common_range.
>	* testsuite/std/ranges/adaptors/lwg3313_neg.cc: New test.

OK.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] libstdc++: LWG 3325 Constrain return type of transformation function for transform_view
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2020-02-25 17:22 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On 24/02/20 18:26 -0500, Patrick Palka wrote:
>libstdc++-v3/ChangeLog:
>
>	LWG 3325 Constrain return type of transformation function for
>	transform_view
>	* include/std/ranges (transform_view): Constrain the return type of the
>	transformation function as per LWG 3325.
>	* testsuite/std/ranges/adaptors/lwg3325_neg.cc: New test.

OK.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] libstdc++: LWG 3301 transform_view::iterator has incorrect iterator_category
  2020-02-24 23:39   ` Patrick Palka
@ 2020-02-25 17:24     ` Jonathan Wakely
  2020-02-25 18:16       ` Patrick Palka
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Wakely @ 2020-02-25 17:24 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On 24/02/20 18:39 -0500, Patrick Palka wrote:
>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.

OK, thanks.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] libstdc++: LWG 3301 transform_view::iterator has incorrect iterator_category
  2020-02-25 17:24     ` Jonathan Wakely
@ 2020-02-25 18:16       ` Patrick Palka
  0 siblings, 0 replies; 12+ messages in thread
From: Patrick Palka @ 2020-02-25 18:16 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Patrick Palka, gcc-patches, libstdc++

On Tue, 25 Feb 2020, Jonathan Wakely wrote:

> On 24/02/20 18:39 -0500, Patrick Palka wrote:
> > 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.
> 
> OK, thanks.

Thanks for the review, I just committed all five patches.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-02-25 18:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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