std::basic_streambuf<CharT,Traits>::pbump
来自cppreference.com
< cpp | io | basic streambuf
输入/输出库
std::basic_streambuf
公开成员函数 | ||||
本地环境 | ||||
寻位 | ||||
获取区 | ||||
放置区 | ||||
回放 | ||||
受保护成员函数 | ||||
(C++11)
|
||||
(C++11)
|
||||
本地环境 | ||||
寻位 | ||||
获取区 | ||||
放置区 | ||||
basic_streambuf::pbump
|
||||
回放 | ||||
void pbump( int count );
|
||
重寻位放置指针( pptr() ) count
个字符,其中
count
可为正或负。不对将指针移出放置区 [pbase(), epptr())
做检查。
若指针前进,然后调用 overflow()
冲入放置区到关联字符序列,则效果是输出拥有未定义值的额外 count
个字符。
参数
count | - | 加到放置指针的数 |
返回值
(无)
注意
因为此函数接收 int
,故它无法操纵大于 std::numeric_limits<int>::max()
字符的缓冲区( LWG 255 )。
示例
运行此代码
#include <iostream> #include <string> #include <fstream> struct showput_streambuf : std::filebuf { using std::filebuf::pbump; // 暴露受保护函数 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'; }
输出:
The put area contains: 1234 after pbump(10), it contains 1234 is a test
参阅
令输出序列中的下一位置指针前进 (受保护成员函数) |