Share via


multiset::clear

Erases all the elements of a multiset.

void clear( );

Example

// multiset_clear.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;   
   multiset <int> ms1;
   
   ms1.insert( 1 );
   ms1.insert( 2 );

   cout << "The size of the multiset is initially "
        << ms1.size( ) << "." << endl;

   ms1.clear( );
   cout << "The size of the multiset after clearing is " 
        << ms1.size( ) << "." << endl;
}

The size of the multiset is initially 2. The size of the multiset after clearing is 0.

Requirements

Header: <set>

Namespace: std

See Also

Reference

multiset Class

Standard Template Library

Other Resources

multiset Members