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 // <string> 11 12 // template<class charT, class traits, class Allocator> 13 // basic_ostream<charT, traits>& 14 // operator<<(basic_ostream<charT, traits>& os, 15 // const basic_string<charT,traits,Allocator>& str); 16 17 #include <string> 18 #include <sstream> 19 #include <cassert> 20 21 int main() 22 { 23 { 24 std::ostringstream out; 25 std::string s("some text"); 26 out << s; 27 assert(out.good()); 28 assert(s == out.str()); 29 } 30 { 31 std::ostringstream out; 32 std::string s("some text"); 33 out.width(12); 34 out << s; 35 assert(out.good()); 36 assert(" " + s == out.str()); 37 } 38 { 39 std::wostringstream out; 40 std::wstring s(L"some text"); 41 out << s; 42 assert(out.good()); 43 assert(s == out.str()); 44 } 45 { 46 std::wostringstream out; 47 std::wstring s(L"some text"); 48 out.width(12); 49 out << s; 50 assert(out.good()); 51 assert(L" " + s == out.str()); 52 } 53 } 54