multiset::end

Returns an iterator that addresses the location succeeding the last element in a multiset.

const_iterator end( ) const; 
iterator end( );

Return Value

A bidirectional iterator that addresses the location succeeding the last element in a multiset. If the multiset is empty, then multiset::end == multiset::begin.

Remarks

end is used to test whether an iterator has reached the end of its multiset. The value returned by end should not be dereferenced.

Example

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

int main( )
{
   using namespace std;   
   multiset <int> ms1;
   multiset <int> :: iterator ms1_Iter;
   multiset <int> :: const_iterator ms1_cIter;
   
   ms1.insert( 1 );
   ms1.insert( 2 );
   ms1.insert( 3 );

   ms1_Iter = ms1.end( );
   ms1_Iter--;
   cout << "The last element of ms1 is " << *ms1_Iter << endl;

   ms1.erase( ms1_Iter );

   // The following 3 lines would err as the iterator is const
   // ms1_cIter = ms1.end( );
   // ms1_cIter--;
   // ms1.erase( ms1_cIter );

   ms1_cIter = ms1.end( );
   ms1_cIter--;
   cout << "The last element of ms1 is now " << *ms1_cIter << endl;
}
The last element of ms1 is 3
The last element of ms1 is now 2

Requirements

Header: <set>

Namespace: std

See Also

Reference

multiset Class

Standard Template Library

Other Resources

multiset Members