std::basic_...asic_spanbuf(3)

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

🌸 NAME 🌸

okay bestie, this is the constructor page for std::basic_spanbuf::basic_spanbuf, from the C++ Standard Library manual (the std::basic_...asic_spanbuf(3) page). It’s giving β€œhow do I build a basic_spanbuf?” energy, and honestly? iconic. πŸ’…


✨ Synopsis ✨

// (1) (since C++23)
basic_spanbuf() : basic_spanbuf(std::ios_base::in | std::ios_base::out) {}

// (2) (since C++23)
explicit basic_spanbuf( std::ios_base::openmode which )
    : basic_spanbuf(std::span<CharT>{}, which) {}

// (3) (since C++23)
explicit basic_spanbuf( std::span<CharT> buf,
                        std::ios_base::openmode which = std::ios_base::in | std::ios_base::out );

// (4) (since C++23)
basic_spanbuf( const basic_spanbuf& ) = delete;

// (5) (since C++23)
basic_spanbuf( basic_spanbuf&& rhs );

πŸŽ€ What each overload does πŸŽ€

  1. Overload (1) β€” default constructor. Creates a basic_spanbuf that has no underlying buffer and is opened for both input and output. The pointers to get and put area are set to the null pointer value. 🫢
  2. Overload (2) β€” same as (1), except the basic_spanbuf is opened in the mode specified by which.
  3. Overload (3) β€” creates a basic_spanbuf that manages the underlying buffer referenced by buf (or has no underlying buffer if buf is empty) and is opened in the mode specified by which. The pointers to get and put area are set as follows, or to the null pointer value if not mentioned in the table:

Get area pointers β€” set bits in open mode (affecting pointers to get area), return value after setting:

  • std::ios_base::in β€” eback() = s.data(), gptr() = s.data(), egptr() = s.data() + s.size()

Put area pointers β€” set bits in open mode (affecting pointers to put area), return value after setting:

  • std::ios_base::out && !std::ios_base::ate β€” pbase() = s.data(), pptr() = s.data(), epptr() = s.data() + s.size()
  • std::ios_base::out && std::ios_base::ate β€” pbase() = s.data(), pptr() = s.data() + s.size(), epptr() = s.data() + s.size()
  1. Overload (4) β€” copy constructor is deleted. basic_spanbuf is not copyable. no cap.
  2. Overload (5) β€” move constructor. Move-constructs the std::basic_streambuf base subobject from that of rhs. The pointers to get and put area, the open mode, and the underlying buffer (if any) are identical to those in rhs before construction. It is implementation-defined whether rhs still holds the underlying buffer after the move-construction. highkey important.

πŸŽ€ Parameters πŸŽ€

  • buf β€” a std::span referencing the underlying buffer. 🌸
  • rhs β€” another basic_spanbuf. πŸ¦‹
  • which β€” specifies stream open mode. It is a bitmask type, and the following constants are defined: πŸ‘‘
    • app β€” seek to the end of stream before each write
    • binary β€” open in binary mode
    • in β€” open for reading
    • out β€” open for writing
    • trunc β€” discard the contents of the stream when opening
    • ate β€” seek to the end of stream immediately after open
    • noreplace (C++23) β€” open in exclusive mode

🌈 Notes 🌈

These constructors are typically called by the constructors of std::basic_ispanstream, std::basic_ospanstream, and std::basic_spanstream. main character energy, fr fr. πŸ‘‘


πŸ¦‹ Example πŸ¦‹

This section is incomplete. Reason: no example. 😭

πŸ‘‘ See also πŸ‘‘

  • constructor β€” constructs the basic_ispanstream (C++23) (public member function of std::basic_ispanstream<CharT,Traits>)
  • constructor β€” constructs the basic_ospanstream (C++23) (public member function of std::basic_ospanstream<CharT,Traits>)
  • constructor β€” constructs the basic_spanstream (C++23) (public member function of std::basic_spanstream<CharT,Traits>)

πŸ“ Category πŸ“

  • Todo no example

source/version/date: http://cppreference.com, 2024.06.10 β€” page std::basic_...asic_spanbuf(3), byeee bestie, go construct something iconic πŸ’–πŸ«Ά

πŸ“¦ where this page comes from