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

履歴 編集

function
<flat_set>

std::flat_set::size(C++23)

size_type size() const noexcept;

概要

コンテナ内の要素の数を返す。

戻り値

flat_set クラスが内部で保持している container_typec とすると、以下を返す。

return c.size();

計算量

定数時間。

#include <flat_set>
#include <iostream>

int main ()
{
  std::flat_set<int> fs;

  std::cout << fs.size() << std::endl;

  fs.insert(1);
  fs.insert(2);
  fs.insert(3);
  fs.insert(1);

  std::cout << fs.size() << std::endl;
}

出力

0
3

バージョン

言語

  • C++23

処理系

関連項目