• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <sstream>
11 
12 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
13 // class basic_istringstream
14 
15 // basic_istringstream& operator=(basic_istringstream&& rhs);
16 
17 #include <sstream>
18 #include <cassert>
19 
main()20 int main()
21 {
22 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
23     {
24         std::istringstream ss0(" 123 456");
25         std::istringstream ss;
26         ss = std::move(ss0);
27         assert(ss.rdbuf() != 0);
28         assert(ss.good());
29         assert(ss.str() == " 123 456");
30         int i = 0;
31         ss >> i;
32         assert(i == 123);
33         ss >> i;
34         assert(i == 456);
35     }
36     {
37         std::istringstream s1("Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd");
38         std::string s;
39         s1 >> s;
40 
41         std::istringstream s2 = std::move(s1);
42         s2 >> s;
43         assert(s == "Bbbbb");
44 
45         std::istringstream s3;
46         s3 = std::move(s2);
47         s3 >> s;
48         assert(s == "Cccccccccc");
49 
50         s1 = std::move(s3);
51         s1 >> s;
52         assert(s == "Dddddddddddddddddd");
53     }
54     {
55         std::wistringstream ss0(L" 123 456");
56         std::wistringstream ss;
57         ss = std::move(ss0);
58         assert(ss.rdbuf() != 0);
59         assert(ss.good());
60         assert(ss.str() == L" 123 456");
61         int i = 0;
62         ss >> i;
63         assert(i == 123);
64         ss >> i;
65         assert(i == 456);
66     }
67     {
68         std::wistringstream s1(L"Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd");
69         std::wstring s;
70         s1 >> s;
71 
72         std::wistringstream s2 = std::move(s1);
73         s2 >> s;
74         assert(s == L"Bbbbb");
75 
76         std::wistringstream s3;
77         s3 = std::move(s2);
78         s3 >> s;
79         assert(s == L"Cccccccccc");
80 
81         s1 = std::move(s3);
82         s1 >> s;
83         assert(s == L"Dddddddddddddddddd");
84     }
85 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
86 }
87