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_stringstream 13 14 // explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20 15 // basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20 16 // explicit basic_stringstream(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 25 template <typename S> 26 void test() { 27 static_assert(test_convertible<S>(), ""); 28 static_assert(!test_convertible<S, std::ios_base::openmode>(), ""); 29 } 30 #endif 31 32 int main(int, char**) 33 { 34 { 35 std::stringstream ss; 36 assert(ss.rdbuf() != 0); 37 assert(ss.good()); 38 assert(ss.str() == ""); 39 } 40 { 41 std::stringstream ss(std::ios_base::in); 42 assert(ss.rdbuf() != 0); 43 assert(ss.good()); 44 assert(ss.str() == ""); 45 } 46 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 47 { 48 std::wstringstream ss; 49 assert(ss.rdbuf() != 0); 50 assert(ss.good()); 51 assert(ss.str() == L""); 52 } 53 { 54 std::wstringstream ss(std::ios_base::in); 55 assert(ss.rdbuf() != 0); 56 assert(ss.good()); 57 assert(ss.str() == L""); 58 } 59 #endif 60 61 #if TEST_STD_VER >= 11 62 test<std::stringstream>(); 63 # ifndef TEST_HAS_NO_WIDE_CHARACTERS 64 test<std::wstringstream>(); 65 # endif 66 #endif 67 68 return 0; 69 } 70