[libcxx-commits] [libcxx] [libc++][istream] P3223R2: Making `std::istream::ignore` less surprising (PR #147007)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 22 11:32:51 PDT 2025
https://github.com/H-G-Hristov updated https://github.com/llvm/llvm-project/pull/147007
>From aa7ce10a8fe587d52d9ea5a47f96b3a9235f6205 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Fri, 4 Jul 2025 07:57:26 +0300
Subject: [PATCH 01/16] [libc++][istream] P3223R2 Making `std::istream::ignore`
less surprising
Implements [P3223R2](https://wg21.link/P3223R2)
- https://github.com/cplusplus/draft/pull/7996
---
libcxx/docs/ReleaseNotes/21.rst | 1 +
libcxx/include/istream | 8 ++++
.../ignore.char_type.pass.cpp | 41 +++++++++++++++++++
3 files changed, 50 insertions(+)
create mode 100644 libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst
index d31ca0130cb80..0a53855e13e56 100644
--- a/libcxx/docs/ReleaseNotes/21.rst
+++ b/libcxx/docs/ReleaseNotes/21.rst
@@ -53,6 +53,7 @@ Implemented Papers
- P2711R1: Making multi-param constructors of ``views`` ``explicit`` (`Github <https://github.com/llvm/llvm-project/issues/105252>`__)
- P2770R0: Stashing stashing ``iterators`` for proper flattening (`Github <https://github.com/llvm/llvm-project/issues/105250>`__)
- P2655R3: ``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type (`Github <https://github.com/llvm/llvm-project/issues/105260>`__)
+- P3223R2: Making ``std::istream::ignore`` less surprising
Improvements and New Features
-----------------------------
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 93def61a8b477..b0a9ea2beb7bf 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -70,6 +70,7 @@ public:
basic_istream& getline(char_type* s, streamsize n, char_type delim);
basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof());
+ basic_istream& ignore(streamsize n, char_type delim); // Since C++26
int_type peek();
basic_istream& read (char_type* s, streamsize n);
streamsize readsome(char_type* s, streamsize n);
@@ -292,6 +293,13 @@ public:
basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
+# if __LIBCPP_STD_VER >= 26
+ basic_istream& ignore(streamsize __n, char_type __delim)
+ requires is_same_v<char_type, char>
+ {
+ return ignore(__n, traits::to_int_type(__delim));
+ }
+# endif
int_type peek();
basic_istream& read(char_type* __s, streamsize __n);
streamsize readsome(char_type* __s, streamsize __n);
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
new file mode 100644
index 0000000000000..2074ecef0bd33
--- /dev/null
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++26
+
+// Requires 396145d in the built library.
+// XFAIL: using-built-library-before-llvm-9
+
+// <istream>
+
+// basic_istream& ignore(streamsize n, char_type delim);
+
+#include <cassert>
+#include <istream>
+#include <sstream>
+#include <string>
+
+#include "test_macros.h"
+
+int main(int, char**) {
+ std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
+ in.ignore(100, '\xA1'); // ignore up to '\xA1' delimiter,
+ // previously might have ignored to EOF
+
+ assert(in.gcount() == 4); // 4 bytes were ignored
+ assert(in.peek() == ' '); // next character is a space
+
+ std::string s1; // read the next word
+ in >> s1;
+ assert(s1 == "Clown");
+
+ in.ignore(100, -1L); // ambiguous overload,
+ // previously equivalent to (int)-1L
+
+ return 0;
+}
>From 7c6aac2ede6369d30282c033370d1a2553c7e7ef Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Fri, 4 Jul 2025 09:56:25 +0300
Subject: [PATCH 02/16] Some fixes
---
libcxx/include/istream | 17 +++++++++---
.../ignore.char_type.pass.cpp | 15 +++++------
.../istream.unformatted/ignore.verify.cpp | 27 +++++++++++++++++++
3 files changed, 47 insertions(+), 12 deletions(-)
create mode 100644 libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp
diff --git a/libcxx/include/istream b/libcxx/include/istream
index b0a9ea2beb7bf..6cd09570373ee 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -173,6 +173,7 @@ template <class Stream, class T>
# include <__type_traits/conjunction.h>
# include <__type_traits/enable_if.h>
# include <__type_traits/is_base_of.h>
+# include <__type_traits/is_same.h>
# include <__type_traits/make_unsigned.h>
# include <__utility/declval.h>
# include <__utility/forward.h>
@@ -293,11 +294,13 @@ public:
basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
-# if __LIBCPP_STD_VER >= 26
- basic_istream& ignore(streamsize __n, char_type __delim)
+# if _LIBCPP_STD_VER >= 26
+ // _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
+ // requires is_same_v<char_type, char>;
+ _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
requires is_same_v<char_type, char>
{
- return ignore(__n, traits::to_int_type(__delim));
+ return this->ignore(__n, _Traits::to_int_type(__delim));
}
# endif
int_type peek();
@@ -874,6 +877,14 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
return *this;
}
+// # if _LIBCPP_STD_VER >= 26
+// template <class _CharT, class _Traits>
+// basic_istream& basic_istream<_CharT, _Traits>&
+// basic_istream<_CharT, _Traits>::ignore(streamsize __n, char_type __delim) {
+// return this->ignore(__n, _Traits::to_int_type(__delim));
+// }
+// # endif
+
template <class _CharT, class _Traits>
typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>::peek() {
ios_base::iostate __state = ios_base::goodbit;
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
index 2074ecef0bd33..6f3fe59c0cbc5 100644
--- a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
@@ -25,17 +25,14 @@
int main(int, char**) {
std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
in.ignore(100, '\xA1'); // ignore up to '\xA1' delimiter,
- // previously might have ignored to EOF
+ // previously might have ignored to EOF
- assert(in.gcount() == 4); // 4 bytes were ignored
- assert(in.peek() == ' '); // next character is a space
+ assert(in.gcount() == 4); // 4 bytes were ignored
+ assert(in.peek() == ' '); // next character is a space
- std::string s1; // read the next word
- in >> s1;
- assert(s1 == "Clown");
-
- in.ignore(100, -1L); // ambiguous overload,
- // previously equivalent to (int)-1L
+ std::string str; // read the next word
+ in >> str;
+ assert(str == "Clown");
return 0;
}
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp
new file mode 100644
index 0000000000000..54d13cac69b94
--- /dev/null
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++26
+
+// Requires 396145d in the built library.
+// XFAIL: using-built-library-before-llvm-9
+
+// <istream>
+
+// basic_istream& ignore(streamsize n, char_type delim);
+
+#include <cassert>
+#include <sstream>
+#include <string>
+
+#include "test_macros.h"
+
+void test() {
+ std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
+ in.ignore(100, -1L); // expected-error {{call to member function 'ignore' is ambiguous}}
+}
>From b9b6b2d580d83508faedbb16aa05a6192fd7c09f Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Fri, 4 Jul 2025 09:57:14 +0300
Subject: [PATCH 03/16] Cleanup
---
libcxx/include/istream | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 6cd09570373ee..fb5d35c2644d1 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -295,8 +295,6 @@ public:
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
# if _LIBCPP_STD_VER >= 26
- // _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
- // requires is_same_v<char_type, char>;
_LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
requires is_same_v<char_type, char>
{
@@ -877,14 +875,6 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
return *this;
}
-// # if _LIBCPP_STD_VER >= 26
-// template <class _CharT, class _Traits>
-// basic_istream& basic_istream<_CharT, _Traits>&
-// basic_istream<_CharT, _Traits>::ignore(streamsize __n, char_type __delim) {
-// return this->ignore(__n, _Traits::to_int_type(__delim));
-// }
-// # endif
-
template <class _CharT, class _Traits>
typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>::peek() {
ios_base::iostate __state = ios_base::goodbit;
>From 64d894bf21f704e74f6c987fc856b1a0977401c2 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Fri, 4 Jul 2025 10:04:24 +0300
Subject: [PATCH 04/16] Cleanup
---
.../input.streams/istream.unformatted/ignore.char_type.pass.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
index 6f3fe59c0cbc5..9d83a7ea15027 100644
--- a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
@@ -16,7 +16,6 @@
// basic_istream& ignore(streamsize n, char_type delim);
#include <cassert>
-#include <istream>
#include <sstream>
#include <string>
>From 92860945a2d3b2c6fac46bc5de5852aa1c3f65ab Mon Sep 17 00:00:00 2001
From: Hristo Hristov <zingam at outlook.com>
Date: Sat, 5 Jul 2025 08:05:53 +0300
Subject: [PATCH 05/16] Update libcxx/include/istream
---
libcxx/include/istream | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/istream b/libcxx/include/istream
index fb5d35c2644d1..553c46043aa56 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -295,7 +295,7 @@ public:
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
# if _LIBCPP_STD_VER >= 26
- _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
+ basic_istream& ignore(streamsize __n, char_type __delim)
requires is_same_v<char_type, char>
{
return this->ignore(__n, _Traits::to_int_type(__delim));
>From 31fa1366e395db4cf5feaf5bd14f37e7d1da2601 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <zingam at outlook.com>
Date: Sat, 5 Jul 2025 17:01:18 +0300
Subject: [PATCH 06/16] Update libcxx/include/istream
---
libcxx/include/istream | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 553c46043aa56..2c7a05cdadd33 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -295,7 +295,7 @@ public:
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
# if _LIBCPP_STD_VER >= 26
- basic_istream& ignore(streamsize __n, char_type __delim)
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& ignore(streamsize __n, char_type __delim)
requires is_same_v<char_type, char>
{
return this->ignore(__n, _Traits::to_int_type(__delim));
>From 6aac62a0c6b41bd54be5564a1c8708c1b044e115 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 6 Jul 2025 09:09:14 +0300
Subject: [PATCH 07/16] Try one last time
---
libcxx/include/istream | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 2c7a05cdadd33..fb5d35c2644d1 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -295,7 +295,7 @@ public:
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
# if _LIBCPP_STD_VER >= 26
- inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& ignore(streamsize __n, char_type __delim)
+ _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
requires is_same_v<char_type, char>
{
return this->ignore(__n, _Traits::to_int_type(__delim));
>From 7de8061f016908a34db770f43f085409cad7c174 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 13 Jul 2025 08:49:38 +0300
Subject: [PATCH 08/16] Updated status
---
libcxx/docs/Status/Cxx2cPapers.csv | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv
index febb0c176f9c4..3a77ccfa0b0fa 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -150,7 +150,7 @@
"`P3008R6 <https://wg21.link/P3008R6>`__","Atomic floating-point min/max","2025-06 (Sofia)","","",""
"`P3111R8 <https://wg21.link/P3111R8>`__","Atomic Reduction Operations","2025-06 (Sofia)","","",""
"`P3060R3 <https://wg21.link/P3060R3>`__","Add ``std::views::indices(n)``","2025-06 (Sofia)","","",""
-"`P2319R5 <https://wg21.link/P2319R5>`__","Prevent ``path`` presentation problems","2025-06 (Sofia)","","",""
+"`P2319R5 <https://wg21.link/P2319R5>`__","Prevent ``path`` presentation problems","2025-06 (Sofia)","|Complete|","21",""
"`P3223R2 <https://wg21.link/P3223R2>`__","Making ``std::istream::ignore`` less surprising","2025-06 (Sofia)","","",""
"`P2781R9 <https://wg21.link/P2781R9>`__","``std::constant_wrapper``","2025-06 (Sofia)","","",""
"`P3697R1 <https://wg21.link/P3697R1>`__","Minor additions to C++26 standard library hardening","2025-06 (Sofia)","","",""
>From 92358bf7b01792d818e29bab3a4aa64a7cc61384 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <zingam at outlook.com>
Date: Mon, 14 Jul 2025 08:04:59 +0300
Subject: [PATCH 09/16] Update libcxx/docs/Status/Cxx2cPapers.csv
Co-authored-by: A. Jiang <de34 at live.cn>
---
libcxx/docs/Status/Cxx2cPapers.csv | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv
index 3a77ccfa0b0fa..fb3182708a302 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -150,8 +150,8 @@
"`P3008R6 <https://wg21.link/P3008R6>`__","Atomic floating-point min/max","2025-06 (Sofia)","","",""
"`P3111R8 <https://wg21.link/P3111R8>`__","Atomic Reduction Operations","2025-06 (Sofia)","","",""
"`P3060R3 <https://wg21.link/P3060R3>`__","Add ``std::views::indices(n)``","2025-06 (Sofia)","","",""
-"`P2319R5 <https://wg21.link/P2319R5>`__","Prevent ``path`` presentation problems","2025-06 (Sofia)","|Complete|","21",""
-"`P3223R2 <https://wg21.link/P3223R2>`__","Making ``std::istream::ignore`` less surprising","2025-06 (Sofia)","","",""
+"`P2319R5 <https://wg21.link/P2319R5>`__","Prevent ``path`` presentation problems","2025-06 (Sofia)","","",""
+"`P3223R2 <https://wg21.link/P3223R2>`__","Making ``std::istream::ignore`` less surprising","2025-06 (Sofia)","|Complete|","21",""
"`P2781R9 <https://wg21.link/P2781R9>`__","``std::constant_wrapper``","2025-06 (Sofia)","","",""
"`P3697R1 <https://wg21.link/P3697R1>`__","Minor additions to C++26 standard library hardening","2025-06 (Sofia)","","",""
"`P3552R3 <https://wg21.link/P3552R3>`__","Add a Coroutine Task Type","2025-06 (Sofia)","","",""
>From 9168f169eb7e5aa0537f37dca2ab63a5b2a10628 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Tue, 15 Jul 2025 01:13:02 +0300
Subject: [PATCH 10/16] As DR
---
libcxx/include/istream | 10 +++----
.../ignore.char_type.pass.cpp | 7 +++--
.../istream.unformatted/ignore.verify.cpp | 27 -------------------
3 files changed, 9 insertions(+), 35 deletions(-)
delete mode 100644 libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp
diff --git a/libcxx/include/istream b/libcxx/include/istream
index fb5d35c2644d1..99329fd587fd0 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -294,13 +294,11 @@ public:
basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
-# if _LIBCPP_STD_VER >= 26
- _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
- requires is_same_v<char_type, char>
- {
- return this->ignore(__n, _Traits::to_int_type(__delim));
+ template <class _Tp = char_type>
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 typename std::enable_if<is_same<_Tp, char>::value, basic_istream&>::type
+ ignore(streamsize __n, char_type __delim) {
+ return ignore(__n, traits_type::to_int_type(__delim));
}
-# endif
int_type peek();
basic_istream& read(char_type* __s, streamsize __n);
streamsize readsome(char_type* __s, streamsize __n);
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
index 9d83a7ea15027..d4f5403a07cec 100644
--- a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
@@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// REQUIRES: std-at-least-c++26
-
// Requires 396145d in the built library.
// XFAIL: using-built-library-before-llvm-9
@@ -33,5 +31,10 @@ int main(int, char**) {
in >> str;
assert(str == "Clown");
+ // Parameter value "-1L" doesn't cause ambiguity with the char_type overload.
+ in.ignore(100, -1L); // ignore up to EOF, which is the default behavior
+ assert(in.eof()); // stream should be at EOF now
+ // assert(in.gcount() == 5);
+
return 0;
}
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp
deleted file mode 100644
index 54d13cac69b94..0000000000000
--- a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// REQUIRES: std-at-least-c++26
-
-// Requires 396145d in the built library.
-// XFAIL: using-built-library-before-llvm-9
-
-// <istream>
-
-// basic_istream& ignore(streamsize n, char_type delim);
-
-#include <cassert>
-#include <sstream>
-#include <string>
-
-#include "test_macros.h"
-
-void test() {
- std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
- in.ignore(100, -1L); // expected-error {{call to member function 'ignore' is ambiguous}}
-}
>From ee72bb4f5fde25765b60cc0429b7e3523c356190 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <zingam at outlook.com>
Date: Tue, 15 Jul 2025 06:27:13 +0300
Subject: [PATCH 11/16] Update
libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
Co-authored-by: A. Jiang <de34 at live.cn>
---
.../input.streams/istream.unformatted/ignore.char_type.pass.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
index d4f5403a07cec..b7aaca8efb77e 100644
--- a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
@@ -8,6 +8,7 @@
// Requires 396145d in the built library.
// XFAIL: using-built-library-before-llvm-9
+// XFAIL: FROZEN-CXX03-HEADERS-FIXME
// <istream>
>From 4c807e162872b6ffb6d03f10c5e27c1252a9b2cc Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Tue, 15 Jul 2025 06:41:11 +0300
Subject: [PATCH 12/16] Fix formatting
---
.../istream.unformatted/ignore.char_type.pass.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
index b7aaca8efb77e..23b214606e44f 100644
--- a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp
@@ -34,8 +34,8 @@ int main(int, char**) {
// Parameter value "-1L" doesn't cause ambiguity with the char_type overload.
in.ignore(100, -1L); // ignore up to EOF, which is the default behavior
- assert(in.eof()); // stream should be at EOF now
- // assert(in.gcount() == 5);
+ assert(in.eof()); // stream should be at EOF now
+ assert(in.gcount() == 5);
return 0;
}
>From cb2254fc55272b34f88f7df9ff59c8ba4e33db9b Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Tue, 15 Jul 2025 23:57:16 +0300
Subject: [PATCH 13/16] Use more typical syntax
---
libcxx/include/istream | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 99329fd587fd0..c984ab69036da 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -294,9 +294,10 @@ public:
basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
- template <class _Tp = char_type>
- inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 typename std::enable_if<is_same<_Tp, char>::value, basic_istream&>::type
- ignore(streamsize __n, char_type __delim) {
+ // template <class _Tp = char_type,
+ // class = typename enable_if<is_same<_Tp, char_type>::value>::type>
+ template <class _Tp = char_type, __enable_if_t<is_same<_Tp, char_type>::value, int> = 0>
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& ignore(streamsize __n, char_type __delim) {
return ignore(__n, traits_type::to_int_type(__delim));
}
int_type peek();
>From cf357b04595b6b733ea88e44d08b2bf78dba86b3 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Tue, 15 Jul 2025 23:57:54 +0300
Subject: [PATCH 14/16] Cleanup
---
libcxx/include/istream | 2 --
1 file changed, 2 deletions(-)
diff --git a/libcxx/include/istream b/libcxx/include/istream
index c984ab69036da..92324f14913a4 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -294,8 +294,6 @@ public:
basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
- // template <class _Tp = char_type,
- // class = typename enable_if<is_same<_Tp, char_type>::value>::type>
template <class _Tp = char_type, __enable_if_t<is_same<_Tp, char_type>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& ignore(streamsize __n, char_type __delim) {
return ignore(__n, traits_type::to_int_type(__delim));
>From 186eaa77bbc6e6f1977ccaa0df23da8c262dbb6e Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Tue, 22 Jul 2025 20:13:53 +0300
Subject: [PATCH 15/16] LLVM22
---
libcxx/docs/ReleaseNotes/21.rst | 1 -
libcxx/docs/ReleaseNotes/22.rst | 1 +
libcxx/docs/Status/Cxx2cPapers.csv | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst
index 0a53855e13e56..d31ca0130cb80 100644
--- a/libcxx/docs/ReleaseNotes/21.rst
+++ b/libcxx/docs/ReleaseNotes/21.rst
@@ -53,7 +53,6 @@ Implemented Papers
- P2711R1: Making multi-param constructors of ``views`` ``explicit`` (`Github <https://github.com/llvm/llvm-project/issues/105252>`__)
- P2770R0: Stashing stashing ``iterators`` for proper flattening (`Github <https://github.com/llvm/llvm-project/issues/105250>`__)
- P2655R3: ``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type (`Github <https://github.com/llvm/llvm-project/issues/105260>`__)
-- P3223R2: Making ``std::istream::ignore`` less surprising
Improvements and New Features
-----------------------------
diff --git a/libcxx/docs/ReleaseNotes/22.rst b/libcxx/docs/ReleaseNotes/22.rst
index 15bf46d44b07f..30a2d6c65ff8d 100644
--- a/libcxx/docs/ReleaseNotes/22.rst
+++ b/libcxx/docs/ReleaseNotes/22.rst
@@ -39,6 +39,7 @@ Implemented Papers
------------------
- P2321R2: ``zip`` (`Github <https://github.com/llvm/llvm-project/issues/105169>`__) (The paper is partially implemented. ``zip_transform_view`` is implemented in this release)
+- P3223R2: Making ``std::istream::ignore`` less surprising
Improvements and New Features
-----------------------------
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv
index fb3182708a302..ae2c4aa863624 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -151,7 +151,7 @@
"`P3111R8 <https://wg21.link/P3111R8>`__","Atomic Reduction Operations","2025-06 (Sofia)","","",""
"`P3060R3 <https://wg21.link/P3060R3>`__","Add ``std::views::indices(n)``","2025-06 (Sofia)","","",""
"`P2319R5 <https://wg21.link/P2319R5>`__","Prevent ``path`` presentation problems","2025-06 (Sofia)","","",""
-"`P3223R2 <https://wg21.link/P3223R2>`__","Making ``std::istream::ignore`` less surprising","2025-06 (Sofia)","|Complete|","21",""
+"`P3223R2 <https://wg21.link/P3223R2>`__","Making ``std::istream::ignore`` less surprising","2025-06 (Sofia)","|Complete|","22",""
"`P2781R9 <https://wg21.link/P2781R9>`__","``std::constant_wrapper``","2025-06 (Sofia)","","",""
"`P3697R1 <https://wg21.link/P3697R1>`__","Minor additions to C++26 standard library hardening","2025-06 (Sofia)","","",""
"`P3552R3 <https://wg21.link/P3552R3>`__","Add a Coroutine Task Type","2025-06 (Sofia)","","",""
>From 60a4b5b979b7a89cbba633078b1152f84cb2b36e Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Tue, 22 Jul 2025 21:32:25 +0300
Subject: [PATCH 16/16] LLVM22
---
libcxx/docs/ReleaseNotes/22.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/docs/ReleaseNotes/22.rst b/libcxx/docs/ReleaseNotes/22.rst
index 30a2d6c65ff8d..01bb49536bae4 100644
--- a/libcxx/docs/ReleaseNotes/22.rst
+++ b/libcxx/docs/ReleaseNotes/22.rst
@@ -39,7 +39,7 @@ Implemented Papers
------------------
- P2321R2: ``zip`` (`Github <https://github.com/llvm/llvm-project/issues/105169>`__) (The paper is partially implemented. ``zip_transform_view`` is implemented in this release)
-- P3223R2: Making ``std::istream::ignore`` less surprising
+- P3223R2: Making ``std::istream::ignore`` less surprising (`Github <https://github.com/llvm/llvm-project/issues/148178>`__)
Improvements and New Features
-----------------------------
More information about the libcxx-commits
mailing list