class template


template < class charT, class traits = char_traits<charT> >
  class basic_filebuf;
File stream buffer

Stream buffer to read from and write to files.

Constructed without association, these objects are associated to a file by calling member open. Once open, all input/output operations performed on the object are reflected in the associated file.

Objects of this class may internally maintain an intermediate input buffer and/or an intermediate output buffer, where individual characters are read or written by i/o operations. These buffers are synchronized with the contents of the file once filled up, when explicitly requested to do so (sync), or when the object is closed.

Objects of this class may be explicitly made unbuffered by calling member pubsetbuf with both arguments set to zero (see member setbuf): Unbuffered file stream buffers perform the i/o operations directly on the file, without an intermediate buffer.

Access to the associated sequence of characters (i.e., the file) is given to streams by means of the interface offered by the virtual members inherited from basic_streambuf that are overriden in this class:

Template parameters

Character type.
This shall be a non-array POD type.
Aliased as member type basic_filebuf::char_type.
Character traits class that defines essential properties of the characters used by stream objects (see char_traits).
traits::char_type shall be the same as charT.
Aliased as member type basic_filebuf::traits_type.

Template instantiations

These instantiations are declared in <fstream>.

Member types

member typedefinitionnotes
char_typeThe first template parameter (charT)
traits_typeThe second template parameter (traits)defaults to: char_traits<charT>
pos_typetraits_type::pos_typegenerally, the same as streampos
off_typetraits_type::off_typegenerally, the same as streamoff

Public member functions

File association

Public member functions inherited from basic_streambuf

Buffer management and positioning:
Input functions (get):
Output functions (put):

Protected virtual function overrides

The class also inherits other protected members that are non-virtual or not overridden. See base class basic_streambuf for more details.

Non-member function overloads