Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 1.23 KB

File metadata and controls

59 lines (44 loc) · 1.23 KB

begin

  • ranges[meta header]
  • std::ranges[meta namespace]
  • concat_view[meta class]
  • function[meta id-type]
  • cpp26[meta cpp]
constexpr auto begin()
  requires (!simple-view<Views> || ...);       // (1) C++26

constexpr auto begin() const
  requires (range<const Views> && ...);        // (2) C++26

概要

viewの先頭要素を指すイテレータを取得する。

戻り値

  • (1), (2) : concat_viewの先頭を指すイテレータを返す。連結されたRangeが空でない場合、最初の非空Rangeの先頭要素を指す。すべてのRangeが空の場合、end()と等価なイテレータを返す。

#include <print>
#include <ranges>
#include <array>
#include <vector>

int main() {
  std::vector<int> v1{1, 2, 3};
  std::vector<int> v2{4, 5};
  std::array<int, 3> a{6, 7, 8};

  std::ranges::concat_view r{v1, v2, a};

  auto it = r.begin();
  
  int x = *it;
  std::println("{}", x);
}
  • begin[color ff0000]

出力

1

バージョン

言語

  • C++26

処理系

  • Clang: 20 [mark noimpl]
  • GCC: 15 [mark verified]
  • Visual C++: 2022 Update 14 [mark noimpl]