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 // UNSUPPORTED: c++98, c++03 11 12 // <sstream> 13 14 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 15 // class basic_istringstream 16 17 // basic_istringstream& operator=(basic_istringstream&& rhs); 18 19 #include <sstream> 20 #include <cassert> 21 main()22int main() 23 { 24 { 25 std::istringstream ss0(" 123 456"); 26 std::istringstream ss; 27 ss = std::move(ss0); 28 assert(ss.rdbuf() != 0); 29 assert(ss.good()); 30 assert(ss.str() == " 123 456"); 31 int i = 0; 32 ss >> i; 33 assert(i == 123); 34 ss >> i; 35 assert(i == 456); 36 } 37 { 38 std::istringstream s1("Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd"); 39 std::string s; 40 s1 >> s; 41 42 std::istringstream s2 = std::move(s1); 43 s2 >> s; 44 assert(s == "Bbbbb"); 45 46 std::istringstream s3; 47 s3 = std::move(s2); 48 s3 >> s; 49 assert(s == "Cccccccccc"); 50 51 s1 = std::move(s3); 52 s1 >> s; 53 assert(s == "Dddddddddddddddddd"); 54 } 55 { 56 std::wistringstream ss0(L" 123 456"); 57 std::wistringstream ss; 58 ss = std::move(ss0); 59 assert(ss.rdbuf() != 0); 60 assert(ss.good()); 61 assert(ss.str() == L" 123 456"); 62 int i = 0; 63 ss >> i; 64 assert(i == 123); 65 ss >> i; 66 assert(i == 456); 67 } 68 { 69 std::wistringstream s1(L"Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd"); 70 std::wstring s; 71 s1 >> s; 72 73 std::wistringstream s2 = std::move(s1); 74 s2 >> s; 75 assert(s == L"Bbbbb"); 76 77 std::wistringstream s3; 78 s3 = std::move(s2); 79 s3 >> s; 80 assert(s == L"Cccccccccc"); 81 82 s1 = std::move(s3); 83 s1 >> s; 84 assert(s == L"Dddddddddddddddddd"); 85 } 86 } 87