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

履歴 編集

function
<inplace_vector>

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

constexpr T* data() noexcept;             // (1) C++26
constexpr const T* data() const noexcept; // (2) C++26

概要

配列の先頭へのポインタを返す。

  • (1) : 非constな文脈で配列の先頭へのポインタを取得する。
  • (2) : constな文脈で配列の先頭への読み取り専用ポインタを取得する。

戻り値

内部に保持する配列の先頭要素へのポインタを返す。空の場合でも呼び出し自体は問題ないが、戻り値のポインタを間接参照してはならない。

例外

投げない

計算量

定数時間

#include <print>
#include <inplace_vector>

int main()
{
  std::inplace_vector<int, 5> iv = {3, 1, 4};

  int* p = iv.data();
  std::println("{}", *p);

  ++p;
  std::println("{}", *p);
}

出力

3
1

バージョン

言語

  • C++26

処理系

参照