16ed40418SPiotr Fusik //===----------------------------------------------------------------------===//
26ed40418SPiotr Fusik //
36ed40418SPiotr Fusik // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
46ed40418SPiotr Fusik // See https://llvm.org/LICENSE.txt for license information.
56ed40418SPiotr Fusik // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66ed40418SPiotr Fusik //
76ed40418SPiotr Fusik //===----------------------------------------------------------------------===//
86ed40418SPiotr Fusik 
96ed40418SPiotr Fusik // UNSUPPORTED: c++03, c++11, c++14, c++17
106ed40418SPiotr Fusik 
116ed40418SPiotr Fusik // <sstream>
126ed40418SPiotr Fusik 
136ed40418SPiotr Fusik // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
146ed40418SPiotr Fusik // class basic_ostringstream
156ed40418SPiotr Fusik 
166ed40418SPiotr Fusik // template <class SAlloc>
176ed40418SPiotr Fusik // basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s, const Allocator& a)
186ed40418SPiotr Fusik //     : basic_ostringstream(s, ios_base::out, a) {}
196ed40418SPiotr Fusik 
206ed40418SPiotr Fusik #include <sstream>
216ed40418SPiotr Fusik #include <cassert>
226ed40418SPiotr Fusik 
236ed40418SPiotr Fusik #include "make_string.h"
246ed40418SPiotr Fusik #include "test_allocator.h"
256ed40418SPiotr Fusik #include "test_macros.h"
26*4dee6411SMark de Wever #include "operator_hijacker.h"
276ed40418SPiotr Fusik 
286ed40418SPiotr Fusik #define STR(S) MAKE_STRING(CharT, S)
296ed40418SPiotr Fusik #define SV(S) MAKE_STRING_VIEW(CharT, S)
306ed40418SPiotr Fusik 
31*4dee6411SMark de Wever template <class CharT, class Allocator>
32*4dee6411SMark de Wever static void test(const Allocator& a) {
336ed40418SPiotr Fusik   const std::basic_string<CharT> s(STR("testing"));
34*4dee6411SMark de Wever   const std::basic_ostringstream<CharT, std::char_traits<CharT>, Allocator> ss(s, a);
356ed40418SPiotr Fusik   assert(ss.rdbuf()->get_allocator() == a);
366ed40418SPiotr Fusik   assert(ss.view() == SV("testing"));
376ed40418SPiotr Fusik }
386ed40418SPiotr Fusik 
396ed40418SPiotr Fusik int main(int, char**) {
40*4dee6411SMark de Wever   test<char>(test_allocator<char>(2));
41*4dee6411SMark de Wever   test<char>(operator_hijacker_allocator<char>());
426ed40418SPiotr Fusik #ifndef TEST_HAS_NO_WIDE_CHARACTERS
43*4dee6411SMark de Wever   test<wchar_t>(test_allocator<wchar_t>(2));
44*4dee6411SMark de Wever   test<wchar_t>(operator_hijacker_allocator<wchar_t>());
456ed40418SPiotr Fusik #endif
466ed40418SPiotr Fusik   return 0;
476ed40418SPiotr Fusik }
48