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 // explicit basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s, ios_base::openmode which = ios_base::out | ios_base::in) 18c7c0095bSPiotr Fusik 19c7c0095bSPiotr Fusik #include <sstream> 20c7c0095bSPiotr Fusik #include <cassert> 21c7c0095bSPiotr Fusik 22c7c0095bSPiotr Fusik #include "make_string.h" 23c7c0095bSPiotr Fusik #include "test_allocator.h" 24*4dee6411SMark de Wever #include "operator_hijacker.h" 25c7c0095bSPiotr Fusik #include "test_macros.h" 26c7c0095bSPiotr Fusik 27c7c0095bSPiotr Fusik #define STR(S) MAKE_STRING(CharT, S) 28c7c0095bSPiotr Fusik #define SV(S) MAKE_STRING_VIEW(CharT, S) 29c7c0095bSPiotr Fusik 30*4dee6411SMark de Wever template <class CharT, class Allocator> 31c7c0095bSPiotr Fusik static void test() { 32c7c0095bSPiotr Fusik { 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); 35c7c0095bSPiotr Fusik assert(ss.view() == SV("testing")); 36c7c0095bSPiotr Fusik } 37c7c0095bSPiotr Fusik { 38c7c0095bSPiotr Fusik const std::basic_string<CharT> s(STR("testing")); 39*4dee6411SMark de Wever const std::basic_stringstream<CharT, std::char_traits<CharT>, Allocator> ss(s, std::ios_base::in); 40c7c0095bSPiotr Fusik assert(ss.view() == SV("testing")); 41c7c0095bSPiotr Fusik } 42c7c0095bSPiotr Fusik } 43c7c0095bSPiotr Fusik 44c7c0095bSPiotr Fusik int main(int, char**) { 45*4dee6411SMark de Wever test<char, test_allocator<char>>(); 46*4dee6411SMark de Wever test<char, operator_hijacker_allocator<char>>(); 47c7c0095bSPiotr 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>>(); 50c7c0095bSPiotr Fusik #endif 51c7c0095bSPiotr Fusik return 0; 52c7c0095bSPiotr Fusik } 53