[streambuf.members]

# 31 Input/output library [[input.output]](./#input.output)

## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.members)

### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#members)

#### 31.6.3.3 Public member functions [streambuf.members]

#### [31.6.3.3.1](#streambuf.locales) Locales [[streambuf.locales]](streambuf.locales)

[ð](#lib:pubimbue,basic_streambuf)

`locale pubimbue(const locale& loc);
`

[1](#streambuf.locales-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3183)

*Effects*: Callsimbue(loc)[.](#streambuf.locales-1.sentence-1)

[2](#streambuf.locales-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3188)

*Postconditions*: loc == getloc()[.](#streambuf.locales-2.sentence-1)

[3](#streambuf.locales-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3192)

*Returns*: Previous value ofgetloc()[.](#streambuf.locales-3.sentence-1)

[ð](#lib:getloc,basic_streambuf)

`locale getloc() const;
`

[4](#streambuf.locales-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3204)

*Returns*: Ifpubimbue() has ever been called, then the last value of loc supplied,
otherwise the current global locale,locale(),
in effect at the time of construction[.](#streambuf.locales-4.sentence-1)

If called afterpubimbue() has been called but beforepubimbue has returned (i.e., from within the call ofimbue())
then it returns the previous value[.](#streambuf.locales-4.sentence-2)

#### [31.6.3.3.2](#streambuf.buffer) Buffer management and positioning [[streambuf.buffer]](streambuf.buffer)

[ð](#lib:pubsetbuf,basic_streambuf)

`basic_streambuf* pubsetbuf(char_type* s, streamsize n);
`

[1](#streambuf.buffer-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3229)

*Returns*: setbuf(s, n)[.](#streambuf.buffer-1.sentence-1)

[ð](#lib:pubseekoff,basic_streambuf)

`pos_type pubseekoff(off_type off, ios_base::seekdir way,
                    ios_base::openmode which
                      = ios_base::in | ios_base::out);
`

[2](#streambuf.buffer-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3242)

*Returns*: seekoff(off, way, which)[.](#streambuf.buffer-2.sentence-1)

[ð](#lib:pubseekpos,basic_streambuf)

`pos_type pubseekpos(pos_type sp,
                    ios_base::openmode which
                      = ios_base::in | ios_base::out);
`

[3](#streambuf.buffer-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3255)

*Returns*: seekpos(sp, which)[.](#streambuf.buffer-3.sentence-1)

[ð](#lib:pubsync,basic_streambuf)

`int pubsync();
`

[4](#streambuf.buffer-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3266)

*Returns*: sync()[.](#streambuf.buffer-4.sentence-1)

#### [31.6.3.3.3](#streambuf.pub.get) Get area [[streambuf.pub.get]](streambuf.pub.get)

[ð](#lib:in_avail,basic_streambuf)

`streamsize in_avail();
`

[1](#streambuf.pub.get-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3279)

*Returns*: If a read position is available, returnsegptr() - gptr()[.](#streambuf.pub.get-1.sentence-1)

Otherwise returns[showmanyc()](filebuf.virtuals#lib:basic_streambuf,showmanyc "31.10.3.5 Overridden virtual functions [filebuf.virtuals]")[.](#streambuf.pub.get-1.sentence-2)

[ð](#lib:snextc,basic_streambuf)

`int_type snextc();
`

[2](#streambuf.pub.get-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3293)

*Effects*: Callssbumpc()[.](#streambuf.pub.get-2.sentence-1)

[3](#streambuf.pub.get-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3298)

*Returns*: If that function returnstraits​::​eof(),
returnstraits​::​eof()[.](#streambuf.pub.get-3.sentence-1)

Otherwise, returnssgetc()[.](#streambuf.pub.get-3.sentence-2)

[ð](#lib:sbumpc,basic_streambuf)

`int_type sbumpc();
`

[4](#streambuf.pub.get-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3314)

*Effects*: If the input sequence read position is not available,
returnsuflow()[.](#streambuf.pub.get-4.sentence-1)

Otherwise, returnstraits​::​to_int_type(*gptr()) and increments the next pointer for the input sequence[.](#streambuf.pub.get-4.sentence-2)

[ð](#lib:sgetc,basic_streambuf)

`int_type sgetc();
`

[5](#streambuf.pub.get-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3330)

*Returns*: If the input sequence read position is not available,
returnsunderflow()[.](#streambuf.pub.get-5.sentence-1)

Otherwise, returnstraits​::​to_int_type(*gptr())[.](#streambuf.pub.get-5.sentence-2)

[ð](#lib:sgetn,basic_streambuf)

`streamsize sgetn(char_type* s, streamsize n);
`

[6](#streambuf.pub.get-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3345)

*Returns*: xsgetn(s, n)[.](#streambuf.pub.get-6.sentence-1)

#### [31.6.3.3.4](#streambuf.pub.pback) Putback [[streambuf.pub.pback]](streambuf.pub.pback)

[ð](#lib:sputbackc,basic_streambuf)

`int_type sputbackc(char_type c);
`

[1](#streambuf.pub.pback-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3358)

*Effects*: If the input sequence putback position is not available, or
iftraits​::​eq(c, gptr()[-1]) is false, returnspbackfail(traits​::​to_int_type(c))[.](#streambuf.pub.pback-1.sentence-1)

Otherwise, decrements the next pointer for the input sequence and
returnstraits​::​to_int_type(*gptr())[.](#streambuf.pub.pback-1.sentence-2)

[ð](#lib:sungetc,basic_streambuf)

`int_type sungetc();
`

[2](#streambuf.pub.pback-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3376)

*Effects*: If the input sequence putback position is not available,
returnspbackfail()[.](#streambuf.pub.pback-2.sentence-1)

Otherwise, decrements the next pointer for the input sequence and
returnstraits​::​to_int_type(*gptr())[.](#streambuf.pub.pback-2.sentence-2)

#### [31.6.3.3.5](#streambuf.pub.put) Put area [[streambuf.pub.put]](streambuf.pub.put)

[ð](#lib:sputc,basic_streambuf)

`int_type sputc(char_type c);
`

[1](#streambuf.pub.put-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3394)

*Effects*: If the output sequence write position is not available,
returnsoverflow(traits​::​to_int_type(c))[.](#streambuf.pub.put-1.sentence-1)

Otherwise, stores c at the next pointer for the output sequence,
increments the pointer, and
returnstraits​::​to_int_type(c)[.](#streambuf.pub.put-1.sentence-2)

[ð](#lib:sputn,basic_streambuf)

`streamsize sputn(const char_type* s, streamsize n);
`

[2](#streambuf.pub.put-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3411)

*Returns*: xsputn(s, n)[.](#streambuf.pub.put-2.sentence-1)
