• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <flat_map>

    std::flat_multimap::size

    size_type size() const noexcept;
    

    概要

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

    戻り値

    containers型メンバ変数cがあるとして、以下を返す。

    return c.keys.size();
    

    計算量

    定数時間

    #include <flat_map>
    #include <iostream>
    
    int main ()
    {
      std::flat_multimap<int, char> fm;
    
      std::cout << fm.size() << std::endl;
    
      fm.insert({1, 'a'});
      fm.insert({2, 'b'});
      fm.insert({3, 'c'});
      fm.insert({1, 'a'});
    
      std::cout << fm.size() << std::endl;
    }
    

    出力

    0
    4
    

    バージョン

    言語

    • C++23

    処理系

    関連項目