1c7c0095bSPiotr Fusik //===----------------------------------------------------------------------===// 2c7c0095bSPiotr Fusik // 3c7c0095bSPiotr Fusik // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4c7c0095bSPiotr Fusik // See https://llvm.org/LICENSE.txt for license information. 5c7c0095bSPiotr Fusik // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6c7c0095bSPiotr Fusik // 7c7c0095bSPiotr Fusik //===----------------------------------------------------------------------===// 8c7c0095bSPiotr Fusik 9c7c0095bSPiotr Fusik // UNSUPPORTED: c++03, c++11, c++14, c++17 10c7c0095bSPiotr Fusik 11c7c0095bSPiotr Fusik // <sstream> 12c7c0095bSPiotr Fusik 13c7c0095bSPiotr Fusik // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>> 14c7c0095bSPiotr Fusik // class basic_stringstream 15c7c0095bSPiotr Fusik 16c7c0095bSPiotr Fusik // template <class SAlloc> 17c7c0095bSPiotr Fusik // basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s, const Allocator& a) 18c7c0095bSPiotr Fusik // : basic_stringstream(s, ios_base::out | ios_base::in, a) {} 19c7c0095bSPiotr Fusik 20c7c0095bSPiotr Fusik #include <sstream> 21c7c0095bSPiotr Fusik #include <cassert> 22c7c0095bSPiotr Fusik 23c7c0095bSPiotr Fusik #include "make_string.h" 24c7c0095bSPiotr Fusik #include "test_allocator.h" 25*4dee6411SMark de Wever #include "operator_hijacker.h" 26c7c0095bSPiotr Fusik #include "test_macros.h" 27c7c0095bSPiotr Fusik 28c7c0095bSPiotr Fusik #define STR(S) MAKE_STRING(CharT, S) 29c7c0095bSPiotr Fusik #define SV(S) MAKE_STRING_VIEW(CharT, S) 30c7c0095bSPiotr Fusik 31*4dee6411SMark de Wever template <class CharT, class Allocator> 32*4dee6411SMark de Wever static void test(const Allocator& a) { 33c7c0095bSPiotr Fusik const std::basic_string<CharT> s(STR("testing")); 34*4dee6411SMark de Wever const std::basic_stringstream<CharT, std::char_traits<CharT>, Allocator> ss(s, a); 35c7c0095bSPiotr Fusik assert(ss.rdbuf()->get_allocator() == a); 36c7c0095bSPiotr Fusik assert(ss.view() == SV("testing")); 37c7c0095bSPiotr Fusik } 38c7c0095bSPiotr Fusik 39c7c0095bSPiotr 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>()); 42c7c0095bSPiotr 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>()); 45c7c0095bSPiotr Fusik #endif 46c7c0095bSPiotr Fusik return 0; 47c7c0095bSPiotr Fusik } 48