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, class T>
16 // basic_ostream<charT, traits>&
17 // operator<<(basic_ostream<charT, traits>&& os, const T& x);
22 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
24 template <class CharT>
26 : public std::basic_streambuf<CharT>
28 typedef std::basic_streambuf<CharT> base;
29 std::basic_string<CharT> str_;
35 std::basic_string<CharT> str() const
36 {return std::basic_string<CharT>(base::pbase(), base::pptr());}
40 virtual typename base::int_type
41 overflow(typename base::int_type __c = base::traits_type::eof())
43 if (__c != base::traits_type::eof())
45 int n = static_cast<int>(str_.size());
46 str_.push_back(static_cast<CharT>(__c));
47 str_.resize(str_.capacity());
48 base::setp(const_cast<CharT*>(str_.data()),
49 const_cast<CharT*>(str_.data() + str_.size()));
56 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
60 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
63 std::ostream(&sb) << "testing...";
64 assert(sb.str() == "testing...");
68 std::wostream(&sb) << L"123";
69 assert(sb.str() == L"123");
71 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES