161d2a9b3SPiotr Fusik //===----------------------------------------------------------------------===//
261d2a9b3SPiotr Fusik //
361d2a9b3SPiotr Fusik // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
461d2a9b3SPiotr Fusik // See https://llvm.org/LICENSE.txt for license information.
561d2a9b3SPiotr Fusik // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
661d2a9b3SPiotr Fusik //
761d2a9b3SPiotr Fusik //===----------------------------------------------------------------------===//
861d2a9b3SPiotr Fusik 
961d2a9b3SPiotr Fusik // UNSUPPORTED: c++03, c++11, c++14, c++17
1061d2a9b3SPiotr Fusik 
1161d2a9b3SPiotr Fusik // <sstream>
1261d2a9b3SPiotr Fusik 
1361d2a9b3SPiotr Fusik // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
1461d2a9b3SPiotr Fusik // class basic_istringstream
1561d2a9b3SPiotr Fusik 
1661d2a9b3SPiotr Fusik // template <class SAlloc>
1761d2a9b3SPiotr Fusik // explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s, ios_base::openmode which = ios_base::in)
1861d2a9b3SPiotr Fusik 
1961d2a9b3SPiotr Fusik #include <sstream>
2061d2a9b3SPiotr Fusik #include <cassert>
2161d2a9b3SPiotr Fusik 
2261d2a9b3SPiotr Fusik #include "make_string.h"
2361d2a9b3SPiotr Fusik #include "test_allocator.h"
2461d2a9b3SPiotr Fusik #include "test_macros.h"
25*4dee6411SMark de Wever #include "operator_hijacker.h"
2661d2a9b3SPiotr Fusik 
2761d2a9b3SPiotr Fusik #define STR(S) MAKE_STRING(CharT, S)
2861d2a9b3SPiotr Fusik #define SV(S) MAKE_STRING_VIEW(CharT, S)
2961d2a9b3SPiotr Fusik 
30*4dee6411SMark de Wever template <class CharT, class Allocator>
3161d2a9b3SPiotr Fusik static void test() {
3261d2a9b3SPiotr Fusik   {
3361d2a9b3SPiotr Fusik     const std::basic_string<CharT> s(STR("testing"));
34*4dee6411SMark de Wever     const std::basic_istringstream<CharT, std::char_traits<CharT>, Allocator> ss(s);
3561d2a9b3SPiotr Fusik     assert(ss.view() == SV("testing"));
3661d2a9b3SPiotr Fusik   }
3761d2a9b3SPiotr Fusik   {
3861d2a9b3SPiotr Fusik     const std::basic_string<CharT> s(STR("testing"));
39*4dee6411SMark de Wever     const std::basic_istringstream<CharT, std::char_traits<CharT>, Allocator> ss(s, std::ios_base::binary);
4061d2a9b3SPiotr Fusik     assert(ss.view() == SV("testing"));
4161d2a9b3SPiotr Fusik   }
4261d2a9b3SPiotr Fusik }
4361d2a9b3SPiotr Fusik 
4461d2a9b3SPiotr Fusik int main(int, char**) {
45*4dee6411SMark de Wever   test<char, test_allocator<char>>();
46*4dee6411SMark de Wever   test<char, operator_hijacker_allocator<char>>();
4761d2a9b3SPiotr Fusik #ifndef TEST_HAS_NO_WIDE_CHARACTERS
48*4dee6411SMark de Wever   test<wchar_t, test_allocator<wchar_t>>();
49*4dee6411SMark de Wever   test<wchar_t, operator_hijacker_allocator<wchar_t>>();
5061d2a9b3SPiotr Fusik #endif
5161d2a9b3SPiotr Fusik   return 0;
5261d2a9b3SPiotr Fusik }
53