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 // explicit basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s, ios_base::openmode which = ios_base::out)
186ed40418SPiotr Fusik 
196ed40418SPiotr Fusik #include <sstream>
206ed40418SPiotr Fusik #include <cassert>
216ed40418SPiotr Fusik 
226ed40418SPiotr Fusik #include "make_string.h"
236ed40418SPiotr Fusik #include "test_allocator.h"
246ed40418SPiotr Fusik #include "test_macros.h"
25*4dee6411SMark de Wever #include "operator_hijacker.h"
266ed40418SPiotr Fusik 
276ed40418SPiotr Fusik #define STR(S) MAKE_STRING(CharT, S)
286ed40418SPiotr Fusik #define SV(S) MAKE_STRING_VIEW(CharT, S)
296ed40418SPiotr Fusik 
30*4dee6411SMark de Wever template <class CharT, class Allocator>
316ed40418SPiotr Fusik static void test() {
326ed40418SPiotr Fusik   {
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);
356ed40418SPiotr Fusik     assert(ss.view() == SV("testing"));
366ed40418SPiotr Fusik   }
376ed40418SPiotr Fusik   {
386ed40418SPiotr Fusik     const std::basic_string<CharT> s(STR("testing"));
39*4dee6411SMark de Wever     const std::basic_ostringstream<CharT, std::char_traits<CharT>, Allocator> ss(s, std::ios_base::binary);
406ed40418SPiotr Fusik     assert(ss.view() == SV("testing"));
416ed40418SPiotr Fusik   }
426ed40418SPiotr Fusik }
436ed40418SPiotr Fusik 
446ed40418SPiotr Fusik int main(int, char**) {
45*4dee6411SMark de Wever   test<char, test_allocator<char>>();
46*4dee6411SMark de Wever   test<char, operator_hijacker_allocator<char>>();
476ed40418SPiotr 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>>();
506ed40418SPiotr Fusik #endif
516ed40418SPiotr Fusik   return 0;
526ed40418SPiotr Fusik }
53