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

履歴 編集

function
<iterator>

std::istreambuf_iterator::operator++

istreambuf_iterator<CharT, Traits>& operator++();
proxy operator++(int);

概要

イテレータを進める

効果

前置インクリメント: sbuf_->sbumpc(); return *this;

後置インクリメント: sbuf->sbumpc()を行い、前の状態をproxyオブジェクトとして返す。 proxyクラスは実装定義

sbuf_は、メンバ変数として保持しているstreambuf_typeオブジェクトへのポインタ

#include <iostream>
#include <iterator>
#include <sstream>

int main()
{
  std::stringstream ss;
  ss << "123";

  std::istreambuf_iterator<char> it(ss);

  ++it; // 前置インクリメント
  std::cout << *it << std::endl;
  std::cout << *(it++) << std::endl; // 後置インクリメント
  std::cout << *it << std::endl;
}

出力

2
2
3

参照