[streambuf.general]

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

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

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

#### 31.6.3.1 General [streambuf.general]

[ð](#lib:basic_streambuf)

namespace std {template<class charT, class traits = char_traits<charT>>class basic_streambuf {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; virtual ~basic_streambuf(); // [[streambuf.locales]](streambuf.locales "31.6.3.3.1 Locales"), locales locale pubimbue(const locale& loc);
 locale getloc() const; // [[streambuf.buffer]](streambuf.buffer "31.6.3.3.2 Buffer management and positioning"), buffer and positioning basic_streambuf* pubsetbuf(char_type* s, streamsize n);
 pos_type pubseekoff(off_type off, ios_base::seekdir way,
 ios_base::openmode which = ios_base::in | ios_base::out);
 pos_type pubseekpos(pos_type sp,
 ios_base::openmode which = ios_base::in | ios_base::out); int pubsync(); // get and put areas// [[streambuf.pub.get]](streambuf.pub.get "31.6.3.3.3 Get area"), get area streamsize in_avail();
 int_type snextc();
 int_type sbumpc();
 int_type sgetc();
 streamsize sgetn(char_type* s, streamsize n); // [[streambuf.pub.pback]](streambuf.pub.pback "31.6.3.3.4 Putback"), putback int_type sputbackc(char_type c);
 int_type sungetc(); // [[streambuf.pub.put]](streambuf.pub.put "31.6.3.3.5 Put area"), put area int_type sputc(char_type c);
 streamsize sputn(const char_type* s, streamsize n); protected: basic_streambuf();
 basic_streambuf(const basic_streambuf& rhs);
 basic_streambuf& operator=(const basic_streambuf& rhs); void swap(basic_streambuf& rhs); // [[streambuf.get.area]](streambuf.get.area "31.6.3.4.2 Get area access"), get area access char_type* eback() const;
 char_type* gptr() const;
 char_type* egptr() const; void gbump(int n); void setg(char_type* gbeg, char_type* gnext, char_type* gend); // [[streambuf.put.area]](streambuf.put.area "31.6.3.4.3 Put area access"), put area access char_type* pbase() const;
 char_type* pptr() const;
 char_type* epptr() const; void pbump(int n); void setp(char_type* pbeg, char_type* pend); // [[streambuf.virtuals]](streambuf.virtuals "31.6.3.5 Virtual functions"), virtual functions// [[streambuf.virt.locales]](streambuf.virt.locales "31.6.3.5.1 Locales"), localesvirtual void imbue(const locale& loc); // [[streambuf.virt.buffer]](streambuf.virt.buffer "31.6.3.5.2 Buffer management and positioning"), buffer management and positioningvirtual basic_streambuf* setbuf(char_type* s, streamsize n); virtual pos_type seekoff(off_type off, ios_base::seekdir way,
 ios_base::openmode which = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type sp,
 ios_base::openmode which = ios_base::in | ios_base::out); virtual int sync(); // [[streambuf.virt.get]](streambuf.virt.get "31.6.3.5.3 Get area"), get areavirtual streamsize showmanyc(); virtual streamsize xsgetn(char_type* s, streamsize n); virtual int_type underflow(); virtual int_type uflow(); // [[streambuf.virt.pback]](streambuf.virt.pback "31.6.3.5.4 Putback"), putbackvirtual int_type pbackfail(int_type c = traits::eof()); // [[streambuf.virt.put]](streambuf.virt.put "31.6.3.5.5 Put area"), put areavirtual streamsize xsputn(const char_type* s, streamsize n); virtual int_type overflow(int_type c = traits::eof()); };}

[1](#1)

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

The class templatebasic_streambuf serves as a base class for deriving various[*stream buffers*](#def:stream_buffers) whose objects each control two[*character sequences*](#def:character_sequences):

- [(1.1)](#1.1)

a character[*input sequence*](#def:input_sequence);

- [(1.2)](#1.2)

a character[*output sequence*](#def:output_sequence)[.](#1.sentence-1)
