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