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_istringstream
135a83710eSEric Fiselier 
14*a11f8b1aSMarek Kurdej // explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20
15*a11f8b1aSMarek Kurdej // basic_istringstream() : basic_istringstream(ios_base::in) {}           // C++20
16*a11f8b1aSMarek Kurdej // explicit basic_istringstream(ios_base::openmode which);                // C++20
175a83710eSEric Fiselier 
185a83710eSEric Fiselier #include <sstream>
195a83710eSEric Fiselier #include <cassert>
205a83710eSEric Fiselier 
217fc6a556SMarshall Clow #include "test_macros.h"
22*a11f8b1aSMarek Kurdej #if TEST_STD_VER >= 11
23*a11f8b1aSMarek Kurdej #include "test_convertible.h"
24*a11f8b1aSMarek Kurdej 
25*a11f8b1aSMarek Kurdej template <typename S>
26*a11f8b1aSMarek Kurdej void test() {
27*a11f8b1aSMarek Kurdej   static_assert(test_convertible<S>(), "");
28*a11f8b1aSMarek Kurdej   static_assert(!test_convertible<S, std::ios_base::openmode>(), "");
29*a11f8b1aSMarek Kurdej }
30*a11f8b1aSMarek Kurdej #endif
317fc6a556SMarshall Clow 
322df59c50SJF Bastien int main(int, char**)
335a83710eSEric Fiselier {
345a83710eSEric Fiselier     {
355a83710eSEric Fiselier         std::istringstream ss;
365a83710eSEric Fiselier         assert(ss.rdbuf() != 0);
375a83710eSEric Fiselier         assert(ss.good());
385a83710eSEric Fiselier         assert(ss.str() == "");
395a83710eSEric Fiselier     }
405a83710eSEric Fiselier     {
415a83710eSEric Fiselier         std::istringstream ss(std::ios_base::in);
425a83710eSEric Fiselier         assert(ss.rdbuf() != 0);
435a83710eSEric Fiselier         assert(ss.good());
445a83710eSEric Fiselier         assert(ss.str() == "");
455a83710eSEric Fiselier     }
465a83710eSEric Fiselier     {
475a83710eSEric Fiselier         std::wistringstream ss;
485a83710eSEric Fiselier         assert(ss.rdbuf() != 0);
495a83710eSEric Fiselier         assert(ss.good());
505a83710eSEric Fiselier         assert(ss.str() == L"");
515a83710eSEric Fiselier     }
525a83710eSEric Fiselier     {
535a83710eSEric Fiselier         std::wistringstream ss(std::ios_base::in);
545a83710eSEric Fiselier         assert(ss.rdbuf() != 0);
555a83710eSEric Fiselier         assert(ss.good());
565a83710eSEric Fiselier         assert(ss.str() == L"");
575a83710eSEric Fiselier     }
582df59c50SJF Bastien 
59*a11f8b1aSMarek Kurdej #if TEST_STD_VER >= 11
60*a11f8b1aSMarek Kurdej     test<std::istringstream>();
61*a11f8b1aSMarek Kurdej     test<std::wistringstream>();
62*a11f8b1aSMarek Kurdej #endif
63*a11f8b1aSMarek Kurdej 
642df59c50SJF Bastien     return 0;
655a83710eSEric Fiselier }
66