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 // <sstream> 11 12 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 13 // class basic_stringbuf 14 15 // explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); 16 17 #include <sstream> 18 #include <cassert> 19 20 template<typename CharT> 21 struct testbuf 22 : std::basic_stringbuf<CharT> 23 { checktestbuf24 void check() 25 { 26 assert(this->eback() == NULL); 27 assert(this->gptr() == NULL); 28 assert(this->egptr() == NULL); 29 assert(this->pbase() == NULL); 30 assert(this->pptr() == NULL); 31 assert(this->epptr() == NULL); 32 } 33 }; 34 main()35int main() 36 { 37 { 38 std::stringbuf buf; 39 assert(buf.str() == ""); 40 } 41 { 42 std::wstringbuf buf; 43 assert(buf.str() == L""); 44 } 45 { 46 testbuf<char> buf; 47 buf.check(); 48 } 49 { 50 testbuf<wchar_t> buf; 51 buf.check(); 52 } 53 } 54