Files
cppdraft_translate/cppdraft/spanbuf/virtuals.md
2025-10-25 03:02:53 +03:00

3.6 KiB
Raw Blame History

[spanbuf.virtuals]

31 Input/output library [input.output]

31.9 Span-based streams [span.streams]

31.9.3 Class template basic_spanbuf [spanbuf]

31.9.3.5 Overridden virtual functions [spanbuf.virtuals]

1

#

[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;

2

#

Effects: Alters the stream position within one or both of the controlled sequences, if possible, as follows:

  • (2.1)

    If ios_base::in is set in which, positions the input sequence;xnext is gptr(), xbeg is eback().

  • (2.2)

    If ios_base::out is set in which, positions the output sequence;xnext is pptr(), xbeg is pbase().

3

#

If both ios_base::in and ios_base::out are set in which and way is ios_base::cur, the positioning operation fails.

4

#

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 andios_base::in is not set in mode,

buf.size() otherwise.

5

#

If baseoff+off would overflow, or if baseoff+off is less than zero, or if baseoff+off is greater than buf.size(), the positioning operation fails.

Otherwise, the function computesoff_type newoff = baseoff + off; and assigns xbeg + newoff to the next pointer xnext.

6

#

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;

7

#

Effects: Equivalent to:return seekoff(off_type(sp), ios_base::beg, which);

🔗

basic_streambuf<charT, traits>* setbuf(charT* s, streamsize n) override;

8

#

Effects: Equivalent to:this->span(std::span(s, n));return this;