Files
2025-10-25 03:02:53 +03:00

103 lines
3.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[streambuf.virt.buffer]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.virt.buffer)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#virt.buffer)
#### 31.6.3.5 Virtual functions [[streambuf.virtuals]](streambuf.virtuals#streambuf.virt.buffer)
#### 31.6.3.5.2 Buffer management and positioning [streambuf.virt.buffer]
[🔗](#lib:setbuf,basic_streambuf)
`basic_streambuf* setbuf(char_type* s, streamsize n);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3619)
*Effects*: Influences stream buffering in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf.virtuals]](stringbuf.virtuals "31.8.2.5Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3626)
*Default behavior*: Does nothing[.](#2.sentence-1)
Returnsthis[.](#2.sentence-2)
[🔗](#lib:seekoff,basic_streambuf)
`pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3641)
*Effects*: Alters the stream positions within one or more of
the controlled sequences in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf.virtuals]](stringbuf.virtuals "31.8.2.5Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3649)
*Default behavior*: Returnspos_type(off_type(-1))[.](#4.sentence-1)
[🔗](#lib:seekpos,basic_streambuf)
`pos_type seekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3663)
*Effects*: Alters the stream positions within one or more of
the controlled sequences in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf]](stringbuf "31.8.2Class template basic_­stringbuf"), [[filebuf]](filebuf "31.10.3Class template basic_­filebuf"))[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3671)
*Default behavior*: Returnspos_type(off_type(-1))[.](#6.sentence-1)
[🔗](#lib:sync,basic_streambuf)
`int sync();
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3683)
*Effects*: Synchronizes the controlled sequences with the arrays[.](#7.sentence-1)
That is, ifpbase() is non-null the characters betweenpbase() andpptr() are written to the controlled sequence[.](#7.sentence-2)
The pointers may then be reset as appropriate[.](#7.sentence-3)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3695)
*Returns*: -1 on failure[.](#8.sentence-1)
What constitutes failure is determined by each derived class ([[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#8.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3700)
*Default behavior*: Returns zero[.](#9.sentence-1)