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

履歴 編集

function
<flat_set>

std::flat_multiset::extract

container_type extract() &&;  // C++23

概要

値のコンテナを戻り値として返す。

戻り値

クラス内部のデータ保持形式である container_type オブジェクト。

事後条件

呼び出し側の flat_multiset は空になる(たとえ例外で関数が中断されたとしても)。

計算量

定数時間。

備考

本関数は右辺値修飾されているので、右辺値からのみ読み出し可能である。

#include <flat_set>
#include <iostream>
#include <utility>

int main()
{
  std::flat_multiset<int> fs = {3, 1, 4, 1};

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

  decltype(fs)::container_type c = std::move(fs).extract();

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

  for (int i : c) {
    std::cout << i << std::endl;
  }
}

出力

4
0

1
1
3
4

バージョン

言語

  • C++23

処理系