Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 903 Bytes

front.md

File metadata and controls

64 lines (47 loc) · 903 Bytes

front

  • span[meta header]
  • std[meta namespace]
  • span[meta class]
  • function[meta id-type]
  • cpp20[meta cpp]
constexpr reference front() const;

概要

参照範囲の先頭要素を取得する。

事前条件

戻り値

以下と等価:

return *data();
  • data()[link data.md]

計算量

定数時間

#include <cassert>
#include <span>
#include <vector>

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

  int& x = std::span{v}.front();
  assert(x == 1);

  int& y = std::span{v}.subspan(2, 3).front();
  assert(y == 3);
}
  • front()[color ff0000]
  • subspan[link subspan.md]

出力

バージョン

言語

  • C++20

処理系