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

履歴 編集

function
<ranges>

std::ranges::basic_istream_view::begin(C++20)

constexpr auto begin(); // (1) C++20

概要

ストリームから値を1つ読み、それを指すイテレータを取得する。

効果

以下と等価:

*stream_ >> value_;
return iterator{*this};

#include <ranges>
#include <sstream>
#include <iostream>

int main() {
  auto iss = std::istringstream{"1 2 3 4 5"};
  auto r = std::views::istream<int>(iss);
  auto it = r.begin();
  std::cout << *it << std::endl;
}

出力

1

バージョン

言語

  • C++20

処理系