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_view<charT,traits> str); 16 17#include <experimental/string_view> 18#include <sstream> 19#include <cassert> 20 21using std::experimental::string_view; 22using std::experimental::wstring_view; 23 24int main() 25{ 26 { 27 std::ostringstream out; 28 string_view sv("some text"); 29 out << sv; 30 assert(out.good()); 31 assert(sv == out.str()); 32 } 33 { 34 std::ostringstream out; 35 std::string s("some text"); 36 string_view sv(s); 37 out.width(12); 38 out << sv; 39 assert(out.good()); 40 assert(" " + s == out.str()); 41 } 42 { 43 std::wostringstream out; 44 wstring_view sv(L"some text"); 45 out << sv; 46 assert(out.good()); 47 assert(sv == out.str()); 48 } 49 { 50 std::wostringstream out; 51 std::wstring s(L"some text"); 52 wstring_view sv(s); 53 out.width(12); 54 out << sv; 55 assert(out.good()); 56 assert(L" " + s == out.str()); 57 } 58} 59