• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <flat_set>

    std::flat_multiset::clear

    void clear() noexcept; // (1) C++23
    

    概要

    コンテナ内の全ての要素を削除する。各要素のデストラクタが呼ばれ、コンテナから削除される。size() は 0 になる。

    計算量

    線形時間。

    例外

    投げない。

    #include <flat_set>
    #include <iostream>
    
    int main ()
    {
      std::flat_multiset<int> fs = {3, 1, 4, 1};
    
      std::cout << fs.size() << std::endl;
    
      fs.clear();
    
      std::cout << fs.size() << std::endl;
    }
    

    出力

    4
    0
    

    バージョン

    言語

    • C++23

    処理系