blob: cf50090d860b890a1df8ee3418bd8239d0a163b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_istream<charT,traits>&
// operator>>(basic_istream<charT,traits>& is,
// basic_string<charT,traits,Allocator>& str);
#include <string>
#include <sstream>
#include <cassert>
int main()
{
{
std::istringstream in("a bc defghij");
std::string s("initial text");
in >> s;
assert(in.good());
assert(s == "a");
assert(in.peek() == ' ');
in >> s;
assert(in.good());
assert(s == "bc");
assert(in.peek() == ' ');
in.width(3);
in >> s;
assert(in.good());
assert(s == "def");
assert(in.peek() == 'g');
in >> s;
assert(in.eof());
assert(s == "ghij");
in >> s;
assert(in.fail());
}
{
std::wistringstream in(L"a bc defghij");
std::wstring s(L"initial text");
in >> s;
assert(in.good());
assert(s == L"a");
assert(in.peek() == L' ');
in >> s;
assert(in.good());
assert(s == L"bc");
assert(in.peek() == L' ');
in.width(3);
in >> s;
assert(in.good());
assert(s == L"def");
assert(in.peek() == L'g');
in >> s;
assert(in.eof());
assert(s == L"ghij");
in >> s;
assert(in.fail());
}
}
|