std::basic_stringbuf<CharT,Traits,Allocator>::setbuf (3) - Linux Manuals
std::basic_stringbuf<CharT,Traits,Allocator>::setbuf: std::basic_stringbuf<CharT,Traits,Allocator>::setbuf
Command to display std::basic_stringbuf<CharT,Traits,Allocator>::setbuf
manual in Linux: $ man 3 std::basic_stringbuf<CharT,Traits,Allocator>::setbuf
NAME
std::basic_stringbuf<CharT,Traits,Allocator>::setbuf - std::basic_stringbuf<CharT,Traits,Allocator>::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, this function has no effect.
Otherwise, the effect is implementation-defined: some implementations do nothing, while some implementations clear the std::string member currently used as the buffer and begin using the user-supplied character array of size n, whose first element is pointed to by s, as the buffer and the input/output character sequence.
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_stringbuf.
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 deprecated stream buffer std::strstreambuf or the boost.IOStreams device boost::basic_array may be used to implement I/O buffering over a user-provided char array in portable manner.
Example
Test for the stringstream's setbuf functionality
// Run this code
#include <iostream>
#include <sstream>
int main()
{
std::ostringstream ss;
char c[1024] = {};
ss.rdbuf()->pubsetbuf(c, 1024);
ss << 3.14 << '\n';
std::cout << c << '\n';
}
Output:
3.14 (on GNU g++/libstdc++ and SunPro C++/roguewave)
<nothing> (on MS Visual Studio 2010, SunPro C++/stlport4, CLang++/libc++)
See also
invokes setbuf()
pubsetbuf (public member function of std::basic_streambuf<CharT,Traits>)
Pages related to std::basic_stringbuf<CharT,Traits,Allocator>::setbuf
- std::basic_stringbuf<CharT,Traits,Allocator>::seekoff (3) - std::basic_stringbuf<CharT,Traits,Allocator>::seekoff
- std::basic_stringbuf<CharT,Traits,Allocator>::seekpos (3) - std::basic_stringbuf<CharT,Traits,Allocator>::seekpos
- std::basic_stringbuf<CharT,Traits,Allocator>::str (3) - std::basic_stringbuf<CharT,Traits,Allocator>::str
- std::basic_stringbuf<CharT,Traits,Allocator>::swap (3) - std::basic_stringbuf<CharT,Traits,Allocator>::swap
- std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf (3) - std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf
- std::basic_stringbuf<CharT,Traits,Allocator>::operator= (3) - std::basic_stringbuf<CharT,Traits,Allocator>::operator=
- std::basic_stringbuf<CharT,Traits,Allocator>::overflow (3) - std::basic_stringbuf<CharT,Traits,Allocator>::overflow
- std::basic_stringbuf<CharT,Traits,Allocator>::pbackfail (3) - std::basic_stringbuf<CharT,Traits,Allocator>::pbackfail
- std::basic_stringbuf<CharT,Traits,Allocator>::underflow (3) - std::basic_stringbuf<CharT,Traits,Allocator>::underflow
- std::basic_stringbuf (3) - std::basic_stringbuf
- std::basic_string (3) - std::basic_string
- std::basic_string<CharT,Traits,Allocator>::append (3) - std::basic_string<CharT,Traits,Allocator>::append
- std::basic_string<CharT,Traits,Allocator>::assign (3) - std::basic_string<CharT,Traits,Allocator>::assign
- std::basic_string<CharT,Traits,Allocator>::at (3) - std::basic_string<CharT,Traits,Allocator>::at
- std::basic_string<CharT,Traits,Allocator>::back (3) - std::basic_string<CharT,Traits,Allocator>::back
- std::basic_string<CharT,Traits,Allocator>::basic_string (3) - std::basic_string<CharT,Traits,Allocator>::basic_string
- std::basic_string<CharT,Traits,Allocator>::begin, (3) - std::basic_string<CharT,Traits,Allocator>::begin,
- std::basic_string<CharT,Traits,Allocator>::begin,std::basic_string<CharT,Traits,Allocator>::cbegin (3) - std::basic_string<CharT,Traits,Allocator>::begin,std::basic_string<CharT,Traits,Allocator>::cbegin
- std::basic_string<CharT,Traits,Allocator>::c_str (3) - std::basic_string<CharT,Traits,Allocator>::c_str
- std::basic_string<CharT,Traits,Allocator>::capacity (3) - std::basic_string<CharT,Traits,Allocator>::capacity
- std::basic_string<CharT,Traits,Allocator>::clear (3) - std::basic_string<CharT,Traits,Allocator>::clear