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 // <ostream> 10 11 // template <class charT, class traits = char_traits<charT> > 12 // class basic_ostream; 13 14 // explicit basic_ostream(basic_streambuf<charT,traits>* sb); 15 16 #include <ostream> 17 #include <cassert> 18 19 template <class CharT> 20 struct testbuf 21 : public std::basic_streambuf<CharT> 22 { 23 testbuf() {} 24 }; 25 26 int main(int, char**) 27 { 28 { 29 testbuf<char> sb; 30 std::basic_ostream<char> os(&sb); 31 assert(os.rdbuf() == &sb); 32 assert(os.tie() == 0); 33 assert(os.fill() == ' '); 34 assert(os.rdstate() == os.goodbit); 35 assert(os.exceptions() == os.goodbit); 36 assert(os.flags() == (os.skipws | os.dec)); 37 assert(os.precision() == 6); 38 assert(os.getloc().name() == "C"); 39 } 40 { 41 testbuf<wchar_t> sb; 42 std::basic_ostream<wchar_t> os(&sb); 43 assert(os.rdbuf() == &sb); 44 assert(os.tie() == 0); 45 assert(os.fill() == L' '); 46 assert(os.rdstate() == os.goodbit); 47 assert(os.exceptions() == os.goodbit); 48 assert(os.flags() == (os.skipws | os.dec)); 49 assert(os.precision() == 6); 50 assert(os.getloc().name() == "C"); 51 } 52 53 return 0; 54 } 55