Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[libc++][istream] P3223R2: Makingstd::istream::ignore less surprising#147007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@H-G-Hristov
Copy link
Contributor

@H-G-HristovH-G-Hristov commentedJul 4, 2025
edited
Loading

@ZingamZingam added libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. c++26 labelsJul 4, 2025
@llvmbot
Copy link
Member

@llvm/pr-subscribers-libcxx

Author: Hristo Hristov (H-G-Hristov)

Changes

ImplementsP3223R2

References


Full diff:https://github.com/llvm/llvm-project/pull/147007.diff

4 Files Affected:

  • (modified) libcxx/docs/ReleaseNotes/21.rst (+1)
  • (modified) libcxx/include/istream (+9)
  • (added) libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp (+37)
  • (added) libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.verify.cpp (+27)
diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rstindex 08b32bb508dc1..34735ca515d53 100644--- a/libcxx/docs/ReleaseNotes/21.rst+++ b/libcxx/docs/ReleaseNotes/21.rst@@ -51,6 +51,7 @@ Implemented Papers - P2441R2: ``views::join_with`` (`Github <https://github.com/llvm/llvm-project/issues/105185>`__) - 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>`__)+- P3223R2: Making ``std::istream::ignore`` less surprising  Improvements and New Features -----------------------------diff --git a/libcxx/include/istream b/libcxx/include/istreamindex 02546902494e3..83ba1799cae91 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);@@ -171,6 +172,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>@@ -291,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+  _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));+  }+#    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.cppnew file mode 100644index 0000000000000..9d83a7ea15027--- /dev/null+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp@@ -0,0 +1,37 @@+//===----------------------------------------------------------------------===//+//+// 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"++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 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.cppnew file mode 100644index 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}}+}

@github-actions
Copy link

github-actionsbot commentedJul 14, 2025
edited
Loading

✅ With the latest revision this PR passed the C/C++ code formatter.

@ZingamZingam changed the titleWIP [libc++][istream] P3223R2: Makingstd::istream::ignore less surprising[libc++][istream] P3223R2: Makingstd::istream::ignore less surprisingJul 15, 2025
@ZingamZingam marked this pull request as ready for reviewJuly 15, 2025 09:18
@ZingamZingam requested a review froma team as acode ownerJuly 15, 2025 09:18
@H-G-HristovH-G-Hristovforce-pushed thehgh/libcxx/P3223R2-Making-std_istream_ignore-less-surprising branch fromc72f223 tocf357b0CompareJuly 22, 2025 17:09
Copy link
Member

@ldionneldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM assuming@frederick-vs-ja is happy

Copy link
Member

@ldionneldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sorry, I missed something subtle during my first review

H-G-Hristovand others added4 commitsAugust 1, 2025 22:53
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
Copy link
Contributor

@philnik777philnik777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why is this implemented as a DR?

@frederick-vs-ja
Copy link
Contributor

Why is this implemented as a DR?

The reason is available incplusplus/papers#1871 (comment).

Zingam reacted with heart emoji

@frederick-vs-ja
Copy link
Contributor

Looks like review comments are resolved. LGTM with conflicts inCxx2cPapers.csv resolved.

Zingam reacted with heart emoji

@Zingam
Copy link
Contributor

@ldionne gentle ping

@frederick-vs-ja
Copy link
Contributor

@ldionne Ping. I think we can land this.

@ldionneldionne merged commitccd06e4 intollvm:mainSep 30, 2025
76 of 79 checks passed
@H-G-HristovH-G-Hristov deleted the hgh/libcxx/P3223R2-Making-std_istream_ignore-less-surprising branchOctober 1, 2025 05:30
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull requestOct 3, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ZingamZingamZingam left review comments

@philnik777philnik777philnik777 left review comments

@ldionneldionneldionne approved these changes

@frederick-vs-jafrederick-vs-jafrederick-vs-ja approved these changes

Assignees

No one assigned

Labels

c++26libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

P3223R2: Makingstd::istream::ignore less surprising

6 participants

@H-G-Hristov@llvmbot@frederick-vs-ja@Zingam@ldionne@philnik777

[8]ページ先頭

©2009-2025 Movatter.jp