File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed
test/std/input.output/iostream.format/input.streams/istream.unformatted Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ Implemented Papers
51
51
- P2441R2: ``views::join_with `` (`Github <https://github.com/llvm/llvm-project/issues/105185 >`__)
52
52
- P2711R1: Making multi-param constructors of ``views `` ``explicit `` (`Github <https://github.com/llvm/llvm-project/issues/105252 >`__)
53
53
- P2770R0: Stashing stashing ``iterators `` for proper flattening (`Github <https://github.com/llvm/llvm-project/issues/105250 >`__)
54
+ - P3223R2: Making ``std::istream::ignore `` less surprising
54
55
55
56
Improvements and New Features
56
57
-----------------------------
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ public:
70
70
basic_istream& getline(char_type* s, streamsize n, char_type delim);
71
71
72
72
basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof());
73
+ basic_istream& ignore(streamsize n, char_type delim); // Since C++26
73
74
int_type peek();
74
75
basic_istream& read (char_type* s, streamsize n);
75
76
streamsize readsome(char_type* s, streamsize n);
@@ -291,6 +292,13 @@ public:
291
292
basic_istream& getline (char_type* __s, streamsize __n, char_type __dlm);
292
293
293
294
basic_istream& ignore (streamsize __n = 1 , int_type __dlm = traits_type::eof());
295
+ # if __LIBCPP_STD_VER >= 26
296
+ basic_istream& ignore (streamsize __n, char_type __delim)
297
+ requires is_same_v<char_type, char>
298
+ {
299
+ return ignore (__n, traits::to_int_type (__delim));
300
+ }
301
+ # endif
294
302
int_type peek ();
295
303
basic_istream& read (char_type* __s, streamsize __n);
296
304
streamsize readsome (char_type* __s, streamsize __n);
Original file line number Diff line number Diff line change
1
+ // ===----------------------------------------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+
9
+ // REQUIRES: std-at-least-c++26
10
+
11
+ // Requires 396145d in the built library.
12
+ // XFAIL: using-built-library-before-llvm-9
13
+
14
+ // <istream>
15
+
16
+ // basic_istream& ignore(streamsize n, char_type delim);
17
+
18
+ #include < cassert>
19
+ #include < istream>
20
+ #include < sstream>
21
+ #include < string>
22
+
23
+ #include " test_macros.h"
24
+
25
+ int main (int , char **) {
26
+ std::istringstream in (" \xF0\x9F\xA4\xA1 Clown Face" );
27
+ in.ignore (100 , ' \xA1 ' ); // ignore up to '\xA1' delimiter,
28
+ // previously might have ignored to EOF
29
+
30
+ assert (in.gcount () == 4 ); // 4 bytes were ignored
31
+ assert (in.peek () == ' ' ); // next character is a space
32
+
33
+ std::string s1; // read the next word
34
+ in >> s1;
35
+ assert (s1 == " Clown" );
36
+
37
+ in.ignore (100 , -1L ); // ambiguous overload,
38
+ // previously equivalent to (int)-1L
39
+
40
+ return 0 ;
41
+ }
You can’t perform that action at this time.
0 commit comments