std::basic_spanbuf::setbuf(3)

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

std::basic_spanbuf::setbuf(3) πŸ’…

okay so this is the C++ Standard Libary manual page for std::basic_spanbuf::setbuf β€” and yes bestie, the header spells it β€œLibary,” we’re keeping that exactly as-is, no editing the icon.


🌸 NAME

std::basic_spanbuf::setbuf β€” std::basic_spanbuf::setbuf. That’s the whole NAME section, no cap.


✨ Synopsis ✨

protected:
std::basic_streambuf<CharT, Traits>* setbuf( CharT *s,
std::streamsize n ) override;

(since C++23) β€” bestie, this one is new new.

Makes the basic_spanbuf perform I/O on the buffer [s, s + n). Equivalently calls this->span(std::span<CharT>(s, n)) and then returns this.

Here’s the pointer vibe check:

  • Set bits in open mode (affecting pointers to get area): std::ios_base::in
    • Return value after setting eback(): s
    • Return value after setting gptr(): s
    • Return value after setting egptr(): s + n
  • Set bits in open mode (affecting pointers to put area): std::ios_base::out && !std::ios_base::ate
    • Return value after setting pbase(): s
    • Return value after setting pptr(): s
    • Return value after setting epptr(): s + n
  • Set bits in open mode (affecting pointers to put area): std::ios_base::out && std::ios_base::ate
    • Return value after setting pbase(): s
    • Return value after setting pptr(): s + n
    • Return value after setting epptr(): s + n

This function is protected virtual, it may only be called through pubsetbuf() or from member functions of a user-defined class derived from std::basic_spanbuf.


πŸŽ€ Parameters

  • s β€” pointer to the first CharT in the user-provided buffer.
  • n β€” the number of CharT elements in the user-provided buffer.

🌈 Return value

this β€” that’s it, that’s the return value, periodt.


πŸ¦‹ Notes

The deprecated stream buffer std::strstreambuf or the boost.IOStreams device boost::basic_array can also implement I/O buffering over a user-provided char array.


πŸ§ͺ Example

This section is incomplete β€” Reason: no example. Not me showing up with zero example πŸ’€


πŸ‘€ See also

  • pubsetbuf invokes setbuf() β€” public member function of std::basic_streambuf<CharT,Traits>.
  • setbuf attempts to replace the controlled character sequence with an array [virtual] β€” virtual protected member function of std::basic_stringbuf<CharT,Traits,Allocator>.
  • setbuf attempts to replace the controlled character sequence with an array [virtual] β€” virtual protected member function of std::strstreambuf.

🏷️ Category

* Todo no example


source/version: cppreference.com; date: 2024.06.10 β€” mwah, go slay those buffers, bestie πŸ’‹βœ¨

πŸ“¦ where this page comes from