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 // <sstream> 10 11 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 12 // class basic_istringstream 13 14 // basic_istringstream(basic_istringstream&& rhs); 15 16 // XFAIL: FROZEN-CXX03-HEADERS-FIXME 17 18 #include <sstream> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #include "operator_hijacker.h" 23 24 int main(int, char**) 25 { 26 { 27 std::istringstream ss0(" 123 456"); 28 std::istringstream ss(std::move(ss0)); 29 assert(ss.rdbuf() != 0); 30 assert(ss.good()); 31 assert(ss.str() == " 123 456"); 32 int i = 0; 33 ss >> i; 34 assert(i == 123); 35 ss >> i; 36 assert(i == 456); 37 } 38 { 39 std::basic_istringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss0(" 123 456"); 40 std::basic_istringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss(std::move(ss0)); 41 assert(ss.rdbuf() != 0); 42 assert(ss.good()); 43 assert(ss.str() == " 123 456"); 44 int i = 0; 45 ss >> i; 46 assert(i == 123); 47 ss >> i; 48 assert(i == 456); 49 } 50 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 51 { 52 std::wistringstream ss0(L" 123 456"); 53 std::wistringstream ss(std::move(ss0)); 54 assert(ss.rdbuf() != 0); 55 assert(ss.good()); 56 assert(ss.str() == L" 123 456"); 57 int i = 0; 58 ss >> i; 59 assert(i == 123); 60 ss >> i; 61 assert(i == 456); 62 } 63 { 64 std::basic_istringstream<wchar_t, std::char_traits<wchar_t>, operator_hijacker_allocator<wchar_t> > ss0( 65 L" 123 456"); 66 std::basic_istringstream<wchar_t, std::char_traits<wchar_t>, operator_hijacker_allocator<wchar_t> > ss( 67 std::move(ss0)); 68 assert(ss.rdbuf() != 0); 69 assert(ss.good()); 70 assert(ss.str() == L" 123 456"); 71 int i = 0; 72 ss >> i; 73 assert(i == 123); 74 ss >> i; 75 assert(i == 456); 76 } 77 #endif 78 79 return 0; 80 } 81