Namespaces
Variants
Views
Actions

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

From cppreference.com
 
 
 
std::basic_string
 
template< class T, class Alloc >
bool operator==( basic_string<T,Alloc>& lhs, basic_string<T,Alloc>& rhs );
(1)
template< class T, class Alloc >
bool operator!=( basic_string<T,Alloc>& lhs, basic_string<T,Alloc>& rhs );
(2)
template< class T, class Alloc >
bool operator<( basic_string<T,Alloc>& lhs, basic_string<T,Alloc>& rhs );
(3)
template< class T, class Alloc >
bool operator<=( basic_string<T,Alloc>& lhs, basic_string<T,Alloc>& rhs );
(4)
template< class T, class Alloc >
bool operator>( basic_string<T,Alloc>& lhs, basic_string<T,Alloc>& rhs );
(5)
template< class T, class Alloc >
bool operator>=( basic_string<T,Alloc>& lhs, basic_string<T,Alloc>& rhs );
(6)

Compares the contents of two strings.

1-2) Checks if the contents of lhs and rhs are equal, that is, lhs.size() == rhs.size() and each character in lhs has equivalent character 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.

[edit] Parameters

lhs, rhs - strings whose contents to compare

[edit] Return value

1) true if the contents of the strings are equivalent, false otherwise

2) true if the contents of the strings are not equivalent, 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

[edit] Complexity

Linear in the size of the strings.