std::basic_filebuf<CharT,Traits>::overflow - cppreference.com

From cppreference.com

protected:virtualint_typeoverflow(int_typech=Traits::eof());Writes some data from the put area to the associated character sequence (to the file).

Behaves like the base class version

std::basic_streambuf::overflow()

, except that the behavior of “consuming characters” is defined as follows:

1) First, uses

std::codecvt::out

of the imbued locale to convert the characters into external (possibly multibyte) representation, stored in a temporary buffer, as follows: (XSIZE is some unspecified buffer size)

conststd::codecvt<CharT,char,typenameTraits::state_type>&a_codecvt=std::use_facet<std::codecvt<CharT,char,typenameTraits::state_type>>(getloc());typenameTraits::state_typestate;CharT*end;charxbuf[XSIZE];char*xbuf_end;std::codecvt_base::resultr=a_codecvt.out(state,pbase(),pptr(),end,xbuf,xbuf+XSIZE,xbuf_end);2) Then writes all fully-converted characters from the buffer into the file. Formally, performs the following steps based on the value of r:

rOperation std::codecvt_base::okOutput characters in [xbuf, xbuf_end) to the file, and fail if output fails. At this point if pbase()!=pptr() and pbase()==end are both true (which means xbuf is not large enough for even one external character), then increase XSIZE and repeat from the beginning. std::codecvt_base::partialOutput the converted external characters in [xbuf, xbuf_end) to the file, and repeat using the remaining unconverted internal characters in [end, pptr()). If output fails, fail (without repeating). std::codecvt_base::noconvOutput characters in [pbase(), pptr()) to the file. std::codecvt_base::errorFail. If the associated file is not open (

is_open()

returns false), output will always fail.

Parameters

ch - the character to store in the put area Return value

Traits::not_eof(ch) to indicate success or Traits::eof() to indicate failure.

Notes

If a_codecvt.always_noconv() returns true, the call to a_codecvt.out() may be skipped.

Example

See also

[virtual]

writes characters to the associated output sequence from the put area
(virtual protected member function of std::basic_streambuf<CharT,Traits>)

[edit]

[virtual]

reads from the associated file
(virtual protected member function)

[edit]