std::basic_streambuf<CharT,Traits>::pbump
From cppreference.com
< cpp | io | basic streambuf
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Input/output library
Print functions (C++23)
Buffers
(C++23)
(C++98/26*)
(C++20)
Streams
Abstractions
File I/O
String I/O
Array I/O
(C++23)
(C++23)
(C++23)
(C++98/26*)
(C++98/26*)
(C++98/26*)
Synchronized Output
(C++20)
Types
Error category interface
(C++11)
(C++11)
std::basic_streambuf
Public member functions
Locales
Positioning
Get area
Put area
Putback
Protected member functions
(C++11)
(C++11)
Locales
Positioning
Get area
Put area
basic_streambuf::pbump
Putback
protected:
void pbump( int count );
void pbump( int count );
Repositions the put pointer (pptr() ) 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 overflow() 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
[edit] Parameters
count
-
number to add to the put pointer
[edit] Return value
(none)
[edit] Notes
Because this function takes an int, it cannot manipulate buffers larger than std::numeric_limits <int>::max() characters (LWG issue 255).
[edit] Example
Run this code
#include <fstream> #include <iostream> #include <string> 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