operators (std::array)

operator==,!=,<,<=,>,>=(std::array)

template< class T, std::size_t N >
bool operator==( const array<T,N>& lhs,
                 const array<T,N>& rhs );
(1)
template< class T, std::size_t N >
bool operator!=( const array<T,N>& lhs,
                 const array<T,N>& rhs );
(2)
template< class T, std::size_t N >
bool operator<( const array<T,N>& lhs,
                const array<T,N>& rhs );
(3)
template< class T, std::size_t N >
bool operator<=( const array<T,N>& lhs,
                 const array<T,N>& rhs );
(4)
template< class T, std::size_t N >
bool operator>( const array<T,N>& lhs,
                const array<T,N>& rhs );
(5)
template< class T, std::size_t N >
bool operator>=( const array<T,N>& lhs,
                 const array<T,N>& rhs );
(6)

Compares the contents of two containers.

1-2) Checks if the contents of lhs and rhs are equal, that is, whether 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
-T must meet the requirements of EqualityComparable in order to use overloads (1-2).
-T must meet the requirements of LessThanComparable in order to use overloads (3-6). The ordering relation must establish total order.

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 otherwise
4) true if the contents of the lhs are lexicographically less than or equal the contents of rhs, false otherwise
5) true if the contents of the lhs are lexicographically greater than the contents of rhs, false otherwise
6) true if the contents of the lhs are lexicographically greater than or equal the contents of rhs, false otherwise

Complexity

Linear in the size of the container.

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/container/array/operator_cmp

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部