[spanbuf.virtuals] # 31 Input/output library [[input.output]](./#input.output) ## 31.9 Span-based streams [[span.streams]](span.streams#spanbuf.virtuals) ### 31.9.3 Class template basic_spanbuf [[spanbuf]](spanbuf#virtuals) #### 31.9.3.5 Overridden virtual functions [spanbuf.virtuals] [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10292) [*Note [1](#note-1)*: Because the underlying buffer is of fixed size, neither overflow, underflow, nor pbackfail can provide useful behavior[.](#1.sentence-1) — *end note*] [🔗](#lib:seekoff,basic_spanbuf) `pos_type seekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out) override; ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10306) *Effects*: Alters the stream position within one or both of the controlled sequences, if possible, as follows: - [(2.1)](#2.1) If ios_base​::​in is set in which, positions the input sequence;xnext is gptr(), xbeg is eback()[.](#2.1.sentence-1) - [(2.2)](#2.2) If ios_base​::​out is set in which, positions the output sequence;xnext is pptr(), xbeg is pbase()[.](#2.2.sentence-1) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10319) If both ios_base​::​in and ios_base​::​out are set in which and way is ios_base​::​cur, the positioning operation fails[.](#3.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10324) 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[.](#4.sentence-1) Otherwise, the function determines baseoff as a value of type off_type as follows: - [(4.1)](#4.1) 0 when way is ios_base​::​beg; - [(4.2)](#4.2) (pptr() - pbase()) for the output sequence, or(gptr() - eback()) for the input sequence when way is ios_base​::​cur; - [(4.3)](#4.3) when way is ios_base​::​end : * [(4.3.1)](#4.3.1) (pptr() - pbase()) if ios_base​::​out is set in *mode* andios_base​::​in is not set in *mode*, * [(4.3.2)](#4.3.2) *buf*.size() otherwise[.](#4.sentence-2) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10351) 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[.](#5.sentence-1) Otherwise, the function computesoff_type newoff = baseoff + off; and assigns xbeg + newoff to the next pointer xnext[.](#5.sentence-2) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10362) *Returns*: pos_type(off_type(-1)) if the positioning operation fails;pos_type(newoff) otherwise[.](#6.sentence-1) [🔗](#lib:seekpos,basic_spanbuf) `pos_type seekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out) override; ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10374) *Effects*: Equivalent to:return seekoff(off_type(sp), ios_base::beg, which); [🔗](#lib:setbuf,basic_spanbuf) `basic_streambuf* setbuf(charT* s, streamsize n) override; ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10388) *Effects*: Equivalent to:this->span(std::span(s, n));return this;