Javatpoint Logo
Javatpoint Logo

C++ std operator<=

C++ Multiset Operator<= is a non-member overloaded function of multiset in C++. This function is used to check whether the first multiset is less than or equal to other or not.

Note: Operator <= compares element sequentially and at first mismatch comparison will stop.

Syntax

Parameter

lhs: First multiset object.

rhs: Second multiset object.

Return value

It returns true if the left side of the multiset object is less than or equal to the right side of the multiset object otherwise false.

Complexity

Complexity will be constant, if the size of lhs and rhs is different.

Otherwise, up to linear in the size of lhs and rhs.

Iterator validity

No changes.

Data Races

Containers, lhs and rhs are accessed.

Concurrently accessing the elements of unmodified multiset is always safe.

Exception Safety

This function does not throw an exception.

Example 1

Let's see the simple example to check whether the first multiset is less than or equal to or not:

Output:

Multiset m1 is less than or equal to m2.
Multiset m1 is not less than or equal to m2.

In the above example, there are two multisets m1 and m2. m1 and m2 contains one element. When we compare both multisets, then it will display the message "multiset m1 is less than or equal to m2" and after adding one extra element in m1 then it will display the message that "multiset m1 is not less than or equal to m2".

Example 2

Let's see a simple example:

Output:

The multiset m1 is less than or equal to the multiset m2.
The multiset m1 is greater than the multiset m3.
The multiset m1 is less than or equal to the multiset m4.

Example 3

Let's see a simple example:

Output:

1
0

In the above example, if multiset s1 is less than or equal to s2 then it will return 1 otherwise 0.

Example 4

Output:

1).
---------Login----------

Enter password: 
xyz@123
Password you have entered: 
xyz@123
Password stored in the system:
xyz@123

Welcome to your Page...

2).
---------Login----------

Enter password: 
abc@333
Password you have entered: 
abc@333
Password stored in the system:
xyz@123

Incorrect Password...

In the above example, there are two multisets m1 and m2. m1 contains stored password and second multiset m2 stores user's entered password. It checks whether the m2 is less than or equal to m2 or not. If password of m2 is less than or equal to m1 then login is successful otherwise login fails.

Next TopicC++ multiset




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA