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

履歴 編集

function
<ranges>

std::ranges::chunk_by_view::end(C++23)

constexpr default_sentinel_t end() const; // (1) C++23

概要

番兵を取得する。

効果

  • (1) : return default_sentinel;

備考

chunk_by_viewは常にdefault_sentinel_tを番兵として使用する。これは、チャンクの境界が動的に決まるため、事前にサイズを計算することができないためである。

#include <ranges>
#include <vector>
#include <functional>
#include <print>

int main() {
  std::vector<int> v = {1, 2, 2, 3, 0, 4, 5, 2};

  std::ranges::chunk_by_view cv{v, std::ranges::less_equal{}};

  // イテレータ範囲で全チャンクを出力
  for (auto it = cv.begin(); it != cv.end(); ++it) {
    std::println("{}", *it);
  }
}

出力

[1, 2, 2, 3]
[0, 4, 5]
[2]

バージョン

言語

  • C++23

処理系

参照