1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
14 // class basic_stringbuf
16 // explicit basic_stringbuf(basic_string<charT, traits, Allocator>&& s, ios_base::openmode which = ios_base::in | ios_base::out);
21 #include "make_string.h"
22 #include "test_allocator.h"
23 #include "test_macros.h"
25 #define STR(S) MAKE_STRING(CharT, S)
26 #define SV(S) MAKE_STRING_VIEW(CharT, S)
28 template <class CharT
>
31 std::basic_string
<CharT
> s(STR("testing"));
32 const std::basic_stringbuf
<CharT
> buf(std::move(s
));
33 assert(buf
.view() == SV("testing"));
36 std::basic_string
<CharT
> s(STR("testing"));
37 const std::basic_stringbuf
<CharT
> buf(std::move(s
), std::ios_base::out
);
38 assert(buf
.view() == SV("testing"));
41 std::basic_string
<CharT
, std::char_traits
<CharT
>, test_allocator
<CharT
>> s(STR("testing"));
42 const std::basic_stringbuf
<CharT
, std::char_traits
<CharT
>, test_allocator
<CharT
>> buf(std::move(s
));
43 assert(buf
.view() == SV("testing"));
46 std::basic_string
<CharT
, std::char_traits
<CharT
>, test_allocator
<CharT
>> s(STR("testing"));
47 const std::basic_stringbuf
<CharT
, std::char_traits
<CharT
>, test_allocator
<CharT
>> buf(
48 std::move(s
), std::ios_base::in
);
49 assert(buf
.view() == SV("testing"));
53 int main(int, char**) {
55 #ifndef TEST_HAS_NO_WIDE_CHARACTERS