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::basic_streambuf::setp(3) C++ Standard Libary std::basic_streambuf::setp(3)

std::basic_streambuf::setp - std::basic_streambuf::setp


protected:
void setp( char_type* pbeg, char_type* pend );


Sets the values of the pointers defining the put area. Specifically, after the call
pbase() == pbeg, pptr() == pbeg, epptr() == pend


pbeg - pointer to the new beginning of the put area
pend - pointer to the new end of the put area


(none)

// Run this code


#include <iostream>
#include <array>


// Buffer for std::ostream implemented by std::array
template<std::size_t SIZE, class CharT = char>
class ArrayedStreamBuffer : public std::basic_streambuf<CharT>
{
public:
using Base = std::basic_streambuf<CharT>;
using char_type = typename Base::char_type;


ArrayedStreamBuffer() : buffer_{} // value-initialize buffer_ to all zeroes
{
Base::setp(buffer_.begin(), buffer_.end()); // set std::basic_streambuf
// put area pointers to work with 'buffer_'
}


void print_buffer()
{
for (const auto& i: buffer_) {
if (i == 0) {
std::cout << "\\0";
} else {
std::cout << i;
}
std::cout << ' ';
}
std::cout << '\n';
}


private:
std::array<char_type, SIZE> buffer_;
};


int main()
{
ArrayedStreamBuffer<10> streambuf;
std::ostream stream(&streambuf);


stream << "hello";
stream << ",";


streambuf.print_buffer();
}


h e l l o , \0 \0 \0 \0


setg repositions the beginning, next, and end pointers of the input sequence
(protected member function)

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.