function
std::relational operators (deque)
<deque>
(1) | template <class T, class Alloc>
bool operator== (const deque<T,Alloc>& lhs, const deque<T,Alloc>& rhs);
|
---|
(2) | template <class T, class Alloc>
bool operator!= (const deque<T,Alloc>& lhs, const deque<T,Alloc>& rhs);
|
---|
(3) | template <class T, class Alloc>
bool operator< (const deque<T,Alloc>& lhs, const deque<T,Alloc>& rhs);
|
---|
(4) | template <class T, class Alloc>
bool operator<= (const deque<T,Alloc>& lhs, const deque<T,Alloc>& rhs);
|
---|
(5) | template <class T, class Alloc>
bool operator> (const deque<T,Alloc>& lhs, const deque<T,Alloc>& rhs);
|
---|
(6) | template <class T, class Alloc>
bool operator>= (const deque<T,Alloc>& lhs, const deque<T,Alloc>& rhs); |
---|
Relational operators for deque
Performs the appropriate comparison operation between the deque containers lhs and rhs.
Operations == and != are performed by first comparing sizes, and if they match, the elements are compared sequentially using algorithm equal, which stops at the first mismatch.
Operations <, >, <= and >= behave as if using algorithm lexicographical_compare, which compares the elements sequentially using operator< reflexively, stopping at the first mismatch.
These operators are overloaded in header <deque>.
Parameters
- lhs, rhs
- deque containers (to the left- and right-hand side of the operator, respectively), having both the same template parameters (T and Alloc).
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
// deque comparisons
#include <iostream>
#include <deque>
int main ()
{
std::deque<int> foo (3,100); // three ints with a value of 100
std::deque<int> bar (2,200); // two ints with a value of 200
if (foo==bar) std::cout << "foo and bar are equal\n";
if (foo!=bar) std::cout << "foo and bar are not equal\n";
if (foo< bar) std::cout << "foo is less than bar\n";
if (foo> bar) std::cout << "foo is greater than bar\n";
if (foo<=bar) std::cout << "foo is less than or equal to bar\n";
if (foo>=bar) std::cout << "foo is greater than or equal to bar\n";
return 0;
}
|
Output:
foo and bar are not equal
foo is less than bar
foo is less than or equal to bar
|
Return Value
true if the condition holds, and false otherwise.
Complexity
Linear in both lhs and rhs's sizes.
Iterator validity
No changes.