Namespaces
Variants
Views
Actions

std::basic_streambuf::pbump

From cppreference.com
< cpp‎ | io‎ | basic streambuf
Revision as of 19:13, 2 November 2012 by P12bot (Talk | contribs)

 
 
 
 
void pbump( int count );

Repositions the put pointer (Template:rlpf) by count characters, where count may be positive or negative. No checks are done for moving the pointer outside the put area [pbase(), epptr()).

If the pointer is advanced and then Template:rlpf is called to flush the put area to the associated character sequence, the effect is that extra count characters with undefined values are output.

Contents

Parameters

count - number to add to the put pointer

Return value

(none)

Example

#include <iostream>
#include <string>
#include <fstream>
 
struct showput_streambuf : std::filebuf
{
    using std::filebuf::pbump; // expose protected
    std::string showput() const {
        return std::string(pbase(), pptr());
    }
};
 
int main()
{
    showput_streambuf mybuf;
    mybuf.open("test.txt", std::ios_base::out);
    std::ostream str(&mybuf);
    str << "This is a test" << std::flush << "1234";
    std::cout << "The put area contains: " << mybuf.showput() << '\n';
    mybuf.pbump(10);
    std::cout << "after pbump(10), it contains " << mybuf.showput() << '\n';
}

Output:

The put area contains: 1234
after pbump(10), it contains 1234 is a test

See also

Template:cpp/io/basic streambuf/dcl list gbump