Skip to content

Latest commit

 

History

History
79 lines (58 loc) · 1.85 KB

File metadata and controls

79 lines (58 loc) · 1.85 KB

end

  • ranges[meta header]
  • std::ranges[meta namespace]
  • adjacent_transform_view[meta class]
  • function[meta id-type]
  • cpp23[meta cpp]
constexpr auto end();      // (1) C++23

constexpr auto end() const
  requires range<const InnerView> &&
           regular_invocable<const F&, REPEAT(range_reference_t<const V>, N)...>; // (2) C++23
  • REPEAT[italic]

概要

番兵を取得する。

効果

common_range<InnerView>trueの場合:

  • (1) : return iterator<false>(*this, inner_.end());
  • (2) : return iterator<true>(*this, inner_.end());

それ以外の場合:

  • (1) : return sentinel<false>(inner_.end());
  • (2) : return sentinel<true>(inner_.end());

ここで、iteratorsentineladjacent_transform_viewの内部で定義される説明専用のクラスであり、InnerViewは説明専用のadjacent_view<V, N>である。

備考

  • REPEAT(T, N) をT型のN個のパックとする。

#include <ranges>
#include <vector>
#include <iostream>

int main() {
  std::vector<int> v = {1, 2, 3, 4, 5};
  
  auto diff = [](int x, int y) { return y - x; };
  std::ranges::adjacent_transform_view<std::views::all_t<std::vector<int>&>, decltype(diff), 2> atv(v, diff);
  
  auto begin = atv.begin();
  auto end = atv.end();
  
  // 全要素を出力
  for (auto it = begin; it != end; ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
  • end[color ff0000]
  • begin[link begin.md]

出力

1 1 1 1 

バージョン

言語

  • C++23

処理系

参照