Difference between revisions of "Template:cpp/container/operator cmp"
From cppreference.com
m (Text replace - "par req concept" to "par req named") |
|||
Line 37: | Line 37: | ||
Compares the contents of two containers. | Compares the contents of two containers. | ||
− | @1-2@ Checks if the contents of {{tt|lhs}} and {{tt|rhs}} are equal, that is, whether {{c|1=lhs.size() == rhs.size()}} and each element in {{tt|lhs}} compares equal with the element in {{tt|rhs}} at the same position. | + | @1-2@ Checks if the contents of {{tt|lhs}} and {{tt|rhs}} are equal, that is, {{#switch:{{{1|}}} |
+ | | vector | deque | list | set | multiset | map | multimap = | ||
+ | {{whether {{c|1=lhs.size() == rhs.size()}} and }} }} each element in {{tt|lhs}} compares equal with the element in {{tt|rhs}} at the same position. | ||
@3-6@ Compares the contents of {{tt|lhs}} and {{tt|rhs}} lexicographically. The comparison is performed by a function equivalent to {{lc|std::lexicographical_compare}}. | @3-6@ Compares the contents of {{tt|lhs}} and {{tt|rhs}} lexicographically. The comparison is performed by a function equivalent to {{lc|std::lexicographical_compare}}. |
Revision as of 21:23, 18 July 2018
template< ... > bool operator==( const std::{{{1}}}<...>& lhs, |
(1) | |
template< ... > bool operator!=( const std::{{{1}}}<...>& lhs, |
(2) | |
template< ... > bool operator<( const std::{{{1}}}<...>& lhs, |
(3) | |
template< ... > bool operator<=( const std::{{{1}}}<...>& lhs, |
(4) | |
template< ... > bool operator>( const std::{{{1}}}<...>& lhs, |
(5) | |
template< ... > bool operator>=( const std::{{{1}}}<...>& lhs, |
(6) | |
Compares the contents of two containers.
1-2) Checks if the contents of
lhs
and rhs
are equal, that is, each element in lhs
compares equal with the element in rhs
at the same position.3-6) Compares the contents of
lhs
and rhs
lexicographically. The comparison is performed by a function equivalent to std::lexicographical_compare.Parameters
lhs, rhs | - | containers whose contents to compare
|
Return value
1) true if the contents of the containers are equal, false otherwise
2) true if the contents of the containers are not equal, false otherwise
3) true if the contents of the
lhs
are lexicographically less than the contents of rhs
, false otherwise4) true if the contents of the
lhs
are lexicographically less than or equal the contents of rhs
, false otherwise5) true if the contents of the
lhs
are lexicographically greater than the contents of rhs
, false otherwise6) true if the contents of the
lhs
are lexicographically greater than or equal the contents of rhs
, false otherwiseComplexity
Linear in the size of the container