streambuf::setbuf | virtual protected member function |
streambuf * setbuf ( char * s, streamsize n ); |
Set buffer
This member is called to set a new buffer for the streambuf object. The public member function pubsetbuf calls this protected member function to perform this action.
This is a virtual member function that shall be redefined in derived classes to behave as expected by setting the array of n characters pointed by s as the new character buffer. Its default behavior in streambuf is to do nothing and return a reference to the object (this), but it is redefined in both standard derived class, filebuf and stringbuf, to behave as expected specifically for each type of buffer (see filebuf::setbuf and stringbuf::setbuf).
Parameters
- s
- Pointer to an array of n characters already allocated in memory. If this parameter is a null pointer, the stream shall be unbuffered.
- n
- Length in characters of the buffer pointed by s.
This is an integer value of type streamsize.
Return Value
In case of success, the member function should return the pointer this, otherwise a null pointer.Basic template member declaration
( basic_streambuf<charT,traits> )
typedef charT char_type;
basic_streambuf* setbuf ( char_type* s, streamsize n );
|
See also
streambuf::pubsetbuf | Set buffer array (public member function) |