std::basic_filebuf<CharT,Traits>::setbuf (3) - Linux Manuals
std::basic_filebuf<CharT,Traits>::setbuf: std::basic_filebuf<CharT,Traits>::setbuf
NAME
std::basic_filebuf<CharT,Traits>::setbuf - std::basic_filebuf<CharT,Traits>::setbuf
Synopsis
protected:
virtual std::basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n )
If s is a null pointer and n is zero, the filebuf becomes unbuffered for output, meaning pbase() and pptr() are null and any output is immediately sent to file.
Otherwise, a call to setbuf() replaces the internal buffer (the controlled character sequence) with the user-supplied character array whose first element is pointed to by s and allows this std::basic_filebuf object to use up to n bytes in that array for buffering.
This function is protected virtual, it may only be called through pubsetbuf() or from member functions of a user-defined class derived from std::basic_filebuf.
Parameters
s - pointer to the first CharT in the user-provided buffer or null
n - the number of CharT elements in the user-provided buffer or zero
Return value
this.
Notes
The conditions when this function may be used and the way in which the provided buffer is used is implementation-defined.
* GCC 4.6 libstdc++
* Clang++3.0 libc++
* Visual Studio 2010
The standard does not define any behavior for this function except that setbuf(0, 0) called before any I/O has taken place is required to set unbuffered output.
Example
provide a 10k buffer for reading. On linux, the strace utility may be used to observe the actual number of bytes read
// Run this code
See also
pubsetbuf (public member function of std::basic_streambuf<CharT,Traits>)
setvbuf (function)