Skip to content

Commit 7c6aac2

Browse files
committed
Some fixes
1 parent aa7ce10 commit 7c6aac2

File tree

3 files changed

+47
-12
lines changed

3 files changed

+47
-12
lines changed

libcxx/include/istream

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ template <class Stream, class T>
173173
# include <__type_traits/conjunction.h>
174174
# include <__type_traits/enable_if.h>
175175
# include <__type_traits/is_base_of.h>
176+
# include <__type_traits/is_same.h>
176177
# include <__type_traits/make_unsigned.h>
177178
# include <__utility/declval.h>
178179
# include <__utility/forward.h>
@@ -293,11 +294,13 @@ public:
293294
basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
294295

295296
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
296-
# if __LIBCPP_STD_VER >= 26
297-
basic_istream& ignore(streamsize __n, char_type __delim)
297+
# if _LIBCPP_STD_VER >= 26
298+
// _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
299+
// requires is_same_v<char_type, char>;
300+
_LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
298301
requires is_same_v<char_type, char>
299302
{
300-
return ignore(__n, traits::to_int_type(__delim));
303+
return this->ignore(__n, _Traits::to_int_type(__delim));
301304
}
302305
# endif
303306
int_type peek();
@@ -874,6 +877,14 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
874877
return *this;
875878
}
876879

880+
// # if _LIBCPP_STD_VER >= 26
881+
// template <class _CharT, class _Traits>
882+
// basic_istream& basic_istream<_CharT, _Traits>&
883+
// basic_istream<_CharT, _Traits>::ignore(streamsize __n, char_type __delim) {
884+
// return this->ignore(__n, _Traits::to_int_type(__delim));
885+
// }
886+
// # endif
887+
877888
template <class _CharT, class _Traits>
878889
typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>::peek() {
879890
ios_base::iostate __state = ios_base::goodbit;

libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.char_type.pass.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@
2525
int main(int, char**) {
2626
std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
2727
in.ignore(100, '\xA1'); // ignore up to '\xA1' delimiter,
28-
// previously might have ignored to EOF
28+
// previously might have ignored to EOF
2929

30-
assert(in.gcount() == 4); // 4 bytes were ignored
31-
assert(in.peek() == ' '); // next character is a space
30+
assert(in.gcount() == 4); // 4 bytes were ignored
31+
assert(in.peek() == ' '); // next character is a space
3232

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
33+
std::string str; // read the next word
34+
in >> str;
35+
assert(str == "Clown");
3936

4037
return 0;
4138
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 <sstream>
20+
#include <string>
21+
22+
#include "test_macros.h"
23+
24+
void test() {
25+
std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
26+
in.ignore(100, -1L); // expected-error {{call to member function 'ignore' is ambiguous}}
27+
}

0 commit comments

Comments
 (0)