名前空間
変種
操作

std::basic_streambuf<CharT,Traits>::pbump

提供: cppreference.com
< cpp‎ | io‎ | basic streambuf
 
 
 
 
void pbump(int count );

put ポインタ (pptr()) を文字 count 個進めます。 ただし count は正でも負でも構いません。 put 領域 [pbase(), epptr()) の外側へのポインタの移動のチェックは行われません。

ポインタが進められ、その後 put 領域を紐付けられている文字シーケンスにフラッシュするために overflow() が呼ばれた場合、その効果は未定義の値を持つ余分な文字が count 個出力されます。

目次

[編集]引数

count - put ポインタに加算する数値

[編集]戻り値

(なし)

[編集]ノート

この関数は int を取るため、文字 std::numeric_limits<int>::max() 個より大きなバッファは操作できません (LWG 255)。

[編集]

#include <iostream>#include <string>#include <fstream>   struct showput_streambuf :std::filebuf{using std::filebuf::pbump;// expose protectedstd::string showput()const{returnstd::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

[編集]関連項目

入力シーケンスの次ポインタを進めます
(プロテクテッドメンバ関数)[edit]
close