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

履歴 編集

function
<span>

std::span::cend(C++23)

constexpr const_iterator cend() const noexcept;

概要

末尾要素の次を指すイテレータを取得する。

戻り値

return end();

例外

投げない

#include <iostream>
#include <span>
#include <vector>

template<typename I, std::sentinel_for<I> S>
bool is_iter_pair(I, S) {
  return true;
}

bool is_iter_pair(...) {
  return false;
}

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

  auto cit = sp.cend();
  --cit;

  std::cout << *cit << '\n';

  std::cout << std::boolalpha;
  std::cout << is_iter_pair(sp.cbegin(), sp.cend()) << '\n';
  std::cout << is_iter_pair(sp.begin(), sp.cend()) << '\n';
}

出力

5
true
true

バージョン

言語

  • C++23

処理系

参照