FreeBSD Manual Pages
std::basic_...buf::setbuf(3) C++ Standard Libary std::basic_...buf::setbuf(3) NAME std::basic_stringbuf::setbuf - std::basic_stringbuf::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 implementa- tions 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 se- quence. This function is protected virtual, it may only be called through pubsetbuf() or from member functions of a user-defined class derived from std::ba- sic_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 pubsetbuf invokes setbuf() (public member function of std::basic_stream- buf<CharT,Traits>) http://cppreference.com 2022.07.31 std::basic_...buf::setbuf(3)
NAME | Synopsis | Parameters | Return value | Notes | Example | Output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::basic_stringbuf::setbuf&sektion=3&manpath=FreeBSD+Ports+15.0>
