diff mbox series

libstdc++: LWG 3397 basic_istream_view::iterator should not provide iterator_category

Message ID 20200224232643.851356-5-ppalka@redhat.com
State New
Headers show
Series libstdc++: LWG 3397 basic_istream_view::iterator should not provide iterator_category | expand

Commit Message

Patrick Palka Feb. 24, 2020, 11:26 p.m. UTC
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(-)

Comments

Jonathan Wakely Feb. 25, 2020, 5:21 p.m. UTC | #1
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.
diff mbox series

Patch

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();
 }