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 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 
11 // <sstream>
12 
13 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
14 // class basic_stringstream
15 
16 // basic_stringstream(ios_base::openmode which, const Allocator& a);
17 
18 #include <cassert>
19 #include <sstream>
20 
21 #include "test_allocator.h"
22 #include "test_macros.h"
23 #include "operator_hijacker.h"
24 
25 template <class CharT, class Allocator>
26 static void test(const Allocator& a) {
27   const std::basic_stringstream<CharT, std::char_traits<CharT>, Allocator> ss(std::ios_base::in, a);
28   assert(ss.rdbuf()->get_allocator() == a);
29   assert(ss.view().empty());
30 }
31 
32 int main(int, char**) {
33   test<char>(test_allocator<char>(2));
34   test<char>(operator_hijacker_allocator<char>());
35 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
36   test<wchar_t>(test_allocator<wchar_t>(2));
37   test<wchar_t>(operator_hijacker_allocator<wchar_t>());
38 #endif
39   return 0;
40 }
41