[RISCV] Improve Errors for X1/X5/X1X5 Reg Classes (#126184)
[llvm-project.git] / libcxx / test / std / input.output / string.streams / stringbuf / stringbuf.cons / default.pass.cpp
blobdac43967d815f69837332bd3102bac63e885c39b
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <sstream>
11 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
12 // class basic_stringbuf
14 // explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20
15 // basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20
16 // explicit basic_stringbuf(ios_base::openmode which); // C++20
18 // XFAIL: FROZEN-CXX03-HEADERS-FIXME
20 #include <sstream>
21 #include <cassert>
23 #include "test_macros.h"
24 #if TEST_STD_VER >= 11
25 #include "test_convertible.h"
26 #endif
28 template<typename CharT>
29 struct testbuf
30 : std::basic_stringbuf<CharT>
32 void check()
34 // LWG2995
35 // It is implementation-defined whether the sequence pointers (eback(),
36 // gptr(), egptr(), pbase(), pptr(), epptr()) are initialized to null
37 // pointers.
38 // This tests the libc++ specific implementation.
39 LIBCPP_ASSERT(this->eback() != nullptr);
40 LIBCPP_ASSERT(this->gptr() != nullptr);
41 LIBCPP_ASSERT(this->egptr() != nullptr);
42 LIBCPP_ASSERT(this->pbase() != nullptr);
43 LIBCPP_ASSERT(this->pptr() != nullptr);
44 LIBCPP_ASSERT(this->epptr() != nullptr);
45 assert(this->str().empty());
49 int main(int, char**)
52 std::stringbuf buf;
53 assert(buf.str() == "");
56 testbuf<char> buf;
57 buf.check();
59 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
61 std::wstringbuf buf;
62 assert(buf.str() == L"");
65 testbuf<wchar_t> buf;
66 buf.check();
68 #endif
70 #if TEST_STD_VER >= 11
72 typedef std::stringbuf B;
73 static_assert(test_convertible<B>(), "");
74 static_assert(!test_convertible<B, std::ios_base::openmode>(), "");
76 #endif
78 return 0;