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, ios_base::openmode which, const Allocator& a) 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> 31*4dee6411SMark de Wever static void test(const Allocator& a) { 32*4dee6411SMark de Wever const std::basic_string<CharT, std::char_traits<CharT>, Allocator> s(STR("testing")); 33*4dee6411SMark de Wever const std::basic_ostringstream<CharT, std::char_traits<CharT>, Allocator> ss(s, std::ios_base::binary, a); 346ed40418SPiotr Fusik assert(ss.rdbuf()->get_allocator() == a); 356ed40418SPiotr Fusik assert(ss.view() == SV("testing")); 366ed40418SPiotr Fusik } 376ed40418SPiotr Fusik 386ed40418SPiotr 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>()); 416ed40418SPiotr 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>()); 446ed40418SPiotr Fusik #endif 456ed40418SPiotr Fusik return 0; 466ed40418SPiotr Fusik } 47