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