29 Input/output library [input.output]

29.9 Span-based streams [span.streams]

29.9.3 Class template spanbuf [spanbuf]

29.9.3.5 Overridden virtual functions [spanbuf.virtuals]

[Note 1:
Because the underlying buffer is of fixed size, neither overflow, underflow, nor pbackfail can provide useful behavior.
— end note]
pos_type seekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out) override;
Effects: Alters the stream position within one or both of the controlled sequences, if possible, as follows:
  • If ios_­base​::​in is set in which, positions the input sequence; xnext is gptr(), xbeg is eback().
  • If ios_­base​::​out is set in which, positions the output sequence; xnext is pptr(), xbeg is pbase().
If both ios_­base​::​in and ios_­base​::​out are set in which and way is ios_­base​::​cur, the positioning operation fails.
For a sequence to be positioned, if its next pointer xnext (either gptr() or pptr()) is a null pointer and the new offset newoff as computed below is nonzero, the positioning operation fails.
Otherwise, the function determines baseoff as a value of type off_­type as follows:
  • 0 when way is ios_­base​::​beg;
  • (pptr() - pbase()) for the output sequence, or (gptr() - eback()) for the input sequence when way is ios_­base​::​cur;
  • when way is ios_­base​::​end :
    • (pptr() - pbase()) if ios_­base​::​out is set in mode and ios_­base​::​in is not set in mode,
    • buf.size() otherwise.
If would overflow, or if is less than zero, or if is greater than buf.size(), the positioning operation fails.
Otherwise, the function computes off_type newoff = baseoff + off; and assigns xbeg + newoff to the next pointer xnext.
Returns: pos_­type(off_­type(-1)) if the positioning operation fails; pos_­type(newoff) otherwise.
pos_type seekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out) override;
Effects: Equivalent to: return seekoff(off_type(sp), ios_base::beg, which);
basic_streambuf<charT, traits>* setbuf(charT* s, streamsize n) override;
Effects: Equivalent to: this->span(std::span<charT>(s, n)); return this;