//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 // // template , class Allocator = allocator> // class basic_stringbuf // template // void str(const T& t); #include #include #include #include #include #include "constexpr_char_traits.h" #include "nasty_string.h" #include "test_allocator.h" #include "test_macros.h" #include "../../helper_concepts.h" #include "../../helper_string_macros.h" #include "../../helper_types.h" template > void test_sfinae_with_nasty_char() { using NStrBuf = std::basic_stringbuf; static_assert(is_valid_argument_for_str_member); static_assert(is_valid_argument_for_str_member); } template , typename AllocT = std::allocator> void test_sfinae() { using StrBuff = std::basic_stringbuf; static_assert(is_valid_argument_for_str_member); static_assert(is_valid_argument_for_str_member); static_assert(is_valid_argument_for_str_member>); static_assert(is_valid_argument_for_str_member>); static_assert(is_valid_argument_for_str_member>); static_assert(!is_valid_argument_for_str_member); static_assert(!is_valid_argument_for_str_member); static_assert(!is_valid_argument_for_str_member); static_assert(!is_valid_argument_for_str_member); static_assert(!is_valid_argument_for_str_member>); } template , typename AllocT = std::allocator> void test() { AllocT allocator; std::basic_stringbuf ss(std::ios_base::in | std::ios_base::out, allocator); assert(ss.str().empty()); // const CharT* ss.str(CS("ba")); assert(ss.str() == CS("ba")); // std::basic_string_view ss.str(SV("ma")); assert(ss.str() == CS("ma")); // std::basic_string ss.str(ST("zmt", allocator)); assert(ss.str() == CS("zmt")); // ConstConvertibleStringView ss.str(ConstConvertibleStringView{CS("da")}); assert(ss.str() == CS("da")); const std::basic_string s(allocator); ss.str(s); assert(ss.str().empty()); } int main(int, char**) { test_sfinae_with_nasty_char(); test_sfinae_with_nasty_char>(); test_sfinae(); test_sfinae, std::allocator>(); test_sfinae, test_allocator>(); test_sfinae, test_allocator>(); test(); test, std::allocator>(); test, test_allocator>(); test, test_allocator>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test_sfinae(); test_sfinae, std::allocator>(); test_sfinae, test_allocator>(); test_sfinae, test_allocator>(); test(); test, std::allocator>(); test, test_allocator>(); test, test_allocator>(); #endif return 0; }