Skip to content

Commit 40652b3

Browse files
committed
Some fixes
1 parent 519cf01 commit 40652b3

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
@@ -172,6 +172,7 @@ template <class Stream, class T>
172172
# include <__type_traits/conjunction.h>
173173
# include <__type_traits/enable_if.h>
174174
# include <__type_traits/is_base_of.h>
175+
# include <__type_traits/is_same.h>
175176
# include <__type_traits/make_unsigned.h>
176177
# include <__utility/declval.h>
177178
# include <__utility/forward.h>
@@ -292,11 +293,13 @@ public:
292293
basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
293294

294295
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)
296+
# if _LIBCPP_STD_VER >= 26
297+
// _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
298+
// requires is_same_v<char_type, char>;
299+
_LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim)
297300
requires is_same_v<char_type, char>
298301
{
299-
return ignore(__n, traits::to_int_type(__delim));
302+
return this->ignore(__n, _Traits::to_int_type(__delim));
300303
}
301304
# endif
302305
int_type peek();
@@ -873,6 +876,14 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
873876
return *this;
874877
}
875878

879+
// # if _LIBCPP_STD_VER >= 26
880+
// template <class _CharT, class _Traits>
881+
// basic_istream& basic_istream<_CharT, _Traits>&
882+
// basic_istream<_CharT, _Traits>::ignore(streamsize __n, char_type __delim) {
883+
// return this->ignore(__n, _Traits::to_int_type(__delim));
884+
// }
885+
// # endif
886+
876887
template <class _CharT, class _Traits>
877888
typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>::peek() {
878889
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)