15a83710eSEric Fiselier //===----------------------------------------------------------------------===// 25a83710eSEric Fiselier // 357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65a83710eSEric Fiselier // 75a83710eSEric Fiselier //===----------------------------------------------------------------------===// 85a83710eSEric Fiselier 95a83710eSEric Fiselier // <sstream> 105a83710eSEric Fiselier 115a83710eSEric Fiselier // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 125a83710eSEric Fiselier // class basic_stringstream 135a83710eSEric Fiselier 14a11f8b1aSMarek Kurdej // explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20 15a11f8b1aSMarek Kurdej // basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20 16a11f8b1aSMarek Kurdej // explicit basic_stringstream(ios_base::openmode which); // C++20 175a83710eSEric Fiselier 185a83710eSEric Fiselier #include <sstream> 195a83710eSEric Fiselier #include <cassert> 205a83710eSEric Fiselier 217fc6a556SMarshall Clow #include "test_macros.h" 22a11f8b1aSMarek Kurdej #if TEST_STD_VER >= 11 23a11f8b1aSMarek Kurdej #include "test_convertible.h" 24a11f8b1aSMarek Kurdej 25a11f8b1aSMarek Kurdej template <typename S> test()26a11f8b1aSMarek Kurdejvoid test() { 27a11f8b1aSMarek Kurdej static_assert(test_convertible<S>(), ""); 28a11f8b1aSMarek Kurdej static_assert(!test_convertible<S, std::ios_base::openmode>(), ""); 29a11f8b1aSMarek Kurdej } 30a11f8b1aSMarek Kurdej #endif 317fc6a556SMarshall Clow main(int,char **)322df59c50SJF Bastienint main(int, char**) 335a83710eSEric Fiselier { 345a83710eSEric Fiselier { 355a83710eSEric Fiselier std::stringstream ss; 365a83710eSEric Fiselier assert(ss.rdbuf() != 0); 375a83710eSEric Fiselier assert(ss.good()); 385a83710eSEric Fiselier assert(ss.str() == ""); 395a83710eSEric Fiselier } 405a83710eSEric Fiselier { 415a83710eSEric Fiselier std::stringstream ss(std::ios_base::in); 425a83710eSEric Fiselier assert(ss.rdbuf() != 0); 435a83710eSEric Fiselier assert(ss.good()); 445a83710eSEric Fiselier assert(ss.str() == ""); 455a83710eSEric Fiselier } 46f4c1258dSLouis Dionne #ifndef TEST_HAS_NO_WIDE_CHARACTERS 475a83710eSEric Fiselier { 485a83710eSEric Fiselier std::wstringstream ss; 495a83710eSEric Fiselier assert(ss.rdbuf() != 0); 505a83710eSEric Fiselier assert(ss.good()); 515a83710eSEric Fiselier assert(ss.str() == L""); 525a83710eSEric Fiselier } 535a83710eSEric Fiselier { 545a83710eSEric Fiselier std::wstringstream ss(std::ios_base::in); 555a83710eSEric Fiselier assert(ss.rdbuf() != 0); 565a83710eSEric Fiselier assert(ss.good()); 575a83710eSEric Fiselier assert(ss.str() == L""); 585a83710eSEric Fiselier } 59f4c1258dSLouis Dionne #endif 602df59c50SJF Bastien 61a11f8b1aSMarek Kurdej #if TEST_STD_VER >= 11 62a11f8b1aSMarek Kurdej test<std::stringstream>(); 63*d9d2ebbfSMark de Wever # ifndef TEST_HAS_NO_WIDE_CHARACTERS 64a11f8b1aSMarek Kurdej test<std::wstringstream>(); 65a11f8b1aSMarek Kurdej # endif 66f4c1258dSLouis Dionne #endif 67a11f8b1aSMarek Kurdej 682df59c50SJF Bastien return 0; 695a83710eSEric Fiselier } 70