次の方法で共有


multimap::clear

multimap のすべての要素を消去します。

void clear( );

使用例

/Wp64 フラグでまたは 64 ビット プラットフォームの例をコンパイルすると、コンパイラ警告 C4267 が生成されます。 この警告の詳細については、「コンパイラの警告 (レベル 3) C4267」を参照してください。

// multimap_clear.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main( )
{
   using namespace std;
   multimap<int, int> m1;
   multimap<int, int>::size_type i;
   typedef pair<int, int> Int_Pair;

   m1.insert(Int_Pair(1, 1));
   m1.insert(Int_Pair(2, 4));

   i = m1.size();
   cout << "The size of the multimap is initially "
        << i << "." << endl;

   m1.clear();
   i = m1.size();
   cout << "The size of the multimap after clearing is "
        << i << "." << endl;
}
  

必要条件

ヘッダー: <map>

名前空間: std

参照

関連項目

multimap クラス

標準テンプレート ライブラリ