xref: /llvm-project/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/mode.alloc.pass.cpp (revision 81ad5a5cb87740c62b30a4f8232770bd5eb7fc45)
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_stringbuf
15 
16 // basic_stringbuf(ios_base::openmode which, const Allocator& a);
17 
18 #include <sstream>
19 #include <cassert>
20 
21 #include "test_allocator.h"
22 #include "test_macros.h"
23 
24 template <class CharT>
test()25 static void test() {
26   const test_allocator<CharT> a(2);
27   const std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> buf(std::ios_base::in, a);
28   assert(buf.get_allocator() == a);
29   assert(buf.view().empty());
30 }
31 
main(int,char **)32 int main(int, char**) {
33   test<char>();
34 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
35   test<wchar_t>();
36 #endif
37   return 0;
38 }
39