首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::basic_streambuf::pbump

void pbump( int count );

?

?

重新定位放置指针%28pptr()29%count人物,在哪里count可能是积极的,也可能是消极的。不检查指针是否移出PUT区域。[pbase(), epptr())...

如果指针是高级的,则overflow()调用,将PUT区域刷新为关联的字符序列,其效果是额外的count输出未定义值的字符。

参数

count

-

number to add to the put pointer

返回值

%280%29

二次

代码语言:javascript
复制
#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';
}

二次

产出:

二次

代码语言:javascript
复制
The put area contains: 1234
after pbump(10), it contains 1234 is a test

二次

另见

gbump

advances the next pointer in the input sequence (protected member function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com