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 // basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s, ios_base::openmode which, const Allocator& a)
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>
31*4dee6411SMark de Wever static void test(const Allocator& a) {
3261d2a9b3SPiotr Fusik   const std::basic_string<CharT> s(STR("testing"));
33*4dee6411SMark de Wever   const std::basic_istringstream<CharT, std::char_traits<CharT>, Allocator> ss(s, std::ios_base::binary, a);
3461d2a9b3SPiotr Fusik   assert(ss.rdbuf()->get_allocator() == a);
3561d2a9b3SPiotr Fusik   assert(ss.view() == SV("testing"));
3661d2a9b3SPiotr Fusik }
3761d2a9b3SPiotr Fusik 
3861d2a9b3SPiotr Fusik int main(int, char**) {
39*4dee6411SMark de Wever   test<char>(test_allocator<char>(2));
40*4dee6411SMark de Wever   test<char>(operator_hijacker_allocator<char>());
4161d2a9b3SPiotr Fusik #ifndef TEST_HAS_NO_WIDE_CHARACTERS
42*4dee6411SMark de Wever   test<wchar_t>(test_allocator<wchar_t>(2));
43*4dee6411SMark de Wever   test<wchar_t>(operator_hijacker_allocator<wchar_t>());
4461d2a9b3SPiotr Fusik #endif
4561d2a9b3SPiotr Fusik   return 0;
4661d2a9b3SPiotr Fusik }
47