首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

operators (std::basic_string)

Compare two basic_string objects

template< class CharT, class Traits, class Alloc > bool operator==( const basic_string<CharT,Traits,Alloc>& lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(1)

template< class CharT, class Traits, class Alloc > bool operator!=( const basic_string<CharT,Traits,Alloc>& lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(2)

template< class CharT, class Traits, class Alloc > bool operator<( const basic_string<CharT,Traits,Alloc>& lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(3)

template< class CharT, class Traits, class Alloc > bool operator<=( const basic_string<CharT,Traits,Alloc>& lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(4)

template< class CharT, class Traits, class Alloc > bool operator>( const basic_string<CharT,Traits,Alloc>& lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(5)

template< class CharT, class Traits, class Alloc > bool operator>=( const basic_string<CharT,Traits,Alloc>& lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(6)

Compare a basic_string object and null-terminated array of T

template< class CharT, class Traits, class Alloc > bool operator==( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(7)

template< class CharT, class Traits, class Alloc > bool operator==( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );

(7)

template< class CharT, class Traits, class Alloc > bool operator!=( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(8)

template< class CharT, class Traits, class Alloc > bool operator!=( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );

(8)

template< class CharT, class Traits, class Alloc > bool operator<( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(9)

template< class CharT, class Traits, class Alloc > bool operator<( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );

(9)

template< class CharT, class Traits, class Alloc > bool operator<=( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(10)

template< class CharT, class Traits, class Alloc > bool operator<=( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );

(10)

template< class CharT, class Traits, class Alloc > bool operator>( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(11)

template< class CharT, class Traits, class Alloc > bool operator>( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );

(11)

template< class CharT, class Traits, class Alloc > bool operator>=( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );

(12)

template< class CharT, class Traits, class Alloc > bool operator>=( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );

(12)

将字符串的内容与另一个字符串或以空结尾的CharT...

所有比较都是通过compare()成员函数%28,它本身是根据Traits::compare()29%:

  • 如果两个字符串的大小都相同,则两个字符串是相等的。lhsrhs中的每个字符都是相等的。lhs中具有等效字符的rhs在同一位置。
  • 排序比较是按字典顺序进行的--通过一个等价于std::lexicographical_compare...

1-6%29比较两basic_string物品。

7-12%29比较abasic_string对象的空结束数组。CharT...

参数

lhs, rhs

-

strings whose contents to compare

返回值

true如果相应的比较成立,false否则。

例外

1-6%29

(none)

(until C++14)

noexcept specification: noexcept

(since C++14)

7-12%29%280%29

复杂性

在字符串的大小上是线性的。

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券