[libcxx-commits] [libcxx] [libc++][sstream] P2495R3: Interfacing `stringstream`s with `string_view` (PR #80552)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 11 07:10:34 PST 2024
================
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_istringstream
+
+// template<class T>
+// void str(const T& t);
+
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_macros.h"
+
+template <typename S, typename T>
+concept HasStr = requires(S s, const T& sv) {
+ { s.str(sv) };
+};
+
+template <typename CharT>
+void test_sfinae() {
+ struct SomeObject {};
+
+ static_assert(HasStr<std::basic_istringstream<CharT>, const CharT*>);
+ static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string_view<CharT>>);
+ static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string<CharT>>);
+
+ static_assert(!HasStr<std::basic_istringstream<CharT>, char>);
----------------
mordante wrote:
Maybe test with `CharT` too.
https://github.com/llvm/llvm-project/pull/80552
More information about the libcxx-commits
mailing list