C++ std operator<=30 Aug 2024 | 4 min read C++ std Operator<= is a non-member overloaded function of set in C++. This function is used to check whether the first set is less than or equal to other or not. Note: Operator <= compares element sequentially and at first mismatch comparison will stop.SyntaxParameterlhs: First set object. rhs: Second set object. Return valueIt returns true if the left side of the set object is less than or equal to the right side of the set object otherwise false. ComplexityComplexity will be constant, if the size of lhs and rhs is different. Otherwise, up to linear in the size of lhs and rhs. Iterator validityNo changes. Data RacesContainers, lhs and rhs are accessed. Concurrently accessing the elements of unmodified set is always safe. Exception SafetyThis function does not throw an exception. Example 1Let's see the simple example to check whether the first set is less than or equal to or not: Output: Set m1 is less than or equal to m2. Set m1 is not less than or equal to m2. In the above example, there are two sets m1 and m2. m1 and m2 contains one element. When we compare both sets then it will display the message "set m1 is less than or equal to m2" and after adding one extra element in m1 then it will display the message that "set m1 is not less than or equal to m2". Example 2Let's see a simple example: Output: The set m1 is less than or equal to the set m2. The set m1 is greater than the set m3. The set m1 is less than or equal to the set m4. Example 3Let's see a simple example: Output: 1 0 In the above example, if set s1 is less than or equal to s2 then it will return 1 otherwise, 0. Example 4Output: 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 sets m1 and m2. m1 contains stored password and second set m2 stores user's entered password. It checks whether the m2 is less than or equal to m1 or not. If password of m2 is less than or equal to m1 then login is successful otherwise login fails. Next TopicSet operator> |
set begin() function
C++ set begin() C++ is used to return an iterator referring to the first element of the set container. Syntax iterator begin(); ...
3 min read
set Size() function
C++ set size() C++ set size() function is used to find the number of elements present in the set container. Syntax Member type size_type is an unsigned integral type. size_type size() const; // until C++ 11 size_type...
3 min read
set operator>=
C++ std operator>= C++ std Operator>= is a non-member overloaded function of set in C++. This function is used to check whether the first set is greater than or equal to other or not. Note: Operator >= sequentially compares the element of set and comparison will stop at...
5 min read
set emplace_hint() function
C++ set emplace_hint() C++ is used to extend the set container by inserting new elements into the container using hint as a position for element. Elements are built directly (neither copied nor moved). The constructor of the element is called by giving the arguments args passed to...
4 min read
set erase() function
C++ set erase() C++ is used to remove either a single element associated with given key or a range of elements ([first, last)) from the set container. Hence, the size will be reduced by the number of elements removed. Syntax void erase (iterator position); ...
6 min read
set insert() function
C++ set insert() C++ set insert() is used for inserting new element in the set. Because element keys are unique in a set, the insertion operation first checks that whether the given key is already present in the set or not, if the key is present in the...
5 min read
set Swap() function
C++ set swap() C++ swap() function is used to swap (or exchange) the content of two sets but both the sets must be of same type although sizes may differ. Syntax void swap (set& x); Parameter x: set container to exchange the contents with. Return value None Complexity Constant. Iterator validity All references, iterators and pointers referring...
4 min read
set operator<
C++ std operator< Operator< is a non-member overloaded function of set in C++. This function is used to check whether the first set is less than other or not. Note: Operator < sequentially compares the element of set and comparison will stop at first mismatch. Syntax template <class T, class...
4 min read
set operator=() function
C++ set operator= There are following three uses of operator= in set: Operator= is used to assign new content to the set container by replacing its old content (or copy the content) and modifies size if necessary. Operator= is used to move the content of one set container into...
4 min read
set operator==
C++ std operator== C++ std operator== is a non-member overloaded function of set in C++. This function is used to check whether the two sets are equal or not. Note: Comparison between set objects is based on a pair wise comparison of the elements. Two sets are equal...
4 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India