move.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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_stringstream 14 15// basic_stringstream& operator=(basic_stringstream&& rhs); 16 17#include <sstream> 18#include <cassert> 19 20int main() 21{ 22#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 23 { 24 std::stringstream ss0(" 123 456 "); 25 std::stringstream 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 ss << i << ' ' << 123; 36 assert(ss.str() == "456 1236 "); 37 } 38 { 39 std::wstringstream ss0(L" 123 456 "); 40 std::wstringstream ss; 41 ss = std::move(ss0); 42 assert(ss.rdbuf() != 0); 43 assert(ss.good()); 44 assert(ss.str() == L" 123 456 "); 45 int i = 0; 46 ss >> i; 47 assert(i == 123); 48 ss >> i; 49 assert(i == 456); 50 ss << i << ' ' << 123; 51 assert(ss.str() == L"456 1236 "); 52 } 53#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 54} 55