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 // <sstream> 10 11 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 12 // class basic_stringbuf 13 14 // explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20 15 // basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20 16 // explicit basic_stringbuf(ios_base::openmode which); // C++20 17 18 #include <sstream> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #if TEST_STD_VER >= 11 23 #include "test_convertible.h" 24 #endif 25 26 template<typename CharT> 27 struct testbuf 28 : std::basic_stringbuf<CharT> 29 { checktestbuf30 void check() 31 { 32 assert(this->eback() == NULL); 33 assert(this->gptr() == NULL); 34 assert(this->egptr() == NULL); 35 assert(this->pbase() == NULL); 36 assert(this->pptr() == NULL); 37 assert(this->epptr() == NULL); 38 } 39 }; 40 main(int,char **)41int main(int, char**) 42 { 43 { 44 std::stringbuf buf; 45 assert(buf.str() == ""); 46 } 47 { 48 testbuf<char> buf; 49 buf.check(); 50 } 51 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 52 { 53 std::wstringbuf buf; 54 assert(buf.str() == L""); 55 } 56 { 57 testbuf<wchar_t> buf; 58 buf.check(); 59 } 60 #endif 61 62 #if TEST_STD_VER >= 11 63 { 64 typedef std::stringbuf B; 65 static_assert(test_convertible<B>(), ""); 66 static_assert(!test_convertible<B, std::ios_base::openmode>(), ""); 67 } 68 #endif 69 70 return 0; 71 } 72