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

履歴 編集

function
<ranges>

std::ranges::subrange::size(C++20)

constexpr make-unsigned-like-t<iter_difference_t<I>> size() const
  requires (K == subrange_kind::sized);

概要

subrangeの大きさを取得する。

この関数は、subrangesizedのときのみオーバーロード解決に参加する。

効果

#include <ranges>
#include <iostream>

int main()
{
  constexpr int a[] = {1, 2, 3};
  const std::ranges::subrange sub1(a);
  const std::ranges::subrange sub2(a, a);

  std::cout << sub1.size() << '\n';
  std::cout << sub2.size() << '\n';
}

出力

3
0

バージョン

言語

  • C++20

処理系

参照