[libcxx-commits] [PATCH] D148641: [libc++] Add C++20 stringstream::view()

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 28 10:22:18 PDT 2023


Mordante added a comment.

In D148641#4304594 <https://reviews.llvm.org/D148641#4304594>, @pfusik wrote:

> There's more in the paper. I'd be happy to implement these in subsequent commits.

Can you for now add notes to the status page to make clear which parts are not done?



================
Comment at: libcxx/include/sstream:492
+basic_string_view<_CharT, _Traits>
+basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept
+{
----------------
pfusik wrote:
> Mordante wrote:
> > Please format the new code with clang-format so it matches our "normal" style. 
> How do I do that?
You can use git clang-format like `git clang-format-16 HEAD^` this formats the changes in the last commit.


================
Comment at: libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/view.pass.cpp:23
+
+static std::string_view get_view(const std::istringstream& ss) noexcept { return ss.view(); }
+
----------------
Why did you add this helper function?


================
Comment at: libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/view.pass.cpp:24
+static std::string_view get_view(const std::istringstream& ss) noexcept { return ss.view(); }
+
+int main(int, char**) {
----------------
Using something along these lines avoid some code duplication. This also makes it easier to adapt the tests if we can use `basic_stringstream` with other character types like `char8_t`.


================
Comment at: libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/view.pass.cpp:32
+    assert(get_view(ss) == " 789");
+  }
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
----------------
This tests the additional properties of the function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148641/new/

https://reviews.llvm.org/D148641



More information about the libcxx-commits mailing list