最終更新日時(UTC):
が更新

履歴 編集

function
<streambuf>

std::basic_streambuf::pbump

namespace std {
  template<class CharT, class Traits = char_traits<CharT>>
  class basic_streambuf {
  protected:
    void pbump(int n);

    ……
  };
}

概要

出力部分列の現在位置を指定した量だけ進める。

効果

出力部分列の現在位置をnだけ進める。

#include <iostream>
#include <streambuf>

// streambufを継承したクラス
class dummy_buf : public std::streambuf {
public:
    dummy_buf(char* begin, char* end) {
        // 出力列の領域を指定
        setp(begin, end);
    }
    void pbump(int n) {
        // ベースクラスのpbump()を呼ぶ
        return std::streambuf::pbump(n);
    }
};

int main(void) {
    char space[10] = {};
    dummy_buf buf{space, space + 10};
    buf.pbump(2);  // 現在位置を2つ進める
    buf.sputc('A');  // 1文字書き込む
    std::cout << space[2] << std::endl;  // [2]に書き込まれた
}

出力

A

バージョン

言語

  • C++98