std::basic_streambuf<CharT,Traits>::pbump
来自cppreference.com
<tbody>
</tbody>
protected: void pbump( int count ); |
||
重寻位放置指针(pptr())count 个字符,其中 count 可为正或负。不对将指针移出放置区 [pbase(), epptr()) 做检查。
若指针前进,然后调用 overflow() 冲入放置区到关联字符序列,则效果是输出拥有未定义值的额外 count 个字符。
参数
| count | - | 加到放置指针的数 |
返回值
(无)
注解
因为此函数接收 int,故它无法操纵大于 std::numeric_limits<int>::max() 个字符的缓冲区(LWG 255)。
示例
运行此代码
#include <fstream>
#include <iostream>
#include <string>
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
参阅
| 推进输出序列中的下一位置指针 (受保护成员函数) |