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

履歴 編集

function
<flat_map>

std::flat_map::keys(C++23)

const key_container_type& keys() const noexcept; // C++23

概要

キーのコンテナを取得する。

戻り値

flat_map クラス内部で保持しているキーのコンテナ。

計算量

定数時間

#include <flat_map>
#include <iostream>
#include <type_traits>
#include <vector>

int main()
{
  std::flat_map<int, char> fm;
  fm[3] = 'C';
  fm[1] = 'A';
  fm[2] = 'B';

  static_assert(std::is_same_v<decltype(fm.keys()), const std::vector<int>&>);

  for (auto i : fm.keys()) {
      std::cout << i << std::endl;
  }
}

出力

1
2
3

バージョン

言語

  • C++23

処理系

関連項目

名前 説明
flat_map::values 値のコンテナを取得する