std::basic_stringbuf::view(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… std::basic_stringbuf::view(3) πŸ’…

🌸 NAME 🌸

std::basic_stringbuf::view β€” std::basic_stringbuf::view

Okay bestie, welcome to the C++ Standard Libary page for std::basic_stringbuf::view β€” yes, that manual name is spelled β€œLibary” in the header, and we are respecting the typo. πŸ’–

πŸ¦‹ Synopsis πŸ¦‹

std::basic_string_view<CharT, Traits> view() const noexcept;  (since
C++20)

This creates and returns a std::basic_string_view over the underlying character sequence. Slay. ✨

  • For input-only streams, the returned view represents the range [eback(), egptr()).
  • For input/output or output-only streams, it references the characters from pbase() to the last character in the sequence regardless of egptr() and epptr().
  • If the stream is neither input nor output, it returns std::basic_string_view<CharT, Traits>{}.

The member character sequence in a buffer open for writing can be over-allocated for efficiency purposes. In that case, only the initialized characters are referenced: these characters are the ones that were obtained from the string argument of the constructor, the string argument used by the most recent call to a setter overload of str(), or from a write operation. A typical implementation that uses over-allocation maintains a high-watermark pointer to track the end of the initialized part of the buffer and the returned view references the characters from pbase() to the high-watermark pointer. Iconic implementation detail, honestly. 🌈

πŸ“ Parameters πŸ“

(none) β€” literally none, bestie. 🫢

✨ Return value ✨

A view over the underlying character sequence. That's the whole vibe. πŸ’…

πŸ’œ Notes πŸ’œ

Using the return value is undefined behavior if the underlying character sequence is destroyed or invalidated, unless the return value is empty. Not a drill β€” undefined behavior is giving β€œdo not touch” energy. πŸ’€

This function is typically accessed through std::basic_istringstream::view(), std::basic_ostringstream::view(), or std::basic_stringstream::view().

πŸ‘‘ See also πŸ‘‘

  • str β€” replaces or obtains a copy of the associated character string (public member function).
  • operator basic_string_view (C++17) β€” returns a non-modifiable string_view into the entire string (public member function of std::basic_string<CharT,Traits,Allocator>).

Cute sign-off: source/version/date served with sparkle β€” http://cppreference.com, 2024.06.10, and the page tag std::basic_stringbuf::view(3). Mwah, bye bestie! πŸŽ€πŸ’‹

πŸ“¦ where this page comes from