GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::strstreambuf::setbuf(3) C++ Standard Libary std::strstreambuf::setbuf(3)

std::strstreambuf::setbuf - std::strstreambuf::setbuf


protected:
virtual streambuf<char>* setbuf(char* 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 deallocate the dynamic member array used as the buffer
and begin using the user-supplied character array of size n, whose first element is
pointed to by s.


This function is protected virtual, it may only be called through pubsetbuf() or
from member functions of a user-defined class derived from std::strstreambuf.


s - pointer to the first byte in the user-provided buffer
n - the number of bytes in the user-provided buffer


this


Implementation test to check if setbuf() is supported on a dynamic strstream (output
obtained with Sun Studio)

// Run this code


#include <strstream>
#include <iostream>


int main()
{
char a[100] = {};
std::strstream str;
str.rdbuf()->pubsetbuf(a, sizeof a);
str << "Test string" << std::ends;
std::cout << "user-provided buffer holds '" << a << "'\n";
}


user-provided buffer holds 'Test string'


pubsetbuf invokes setbuf()
(public member function of std::basic_streambuf<CharT,Traits>)
setbuf replaces the buffer with user-defined array, if permitted
[virtual] (virtual protected member function of std::basic_streambuf<CharT,Traits>)
setbuf attempts to replace the controlled character sequence with an array
[virtual] (virtual protected member function of
std::basic_stringbuf<CharT,Traits,Allocator>)
setbuf provides user-supplied buffer or turns this filebuf unbuffered
[virtual] (virtual protected member function of std::basic_filebuf<CharT,Traits>)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.