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

履歴 編集

function
<inplace_vector>

std::inplace_vector::front(C++26)

constexpr reference front();             // (1) C++26
constexpr const_reference front() const; // (2) C++26

概要

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

  • (1) : 非constな文脈で先頭要素への参照を取得する。
  • (2) : constな文脈で先頭要素への読み取り専用参照を取得する。

戻り値

先頭要素への参照

計算量

定数時間

#include <print>
#include <inplace_vector>

int main()
{
  std::inplace_vector<int, 5> iv = {3, 1, 4};
  int& x = iv.front();
  std::println("{}", x);
}

出力

3

バージョン

言語

  • C++26

処理系

参照