Home » C++ multiset cend() function

C++ multiset cend() function

by Online Tutorials Library

C++ multiset cend()

C++ multiset cend() function is used to return a constant iterator which is next to the last entry in the multiset.

Note:- This is a placeholder. No element exists in this location and attempting to access is undefined behavior.

Syntax

A const_iterator is an iterator that points to constant content.

Parameter

None

Return value

The cend() function returns a constant iterator which is pointing next to the last element of the multiset.

Complexity

Constant.

Iterator validity

No changes.

Data Races

The container is accessed.

Concurrently accessing the elements of a multiset container is safe.

Exception Safety

This member function never throws exceptions.

Example 1

Let’s see the simple example for cend() function:

Output:

mymultiset contains: 10 10 20 20 30 40  

In the above example, cend() function is used to return an iterator pointing next to the last element in the mymultiset multiset.

Example 2

Let’s see a simple example to find the element in the multiset:

Output:

Enter value to find: 10  Element found: 10  

Example 3

Let’s see a simple example to iterate over the multiset using while loop:

Output:

Apple  Banana  Orange  Orange  

In the above example, cend() function is used to return an iterator pointing next to the last element in the mymultiset multiset.

Example 4

Let’s see a simple example:

Output:

1  1  2  3  

In the above example, cend() function is used to return an iterator pointing next to the last element in the mymultiset multiset.

Next TopicC++ multiset

You may also like