1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class charT, class traits = char_traits<charT> >
13 // class basic_ostream;
15 // template<class charT, class traits>
16 // basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, charT c);
21 template <class CharT>
23 : public std::basic_streambuf<CharT>
25 typedef std::basic_streambuf<CharT> base;
26 std::basic_string<CharT> str_;
32 std::basic_string<CharT> str() const
33 {return std::basic_string<CharT>(base::pbase(), base::pptr());}
37 virtual typename base::int_type
38 overflow(typename base::int_type __c = base::traits_type::eof())
40 if (__c != base::traits_type::eof())
42 int n = static_cast<int>(str_.size());
44 str_.resize(str_.capacity());
45 base::setp(const_cast<CharT*>(str_.data()),
46 const_cast<CharT*>(str_.data() + str_.size()));
56 std::wostream os((std::wstreambuf*)0);
64 std::wostream os(&sb);
67 assert(sb.str() == L"a");
71 std::wostream os(&sb);
75 assert(sb.str() == L" a");
76 assert(os.width() == 0);
80 std::wostream os(&sb);
85 assert(sb.str() == L"a ");
86 assert(os.width() == 0);